jhomenet.security
Class RdbmsLoginModule

java.lang.Object
  extended by jhomenet.security.RdbmsLoginModule
All Implemented Interfaces:
javax.security.auth.spi.LoginModule

public class RdbmsLoginModule
extends java.lang.Object
implements javax.security.auth.spi.LoginModule

RdbmsLoginModule is a LoginModule that authenticates a given username/password credential against a JDBC datasource.

This LoginModule interoperates with any conformant JDBC datasource. To direct this LoginModule to use a specific JNDI datasource, two options must be specified in the login Configuration for this LoginModule.

    url=jdbc_url
    driverb>jdbc driver class
 

For the purposed of this example, the format in which the user's information must be stored in the database is in a table named "USER_AUTH" with the following columns

     USERID
     PASSWORD
     FIRST_NAME
     LAST_NAME
     DELETE_PERM
     UPDATE_PERM
 

Author:
dirwin
See Also:
LoginModule

Constructor Summary
RdbmsLoginModule()
          Default constructor.
 
Method Summary
 boolean abort()
           This method is called if the LoginContext's overall authentication failed.
 boolean commit()
          Abstract method to commit the authentication process (phase 2).
 void initialize(javax.security.auth.Subject subject, javax.security.auth.callback.CallbackHandler callbackHandler, java.util.Map<java.lang.String,?> sharedState, java.util.Map<java.lang.String,?> options)
           
 boolean login()
          Verify the password against the relevant JDBC datasource.
 boolean logout()
          Logout a user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RdbmsLoginModule

public RdbmsLoginModule()
Default constructor.

Method Detail

initialize

public void initialize(javax.security.auth.Subject subject,
                       javax.security.auth.callback.CallbackHandler callbackHandler,
                       java.util.Map<java.lang.String,?> sharedState,
                       java.util.Map<java.lang.String,?> options)
Specified by:
initialize in interface javax.security.auth.spi.LoginModule
See Also:
LoginModule.initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)

login

public boolean login()
              throws javax.security.auth.login.LoginException
Verify the password against the relevant JDBC datasource.

Specified by:
login in interface javax.security.auth.spi.LoginModule
Throws:
javax.security.auth.login.LoginException
See Also:
LoginModule.login()

commit

public boolean commit()
               throws javax.security.auth.login.LoginException
Abstract method to commit the authentication process (phase 2).

This method is called if the LoginContext's overall authentication succeeded (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules succeeded).

If this LoginModule's own authentication attempt succeeded (checked by retrieving the private state saved by the login method), then this method associates a RdbmsPrincipal with the Subject located in the LoginModule. If this LoginModule's own authentication attempted failed, then this method removes any state that was originally saved.

Specified by:
commit in interface javax.security.auth.spi.LoginModule
Throws:
javax.security.auth.login.LoginException
See Also:
LoginModule.commit()

abort

public boolean abort()
              throws javax.security.auth.login.LoginException

This method is called if the LoginContext's overall authentication failed. (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did not succeed).

If this LoginModule's own authentication attempt succeeded (checked by retrieving the private state saved by the login and commit methods), then this method cleans up any state that was originally saved.

Specified by:
abort in interface javax.security.auth.spi.LoginModule
Throws:
javax.security.auth.login.LoginException
See Also:
LoginModule.abort()

logout

public boolean logout()
               throws javax.security.auth.login.LoginException
Logout a user.

This method removes the Principals that were added by the commit method.

Specified by:
logout in interface javax.security.auth.spi.LoginModule
Throws:
javax.security.auth.login.LoginException
See Also:
LoginModule.logout()


Copyright © 2004-2005 David Irwin. All Rights Reserved.