public class SimplePasswordAuthenticator extends Object implements Authenticator
| Modifier and Type | Field and Description |
|---|---|
protected Properties |
groups |
protected MessageDigest |
md |
protected Properties |
users |
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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). |
protected Properties users
protected Properties groups
protected MessageDigest md
public SimplePasswordAuthenticator(Properties usersFile, Properties groupFile)
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.usersFile - groupFile - IOExceptionpublic SimplePasswordAuthenticator(Properties usersFile, Properties groupFile, MessageDigest messageDigest)
usersFile - groupFile - messageDigest - IOExceptionpublic boolean authenticate(String login, String password)
authenticate in interface Authenticatorlogin - The login of the user to authenticate.password - The password used for authentication.true, if the user exists and the password equals the one
stored within the authenticator.Authenticator.authenticate(java.lang.String, java.lang.String)public List<String> getRoles(String user)
Authenticatorlogin
belongs to.getRoles in interface Authenticatoruser - The user's login.Authenticator.getRoles(java.lang.String)public boolean isUserInRole(String user, String role)
Authenticatoruser) is a member of the
specified group (role).isUserInRole in interface Authenticatoruser - The user to check.role - The group to check.true, if the users is a member of the given group.Authenticator.isUserInRole(java.lang.String, java.lang.String)Copyright © 2013 jwall.org. All Rights Reserved.