Dear *,

I am going to do the “CloudForms” presentation in Luxembourg on the 25th of August 2011.
If your company or you are based in BeNeLux and are interested by this presentation, just let me know and I will try to arrange a Meeting for you.

BR
Frederic 😉

 
 
 
 
 

 

 

Dear *,

Here was the problem. One our client decided to not use Seam and do everything by himself. – Why reinvent the wheel ? –

Well, so he had an issue with the web page access which needs to have credentials. They were accessible by everyone if you knew the URL.

So the solution was to use servlet filter:

So create the Authentication filter implementation  named Authentication.java for instance :

package com.jboss.eas.project;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class Authentication implements Filter {
private FilterConfig customedFilterConfig;

public void doFilter(ServletRequest req, ServletResponse resp,FilterChain chain) throws IOException, ServletException {

if (((HttpServletRequest)req).getSession().getAttribute(Login.AUTH_KEY) == null) {
((HttpServletResponse)resp).sendRedirect(“../Non_Authorized_login.xhtml”);
} else {

chain.doFilter(req, resp);
}
}

public void init(FilterConfig customedFilterConfig) throws ServletException {
this.customedFilterConfig = customedFilterConfig;
}

public void destroy() {
customedFilterConfig = null;
}
}

Then create a login bean or adapt yours – e.g. here Login.java –  :

package com.jboss.eas.project;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public class Login {
public static final String AUTH_KEY = "username";
private String username;
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }public boolean isLoggedIn() {
return FacesContext.getCurrentInstance().getExternalContext()
.getSessionMap().get(AUTH_KEY) != null;
}public String login() {
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(
AUTH_KEY, username);
return “true”;
}public String logout() {
FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
.remove(AUTH_KEY);
return null;
}
}
 
Then add the following stanzas in your web.xml file :
 
<filter>
  <filter-name>Authentication</filter-name>
  <filter-class>com.jboss.eap.project.Authentication</filter-class>
</filter>
<filter-mapping>
  <filter-name>Authentication</filter-name>
  <url-pattern>/Authorized_Web_Pages_Access_Directory_Path/*</url-pattern>
</filter-mapping>

BTW, the “Authorized_Web_Pages_Access_Directory_Path" is the directory which contains all your protected web pages.

Then create a Error redirection web page in case of an access to a web page without credentials  – here Non_Authorized_login.xhtml –

<html>
<head>

You do not have access to this page. 😦 <p></p> You must be registered !

</head>
</html>
 
Finally create your xhtml or jsf page – here AuthenticatedLogin.xhtml –
 
<f:view>
 <h:form> Username:
  <h:panelGroup rendered="#{not login.loggedIn}">
    <h:inputText value="#{login.name}" />
    <h:commandButton value="login" action="#{login.login}" />
  </h:panelGroup> <h:commandButton value="logout" action="#{login.logout}" rendered="#{login.loggedIn}" />
 </h:form>
</f:view>
 
Here should be the result when you try to access a page without successful logged in using its URL  :

BR

Frederic 😉

Dear *,

Yesterday someone asked me how to include  javax.servlet-3.0.jar in his JBoss AS 7 Project in using Maven.

My answer was to go to the JBoss community repository web interface – see URL below –
and search for the “servlet-api” then insert in his project’s pom.xml the follwoing content under the <dependencies></dependencies> stanzas :

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0</version>

<scope>provided</scope>

</dependency>

Rem : https://repository.jboss.org/nexus/index.html

BR

Frederic 😉

Dear *,

Well, in the case like me you would like to use Hybernate validator in you JBoss AS 7 with Maven.

Then open you pom.xml and add the following stanzas in corresponding parent tags :

<pluginRepositories>
……………………..
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Group Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url&gt;
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

AND

<dependencyManagement>
<dependencies>
…………………………..
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

Ref : http://docs.jboss.org/hibernate/validator/4.2/reference/en-US/html_single/#validator-gettingstarted-createproject

BR
Frederic 😉

Dear *,

Well, here are few MRG screen shots I did this evening for one of our client.
OK, I still need to run some jobs in order to test the messaging part. it should be for tomorrow. 😉

If your company or you are based in BeNeLux and are interested by the presentation I introduce in one of my previous post, just let me know and I will try to arrange a Meeting for you.



























Ref: Red Hat MRG
BR
Frederic 😉

 
Dear *,

Well, Ok you all already know that AS7 is there.
But for those who were in holidays….

Congrats JBoss Team ! AS7 is so fast….

BR
Frederic 😉

Where is the time when professional people were thinking Linux was a student hobby ????

Links : Toyota Joins Linux Foundation as a gold member

BR
Frederic 😉

Well, all my congratulations Bert as well as all other Fedora Ambassadors — Bert Web page
On the Fedora Project Front page. 😉

Have fun with Fedora. – Specially in Belgium (Picture taken @ FOSDEM’11) 😉 –

N.B. http://be.fedoracommunity.org/
BR
Frederic 😉

Dear *,

I am going to do the “MRG 2.0” – Messaging, RealTime, Grid – presentation in Luxembourg on the 25th of August 2011.
If your company or you are based in BeNeLux and are interested by this presentation, just let me know and I will try to arrange a Meeting for you.

BR
Frederic 😉