org.jwall.web.audit.util
Class SimplePasswordAuthenticator

java.lang.Object
  extended by org.jwall.web.audit.util.SimplePasswordAuthenticator
All Implemented Interfaces:
Authenticator
Direct Known Subclasses:
PasswordFileAuthenticator

public class SimplePasswordAuthenticator
extends Object
implements Authenticator

Author:
Christian Bockermann <chris@jwall.org>

Constructor Summary
SimplePasswordAuthenticator(Properties usersFile, Properties groupFile)
          This creates a new authenticator which reads users from the given file usersFile.
SimplePasswordAuthenticator(Properties usersFile, Properties groupFile, MessageDigest messageDigest)
          This creates a new authenticator in the same manner as the above constructor does.
 
Method Summary
 boolean authenticate(String login, String password)
          This method checks the given login and password to the internal user-information.
 List<String> getRoles(String user)
          This method returns the list of groups which the user sepcified by login belongs to.
 boolean isUserInRole(String user, String role)
          This method returns if the given user (user) is a member of the specified group (role).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePasswordAuthenticator

public SimplePasswordAuthenticator(Properties usersFile,
                                   Properties groupFile)
This creates a new authenticator which reads users from the given file usersFile. The group information is read from groupFile. The user file is expected to have one line of the format
     user=password
 
for each user. The password is supposed to be in plaintext. The group file is supposed to have a line for each group, i.e.
     group1=user1,user2,user3
 
Similar to the standard unix password/group format.

Parameters:
usersFile -
groupFile -
Throws:
IOException

SimplePasswordAuthenticator

public SimplePasswordAuthenticator(Properties usersFile,
                                   Properties groupFile,
                                   MessageDigest messageDigest)
This creates a new authenticator in the same manner as the above constructor does. It additionally allows for the specification of a message digest algorithm, which is used to compute a digest of the password before comparing it during authentication.

Parameters:
usersFile -
groupFile -
messageDigest -
Throws:
IOException
Method Detail

authenticate

public boolean authenticate(String login,
                            String password)
This method checks the given login and password to the internal user-information. If a message digest was specified during the creation of this authenticator, the given digest of the given password is computed before comparison.

Specified by:
authenticate in interface Authenticator
Parameters:
login - The login of the user to authenticate.
password - The password used for authentication.
Returns:
true, if the user exists and the password equals the one stored within the authenticator.
See Also:
Authenticator.authenticate(java.lang.String, java.lang.String)

getRoles

public List<String> getRoles(String user)
Description copied from interface: Authenticator
This method returns the list of groups which the user sepcified by login belongs to.

Specified by:
getRoles in interface Authenticator
Parameters:
user - The user's login.
Returns:
The list of group names, which the user is a member of.
See Also:
Authenticator.getRoles(java.lang.String)

isUserInRole

public boolean isUserInRole(String user,
                            String role)
Description copied from interface: Authenticator
This method returns if the given user (user) is a member of the specified group (role).

Specified by:
isUserInRole in interface Authenticator
Parameters:
user - The user to check.
role - The group to check.
Returns:
true, if the users is a member of the given group.
See Also:
Authenticator.isUserInRole(java.lang.String, java.lang.String)


Copyright © 2012 jwall.org. All Rights Reserved.