public class ShibAuthentication extends Object implements AuthenticationMethod
| Modifier and Type | Field and Description |
|---|---|
protected String |
COLUMN_NAME_REGEX
Validate Postgres Column Names
|
protected ConfigurationService |
configurationService |
protected EPersonService |
ePersonService |
protected GroupService |
groupService |
protected int |
METADATA_MAX_SIZE
Maximum length for eperson additional metadata fields
|
protected MetadataFieldService |
metadataFieldService |
protected Map<String,String> |
metadataHeaderMap
Additional metadata mappings
|
protected MetadataSchemaService |
metadataSchemaService |
protected int |
NAME_MAX_SIZE
Maximum length for eperson metadata fields
|
protected int |
PHONE_MAX_SIZE |
BAD_ARGS, BAD_CREDENTIALS, CERT_REQUIRED, NO_SUCH_USER, SUCCESS| Constructor and Description |
|---|
ShibAuthentication() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowSetPassword(Context context,
javax.servlet.http.HttpServletRequest request,
String email)
Indicate whether or not a particular self-registering user can set
themselves a password in the profile info form.
|
int |
authenticate(Context context,
String username,
String password,
String realm,
javax.servlet.http.HttpServletRequest request)
Authenticate the given or implicit credentials.
|
protected boolean |
autoCreateEpersonMetadataField(Context context,
String metadataName)
Automatically create a new metadataField for an eperson
|
boolean |
canSelfRegister(Context context,
javax.servlet.http.HttpServletRequest request,
String username)
Indicate whether or not a particular user can self-register, based on
e-mail address.
|
protected boolean |
checkIfEpersonMetadataFieldExists(Context context,
String metadataName)
Check if a MetadataField for an eperson is available.
|
protected String |
findAttribute(javax.servlet.http.HttpServletRequest request,
String name)
Find a particular Shibboleth header value and return the all values.
|
protected EPerson |
findEPerson(Context context,
javax.servlet.http.HttpServletRequest request)
Identify an existing EPerson based upon the shibboleth attributes provided on
the request object.
|
protected List<String> |
findMultipleAttributes(javax.servlet.http.HttpServletRequest request,
String name)
Find a particular Shibboleth hattributeeader value and return the values.
|
protected String |
findSingleAttribute(javax.servlet.http.HttpServletRequest request,
String name)
Find a particular Shibboleth header value and return the first value.
|
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 e-person record for a self-registered new user.
|
protected void |
initialize(Context context)
Initialize Shibboleth Authentication.
|
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 EPerson |
registerNewEPerson(Context context,
javax.servlet.http.HttpServletRequest request)
Register a new eperson object.
|
protected int |
swordCompatibility(Context context,
String username,
String password,
javax.servlet.http.HttpServletRequest request)
Provide password-based authentication to enable sword compatibility.
|
protected void |
updateEPerson(Context context,
javax.servlet.http.HttpServletRequest request,
EPerson eperson)
After we successfully authenticated a user, this method will update the user's attributes.
|
protected final int NAME_MAX_SIZE
protected final int PHONE_MAX_SIZE
protected final int METADATA_MAX_SIZE
protected EPersonService ePersonService
protected GroupService groupService
protected MetadataFieldService metadataFieldService
protected MetadataSchemaService metadataSchemaService
protected ConfigurationService configurationService
protected final String COLUMN_NAME_REGEX
public int authenticate(Context context, String username, String password, String realm, javax.servlet.http.HttpServletRequest request) throws SQLException
EPerson. If an EPerson is found it is set in
the Context that was passed.
DSpace supports authentication using NetID, or email address. A user's NetID
is a unique identifier from the IdP that identifies a particular user. The
NetID can be of almost any form such as a unique integer, string, or with
Shibboleth 2.0 you can use "targeted ids". You will need to coordinate with
your Shibboleth federation or identity provider. There are three ways to
supply identity information to DSpace:
1) NetID from Shibboleth Header (best)
The NetID-based method is superior because users may change their email
address with the identity provider. When this happens DSpace will not be
able to associate their new address with their old account.
2) Email address from Shibboleth Header (okay)
In the case where a NetID header is not available or not found DSpace
will fall back to identifying a user based-upon their email address.
3) Tomcat's Remote User (worst)
In the event that neither Shibboleth headers are found then as a last
resort DSpace will look at Tomcat's remote user field. This is the least
attractive option because Tomcat has no way to supply additional
attributes about a user. Because of this the autoregister option is not
supported if this method is used.
Identity Scheme Migration Strategies:
If you are currently using Email based authentication (either 1 or 2) and
want to upgrade to NetID based authentication then there is an easy path.
Simply enable Shibboleth to pass the NetID attribute and set the netid-header
below to the correct value. When a user attempts to log in to DSpace first
DSpace will look for an EPerson with the passed NetID, however when this
fails DSpace will fall back to email based authentication. Then DSpace will
update the user's EPerson account record to set their netid so all future
authentications for this user will be based upon netid. One thing to note
is that DSpace will prevent an account from switching NetIDs. If an account
already has a NetID set and then they try and authenticate with a
different NetID the authentication will fail.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 - Not used by Shibboleth-based authenticationrequest - 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 List<Group> getSpecialGroups(Context context, javax.servlet.http.HttpServletRequest request)
authentication.shib.role.<role-name> which is a comma separated list of
DSpace groups.getSpecialGroups in interface AuthenticationMethodcontext - A valid DSpace context.request - The request that started this operation, or null if not
applicable.null.public boolean allowSetPassword(Context context, javax.servlet.http.HttpServletRequest request, String email) throws SQLException
allowSetPassword in interface AuthenticationMethodcontext - DSpace contextrequest - HTTP request, in case anything in that is used to decideemail - e-mail address of user attempting to registerSQLException - if database errorpublic boolean isImplicit()
isImplicit in interface AuthenticationMethodpublic boolean canSelfRegister(Context context, javax.servlet.http.HttpServletRequest request, String username) throws SQLException
canSelfRegister in interface AuthenticationMethodcontext - DSpace contextrequest - HTTP request, in case anything in that is used to decideusername - e-mail address of user attempting to registerSQLException - if database errorpublic void initEPerson(Context context, javax.servlet.http.HttpServletRequest request, EPerson eperson) throws SQLException
initEPerson in interface AuthenticationMethodcontext - DSpace contextrequest - HTTP request, in case it's neededeperson - newly created EPerson record - email + information from the
registration form will have been filled out.SQLException - if database errorpublic String loginPageURL(Context context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
loginPageURL 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)
loginPageTitle in interface AuthenticationMethodcontext - DSpace context, will be modified (ePerson set) upon success.protected EPerson findEPerson(Context context, javax.servlet.http.HttpServletRequest request) throws SQLException, AuthorizeException
context - The DSpace database contextrequest - The current HTTP RequestSQLException - if database errorAuthorizeException - if authorization errorprotected EPerson registerNewEPerson(Context context, javax.servlet.http.HttpServletRequest request) throws SQLException, AuthorizeException
context - The current DSpace database contextrequest - The current HTTP RequestSQLException - if database errorAuthorizeException - if authorization errorprotected void updateEPerson(Context context, javax.servlet.http.HttpServletRequest request, EPerson eperson) throws SQLException, AuthorizeException
context - The current DSpace database contextrequest - The current HTTP Requesteperson - The eperson object to update.SQLException - if database errorAuthorizeException - if authorization errorprotected int swordCompatibility(Context context, String username, String password, javax.servlet.http.HttpServletRequest request) throws SQLException
context - The DSpace database contextusername - The usernamepassword - The passwordrequest - The HTTP RequestSQLException - if database errorprotected void initialize(Context context) throws SQLException
context - contextSQLException - if database errorprotected boolean checkIfEpersonMetadataFieldExists(Context context, String metadataName) throws SQLException
metadataName - The name of the metadata field.context - contextSQLException - if database errorprotected boolean autoCreateEpersonMetadataField(Context context, String metadataName) throws SQLException
context - contextmetadataName - The name of the new metadata field.SQLException - if database errorprotected String findAttribute(javax.servlet.http.HttpServletRequest request, String name)
request - The HTTP request to look for values in.name - The name of the attribute or headerprotected String findSingleAttribute(javax.servlet.http.HttpServletRequest request, String name)
request - The HTTP request to look for headers values on.name - The name of the headerprotected List<String> findMultipleAttributes(javax.servlet.http.HttpServletRequest request, String name)
request - The HTTP request to look for headers values on.name - The name of the attributeCopyright © 2022 LYRASIS. All rights reserved.