Package org.jboss.security.auth.spi
Class UsersLoginModule
- java.lang.Object
-
- org.jboss.security.auth.spi.AbstractServerLoginModule
-
- org.jboss.security.auth.spi.UsernamePasswordLoginModule
-
- org.jboss.security.auth.spi.UsersLoginModule
-
- All Implemented Interfaces:
LoginModule
public class UsersLoginModule extends UsernamePasswordLoginModule
A simple properties file based login module that consults a Java Properties formatted text files for username to password("users.properties") mapping. The name of the properties file may be overriden by the usersProperties option. The properties file are loaded during initialization using the thread context class loader. This means that these files can be placed into the J2EE deployment jar or the JBoss config directory. The users.properties file uses a format: username1=password1 username2=password2 ... to define all valid usernames and their corresponding passwords.- Version:
- $Revision$
- Author:
- Thomas.Diesler@jboss.org
-
-
Field Summary
-
Fields inherited from class org.jboss.security.auth.spi.AbstractServerLoginModule
callbackHandler, jbossModuleName, log, loginOk, options, principalClassModuleName, principalClassName, sharedState, subject, unauthenticatedIdentity, useFirstPass
-
-
Constructor Summary
Constructors Constructor Description UsersLoginModule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Group[]
getRoleSets()
Return a group Roles with no membersprotected String
getUsersPassword()
Get the expected password for the current username available via the getUsername() method.void
initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options)
Initialize this LoginModule.boolean
login()
Method to authenticate a Subject (phase 1).-
Methods inherited from class org.jboss.security.auth.spi.UsernamePasswordLoginModule
createPasswordHash, getCredentials, getIdentity, getUnauthenticatedIdentity, getUsername, getUsernameAndPassword, getValidateError, safeClose, setValidateError, validatePassword
-
Methods inherited from class org.jboss.security.auth.spi.AbstractServerLoginModule
abort, addValidOptions, checkOptions, commit, createGroup, createIdentity, getCallerPrincipalGroup, getUseFirstPass, logout
-
-
-
-
Method Detail
-
initialize
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options)
Initialize this LoginModule.- Specified by:
initialize
in interfaceLoginModule
- Overrides:
initialize
in classUsernamePasswordLoginModule
- Parameters:
options
- the login module option map. Supported options include: usersProperties: The name of the properties resource containing user/passwords. The default is "users.properties"subject
- the Subject to update after a successful login.callbackHandler
- the CallbackHandler that will be used to obtain the the user identity and credentials.sharedState
- a Map shared between all configured login module instances
-
login
public boolean login() throws LoginException
Method to authenticate a Subject (phase 1). This validates that the users properties file were loaded and then calls super.login to perform the validation of the password.- Specified by:
login
in interfaceLoginModule
- Overrides:
login
in classUsernamePasswordLoginModule
- Throws:
LoginException
- thrown if the users or roles properties files were not found or the super.login method fails.
-
getRoleSets
protected Group[] getRoleSets() throws LoginException
Return a group Roles with no members- Specified by:
getRoleSets
in classAbstractServerLoginModule
- Returns:
- Group[] containing the sets of roles
- Throws:
LoginException
-
getUsersPassword
protected String getUsersPassword()
Description copied from class:UsernamePasswordLoginModule
Get the expected password for the current username available via the getUsername() method. This is called from within the login() method after the CallbackHandler has returned the username and candidate password.- Specified by:
getUsersPassword
in classUsernamePasswordLoginModule
- Returns:
- the valid password String
-
-