public class AuthenticationManager extends Object
This class initializes the "stack" from the DSpace configuration, and then invokes methods in the appropriate order on behalf of clients.
See the AuthenticationMethod interface for details about what each function does.
Configuration
The stack of authentication methods is defined by one property in the DSpace configuration:
plugin.sequence.org.dspace.eperson.AuthenticationMethod = a list of method class names
e.g.
plugin.sequence.org.dspace.eperson.AuthenticationMethod = \
org.dspace.eperson.X509Authentication, \
org.dspace.eperson.PasswordAuthentication
The "stack" is always traversed in order, with the methods specified first (in the configuration) thus getting highest priority.
AuthenticationMethod| Constructor and Description |
|---|
AuthenticationManager() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
allowSetPassword(Context context,
javax.servlet.http.HttpServletRequest request,
String username)
Predicate, can user set EPerson password.
|
static int |
authenticate(Context context,
String username,
String password,
String realm,
javax.servlet.http.HttpServletRequest request)
Test credentials for authenticity.
|
static int |
authenticateImplicit(Context context,
String username,
String password,
String realm,
javax.servlet.http.HttpServletRequest request)
Test credentials for authenticity, using only Implicit methods.
|
static Iterator<AuthenticationMethod> |
authenticationMethodIterator()
Get stack of authentication methods.
|
static boolean |
canSelfRegister(Context context,
javax.servlet.http.HttpServletRequest request,
String username)
Predicate, can a new EPerson be created.
|
static int[] |
getSpecialGroups(Context context,
javax.servlet.http.HttpServletRequest request)
Get list of extra groups that user implicitly belongs to.
|
static void |
initEPerson(Context context,
javax.servlet.http.HttpServletRequest request,
EPerson eperson)
Initialize a new e-person record for a self-registered new user.
|
public static int authenticate(Context context, String username, String password, String realm, javax.servlet.http.HttpServletRequest request)
SUCCESS, or otherwise
returns the most favorable outcome from one of the methods.context - DSpace context, will be modified (ePerson set) upon success.username - Username (or email address) when method is explicit. Use null for
implicit method.password - Password for explicit auth, or null for implicit method.realm - Realm is an extra parameter used by some authentication methods, leave null if
not applicable.request - The HTTP request that started this operation, or null if not applicable.Meaning:
SUCCESS - authenticated OK.
BAD_CREDENTIALS - user exists, but credentials (e.g. password) don't match
CERT_REQUIRED - not allowed to login this way without X.509 cert.
NO_SUCH_USER - user not found using this method.
BAD_ARGS - user/password not appropriate for this method
public static int authenticateImplicit(Context context, String username, String password, String realm, javax.servlet.http.HttpServletRequest request)
authenticate(), except it only invokes the
implicit authentication methods the stack.context - DSpace context, will be modified (ePerson set) upon success.username - Username (or email address) when method is explicit. Use null for
implicit method.password - Password for explicit auth, or null for implicit method.realm - Realm is an extra parameter used by some authentication methods, leave null if
not applicable.request - The HTTP request that started this operation, or null if not applicable.Meaning:
SUCCESS - authenticated OK.
BAD_CREDENTIALS - user exists, but credentials (e.g. password) don't match
CERT_REQUIRED - not allowed to login this way without X.509 cert.
NO_SUCH_USER - user not found using this method.
BAD_ARGS - user/password not appropriate for this method
public static boolean canSelfRegister(Context context, javax.servlet.http.HttpServletRequest request, String username) throws SQLException
canSelfRegister() of every authentication
method in the stack, and returns true if any of them is true.context - DSpace contextrequest - HTTP request, in case it's needed. Can be null.username - Username, if available. Can be null.SQLExceptionpublic static boolean allowSetPassword(Context context, javax.servlet.http.HttpServletRequest request, String username) throws SQLException
allowSetPassword() method of any
member of the stack returns true.context - DSpace contextrequest - HTTP request, in case it's needed. Can be null.username - Username, if available. Can be null.SQLExceptionpublic static void initEPerson(Context context, javax.servlet.http.HttpServletRequest request, EPerson eperson) throws SQLException
initEperson()context - DSpace contextrequest - HTTP request, in case it's needed. Can be null.eperson - newly created EPerson record - email + information from the
registration form will have been filled out.SQLExceptionpublic static int[] getSpecialGroups(Context context, javax.servlet.http.HttpServletRequest request) throws SQLException
getSpecialGroups()
methods in the stack.context - A valid DSpace context.request - The request that started this operation, or null if not applicable.SQLExceptionpublic static Iterator<AuthenticationMethod> authenticationMethodIterator()
Iterator that steps through each configured
authentication method, in order of precedence.Copyright © 2014 DuraSpace. All Rights Reserved.