net.sf.jguard.authentication
Class AuthenticationUtils

java.lang.Object
  extended by net.sf.jguard.authentication.AuthenticationUtils

public class AuthenticationUtils
extends java.lang.Object

Authentication utility class stored on the user's session.

Author:
Charles Gay this class was inspired by the article on jaas published at this address.

Constructor Summary
AuthenticationUtils()
           
 
Method Summary
 javax.security.auth.login.LoginContext authenticate(java.lang.String applicationName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String authScheme)
          encapsulate JAAS login lifecycle.
 javax.security.auth.Subject getSubject()
          retrieve the subject from the loginContext.
 void logout()
          logout the user with the related LoginContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthenticationUtils

public AuthenticationUtils()
Method Detail

authenticate

public javax.security.auth.login.LoginContext authenticate(java.lang.String applicationName,
                                                           javax.servlet.http.HttpServletRequest request,
                                                           javax.servlet.http.HttpServletResponse response,
                                                           java.lang.String authScheme)
                                                    throws javax.security.auth.login.LoginException
encapsulate JAAS login lifecycle.

Parameters:
applicationName - one of the application names located in 'login.config.url's files defined in the 'java.security' file. 'jGuard.loginScheme' file is one of them.
username - user login
password - user password
Returns:
authentification state. true if the user has been authenticated succesfully.
Throws:
javax.security.auth.login.LoginException

getSubject

public javax.security.auth.Subject getSubject()
retrieve the subject from the loginContext.

Returns:
authenticated Subject.

logout

public void logout()
logout the user with the related LoginContext.

Parameters:
applicationName -
username - user login
password - user password