Off the record

Aller au contenu | Aller au menu | Aller à la recherche

vendredi 28 mars 2008

JEE authentication best practices for the web

4 authentication methods to identify a user with JAAS over HTTP

  • basic authentication : the popup asking for login/password, not encrypting anything :-C
  • digest-authentication : same as basic, with password encryption. Not a really nice user experience (login popups remind of the 90's :( )
  • certificate based authentication : HTTPS, using SSL, secured socket layer. first the usual PKI handshake (asymetric encryption) then the usual symetric encryption for performance. (A variant of this authentication is also managed for installations providing users PKI certificates, chip card format for example)
  • form based authentication, the usual HTML form...

How do i do that?

-> form based authentication, most often used :

  • add a security constraint and a security role in web.xml :
       <web-resource-name>All JSP direct access</web-resource-name>  
        No Access  

     <description>NO Access</description>  
  • edit the web.xml file to add a login-config block :

Then config your JAAS realm. Done. ;-)
-> Seriously. I'll complete the article later.

mercredi 26 mars 2008

Java annotations

Brief review of the Java annotations.

standard annotations
  • @Deprecated
  • @SuppressWarnings
  • @Override
  • @Inherited
  • @Retention(RetentionPolicy.SOURCE / RetentionPolicy.CLASS / RetentionPolicy.RUNTIME)
  • @Target(ElementType.CONSTRUCTOR / ElementType.METHOD / ElementType.PACKAGE / ElementType. ) (Note that more than one ElementType is allowed here).
additional annotations

Here we go. Now we want to developp our own annotation. Example...

 public @interface TODO { 
 	String value(); 
 	Level  level() default Level.NORMAL; 
 	public static enum Level { MINEUR, NORMAL, IMPORTANT }; 

This will be used as follows :

 @TODO(value="whatever message we want here describing the TODO...", level=NORMAL) 

Afterwards, we will have to tell the APT (annotation processing tool) what he is supposed to do with those annotations.
Source :

vendredi 7 mars 2008

Thank you gmail...