org.n52.security.authentication
Class JAASAuthenticationService

java.lang.Object
  extended by org.n52.security.authentication.JAASAuthenticationService
All Implemented Interfaces:
AuthenticationService

public class JAASAuthenticationService
extends java.lang.Object
implements AuthenticationService

Class JAASAuthenticationService implements the AuthenticationService interface by using the JAAS api.

This AuthenticationService implementation is the default implementation used within 52n-security. If you create an instance it uses the default JAAS Configuration (Configuration.getConfiguration() and an empty application name to perform logins.

You can use the setter methods for the applicationname and the Configuration to change the behavior of this class.

Version:
$Revision: $
Author:
Marko Reiprecht Created on 18.07.2008

Constructor Summary
JAASAuthenticationService()
          Constructor creates a new instance.
 
Method Summary
 AuthenticationContext createAuthenticationContext()
          Method creates a new AuthenticationContext.
protected  javax.security.auth.login.LoginContext createLoginContext(java.lang.String applicationName, javax.security.auth.Subject subject, javax.security.auth.callback.CallbackHandler handler, javax.security.auth.login.Configuration configuration)
          Method creates a LoginContext.
 java.lang.String getApplicationName()
          Method gets the applicationName.
 javax.security.auth.login.Configuration getConfiguration()
          Method gets the configuration.
 AuthenticationContext login()
          Method performs a "anonymous" login.
 AuthenticationContext login(javax.security.auth.callback.CallbackHandler handler)
          Method performs a login.
 AuthenticationContext login(javax.security.auth.callback.CallbackHandler handler, AuthenticationContext ctx)
          Method performs a login with a given authentication context.
 AuthenticationContext logout(AuthenticationContext ctx)
          Method performs a logout.
 void setApplicationName(java.lang.String applicationName)
          Method sets the applicationName.
 void setConfiguration(javax.security.auth.login.Configuration configuration)
          Method sets the configuration.
protected  AuthenticationException wrap(javax.security.auth.login.LoginException ex)
          Method converts a LoginException in a AuthenticationException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAASAuthenticationService

public JAASAuthenticationService()
Constructor creates a new instance.

Method Detail

getApplicationName

public java.lang.String getApplicationName()
Method gets the applicationName.

Returns:
String.
See Also:
javax.security.auth.login.Configuration} for details about the application name.

setApplicationName

public void setApplicationName(java.lang.String applicationName)
Method sets the applicationName.

Parameters:
applicationName - the applicationName.
See Also:
javax.security.auth.login.Configuration} for details about the application name.

getConfiguration

public javax.security.auth.login.Configuration getConfiguration()
Method gets the configuration.

Returns:
Configuration.

setConfiguration

public void setConfiguration(javax.security.auth.login.Configuration configuration)
Method sets the configuration.

Parameters:
configuration - the configuration.

createAuthenticationContext

public AuthenticationContext createAuthenticationContext()
Description copied from interface: AuthenticationService
Method creates a new AuthenticationContext. The context will be in state not authenticated and contain an empty Subject.

Specified by:
createAuthenticationContext in interface AuthenticationService
Returns:
AuthenticationContext.
See Also:
AuthenticationService.createAuthenticationContext()

login

public AuthenticationContext login()
                            throws AuthenticationException
Description copied from interface: AuthenticationService
Method performs a "anonymous" login. The behavior of this mehtod is implementation dependend.

The semantic is that somebody tries to login without any credentials, so an implementation can throw an error or create an "anonymous" AuthenticationContext.

Specified by:
login in interface AuthenticationService
Returns:
AuthenticationContext.
Throws:
AuthenticationException - if error occurs.
See Also:
AuthenticationService.login()

login

public AuthenticationContext login(javax.security.auth.callback.CallbackHandler handler)
                            throws AuthenticationException
Description copied from interface: AuthenticationService
Method performs a login. Credentials and other informations required to successfull execute the login are provided by an callback handler instance.

Specified by:
login in interface AuthenticationService
Parameters:
handler - the handler.
Returns:
AuthenticationContext.
Throws:
AuthenticationException - if error occurs.
See Also:
AuthenticationService.login(CallbackHandler)

login

public AuthenticationContext login(javax.security.auth.callback.CallbackHandler handler,
                                   AuthenticationContext ctx)
                            throws AuthenticationException
Description copied from interface: AuthenticationService
Method performs a login with a given authentication context.

Credentials and other informations required to successfull execute the login are provided by an callback handler instance.

Specified by:
login in interface AuthenticationService
Parameters:
handler - the handler.
ctx - the ctx.
Returns:
AuthenticationContext.
Throws:
AuthenticationException - if error occurs.
See Also:
AuthenticationService.login(CallbackHandler, AuthenticationContext)

logout

public AuthenticationContext logout(AuthenticationContext ctx)
                             throws AuthenticationException
Description copied from interface: AuthenticationService
Method performs a logout.

Specified by:
logout in interface AuthenticationService
Parameters:
ctx - the ctx.
Returns:
AuthenticationContext.
Throws:
AuthenticationException - if error occurs.
See Also:
AuthenticationService.logout(AuthenticationContext)

createLoginContext

protected javax.security.auth.login.LoginContext createLoginContext(java.lang.String applicationName,
                                                                    javax.security.auth.Subject subject,
                                                                    javax.security.auth.callback.CallbackHandler handler,
                                                                    javax.security.auth.login.Configuration configuration)
Method creates a LoginContext.

Parameters:
applicationName - the applicationName.
subject - the subject.
handler - the handler.
configuration - the configuration.
Returns:
LoginContext.

wrap

protected AuthenticationException wrap(javax.security.auth.login.LoginException ex)
Method converts a LoginException in a AuthenticationException.

Parameters:
ex - the ex.
Returns:
AuthenticationException.


Copyright © 2004-2009 52north.org. All Rights Reserved.