public class IPAuthentication extends Object implements AuthenticationMethod
authentication.ip.<GROUPNAME> = <IPRANGE>[, <IPRANGE> ...]
e.g. authentication.ip.MIT = 18., 192.25.0.0/255.255.0.0
Negative matches can be included by prepending the range with a '-'. For example if you want to include all of a class B network except for users of a contained class c network, you could use:
111.222,-111.222.333.
For supported IP ranges see IPMatcher.
| Modifier and Type | Field and Description |
|---|---|
protected GroupService |
groupService |
protected Map<IPMatcher,UUID> |
ipMatcherGroupIDs
Maps IPMatchers to group IDs (Integers) where we know the group DB ID
|
protected Map<IPMatcher,String> |
ipMatcherGroupNames
Maps IPMatchers to group names when we don't know group DB ID yet.
|
protected List<IPMatcher> |
ipMatchers
All the IP matchers
|
protected List<IPMatcher> |
ipNegativeMatchers
All the negative IP matchers
|
protected static Boolean |
useProxies
Whether to look for x-forwarded headers for logging IP addresses
|
BAD_ARGS, BAD_CREDENTIALS, CERT_REQUIRED, NO_SUCH_USER, SUCCESS| Constructor and Description |
|---|
IPAuthentication()
Initialize an IP authenticator, reading in the configuration.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addMatchers(String groupName,
String[] ipRanges)
Add matchers for the given comma-delimited IP ranges and group.
|
boolean |
allowSetPassword(Context context,
javax.servlet.http.HttpServletRequest request,
String username)
Should (or can) we allow the user to change their password.
|
int |
authenticate(Context context,
String username,
String password,
String realm,
javax.servlet.http.HttpServletRequest request)
Authenticate the given or implicit credentials.
|
boolean |
canSelfRegister(Context context,
javax.servlet.http.HttpServletRequest request,
String username)
Predicate, whether to allow new EPerson to be created.
|
List<Group> |
getSpecialGroups(Context context,
javax.servlet.http.HttpServletRequest request)
Get list of extra groups that user implicitly belongs to.
|
void |
initEPerson(Context context,
javax.servlet.http.HttpServletRequest request,
EPerson eperson)
Initialize a new EPerson record for a self-registered new user.
|
boolean |
isImplicit()
Predicate, is this an implicit authentication method.
|
String |
loginPageTitle(Context context)
Get title of login page to which to redirect.
|
String |
loginPageURL(Context context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Get login page to which to redirect.
|
protected static Boolean useProxies
protected GroupService groupService
protected Map<IPMatcher,String> ipMatcherGroupNames
public IPAuthentication()
protected void addMatchers(String groupName, String[] ipRanges)
groupName - name of groupipRanges - IP rangespublic boolean canSelfRegister(Context context, javax.servlet.http.HttpServletRequest request, String username) throws SQLException
AuthenticationMethodcanSelfRegister in interface AuthenticationMethodcontext - DSpace contextrequest - HTTP request, in case it's needed. May be null.username - Username, if available. May be null.SQLException - if database errorpublic void initEPerson(Context context, javax.servlet.http.HttpServletRequest request, EPerson eperson) throws SQLException
AuthenticationMethodinitEPerson in interface AuthenticationMethodcontext - DSpace contextrequest - HTTP request, in case it's needed. May be null.eperson - newly created EPerson record - email + information from the
registration form will have been filled out.SQLException - if database errorpublic boolean allowSetPassword(Context context, javax.servlet.http.HttpServletRequest request, String username) throws SQLException
AuthenticationMethodallowSetPassword in interface AuthenticationMethodcontext - DSpace contextrequest - HTTP request, in case it's needed. May be null.username - Username, if available. May be null.SQLException - if database errorpublic boolean isImplicit()
AuthenticationMethodisImplicit in interface AuthenticationMethodpublic List<Group> getSpecialGroups(Context context, javax.servlet.http.HttpServletRequest request) throws SQLException
AuthenticationMethodIt might make sense to implement this method by itself in a separate authentication method that just adds special groups, if the code doesn't belong with any existing auth method. The stackable authentication system was designed expressly to separate functions into "stacked" methods to keep your site-specific code modular and tidy.
getSpecialGroups in interface AuthenticationMethodcontext - A valid DSpace context.request - The request that started this operation, or null if not
applicable.null.SQLException - if database errorpublic int authenticate(Context context, String username, String password, String realm, javax.servlet.http.HttpServletRequest request) throws SQLException
AuthenticationMethodEPerson. If an EPerson is found it is
set in the Context that was passed.authenticate in interface AuthenticationMethodcontext - 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. passwd) 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/pw not appropriate for this method
SQLException - if database errorpublic String loginPageURL(Context context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
AuthenticationMethodloginPageURL in interface AuthenticationMethodcontext - DSpace context, will be modified (ePerson set) upon success.request - The HTTP request that started this operation, or null if not applicable.response - The HTTP response from the servlet method.public String loginPageTitle(Context context)
AuthenticationMethodloginPageTitle in interface AuthenticationMethodcontext - DSpace context, will be modified (ePerson set) upon success.Copyright © 2016 DuraSpace. All rights reserved.