Class UnboundidDirectoryProvider
- java.lang.Object
-
- org.sakaiproject.unboundid.UnboundidDirectoryProvider
-
- All Implemented Interfaces:
LdapConnectionManagerConfig,org.sakaiproject.user.api.AuthenticationIdUDP,org.sakaiproject.user.api.DisplayAdvisorUDP,org.sakaiproject.user.api.ExternalUserSearchUDP,org.sakaiproject.user.api.UserDirectoryProvider,org.sakaiproject.user.api.UsersShareEmailUDP
public class UnboundidDirectoryProvider extends Object implements org.sakaiproject.user.api.UserDirectoryProvider, LdapConnectionManagerConfig, org.sakaiproject.user.api.ExternalUserSearchUDP, org.sakaiproject.user.api.UsersShareEmailUDP, org.sakaiproject.user.api.DisplayAdvisorUDP, org.sakaiproject.user.api.AuthenticationIdUDP
An implementation of a Sakai UserDirectoryProvider that authenticates/retrieves users from a LDAP directory. Forked from JLDAP in early 2016.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_ALLOW_AUTHENTICATIONstatic booleanDEFAULT_ALLOW_AUTHENTICATION_ADMINstatic booleanDEFAULT_ALLOW_AUTHENTICATION_EXTERNALstatic booleanDEFAULT_ALLOW_GET_EXTERNALstatic booleanDEFAULT_ALLOW_SEARCH_EXTERNALstatic booleanDEFAULT_AUTHENTICATE_WITH_PROVIDER_FIRSTstatic intDEFAULT_BATCH_SIZEDefault LDAP maximum number of objects to query forstatic longDEFAULT_HEALTH_CHECK_INTERVAL_MILLISstatic booleanDEFAULT_IS_FOLLOW_REFERRALSDefault referral following behaviorstatic booleanDEFAULT_IS_SEARCH_ALIASESstatic booleanDEFAULT_IS_SECURE_CONNECTIONDefault secure/unsecure LDAP connection creation behaviorstatic int[]DEFAULT_LDAP_PORTDefault LDAP connection portstatic intDEFAULT_MAX_RESULT_SIZEDefault LDAP maximum number of objects in a resultstatic intDEFAULT_OPERATION_TIMEOUT_MILLISDefault LDAP access timeout in millisecondsstatic intDEFAULT_POOL_MAX_CONNSDefault LDAP maximum number of connections in the poolstatic booleanDEFAULT_RETRY_FAILED_OPERATIONS_DUE_TO_INVALID_CONNECTIONSstatic com.unboundid.ldap.sdk.SearchScopeDEFAULT_SEARCH_SCOPEDefault search scope for filters executed by#searchDirectory(String, LDAPConnection, LdapEntryMapper, String[], String, int)protected LdapEntryMapperdefaultLdapEntryMapperDefaults to an anon-inner class which handlesLDAPEntry(ies) by passing them tomapLdapEntryOntoUserData(LDAPEntry), the result of which is returned.static StringDISPLAY_ID_PROPERTYProperty of the user object to store the display ID understatic StringDISPLAY_NAME_PROPERTYProperty of the user object to store the display Name under
-
Constructor Summary
Constructors Constructor Description UnboundidDirectoryProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanauthenticateUser(String userLogin, org.sakaiproject.user.api.UserEdit edit, String password)Authenticates the specified user login by recursively searching for and binding to a DN below the configured base DN.booleanauthenticateWithProviderFirst(String id)By default returns the global boolean setting configured viasetAuthenticateWithProviderFirst(boolean).voidclearCache()Resets the internalLdapUserDatacacheprotected booleancreateConnectionPool()Create the LDAP connection poolvoiddestroy()Typically called by Spring to signal bean destruction.booleanfindUserByEmail(org.sakaiproject.user.api.UserEdit edit, String email)Locates a user directory entry using an email address as a key.CollectionfindUsersByEmail(String email, org.sakaiproject.user.api.UserFactory factory)Find all user objects which have this email address.Map<String,String>getAttributeMappings()StringgetBasePath()intgetBatchSize()StringgetDisplayId(org.sakaiproject.user.api.User user)StringgetDisplayName(org.sakaiproject.user.api.User user)EidValidatorgetEidValidator()Access the service used to verify EIDs prior to executing searches on those values.longgetHealthCheckIntervalMillis()Map<String,String>getHealthCheckMappings()LdapAttributeMappergetLdapAttributeMapper()Access the currently assignedLdapAttributeMapperdelegate.String[]getLdapHost()StringgetLdapPassword()int[]getLdapPort()StringgetLdapUser()intgetMaxObjectsToQueryFor()intgetMaxResultSize()intgetOperationTimeout()intgetPoolMaxConns()booleangetRetryFailedOperationsDueToInvalidConnections()com.unboundid.ldap.sdk.SearchScopegetSearchScope()Access the configured search scope for all filters executed by#searchDirectory(String, LDAPConnection, LdapEntryMapper, String[], String, int).booleangetUser(org.sakaiproject.user.api.UserEdit edit)Effectively the same asgetUserByEid(edit, edit.getEid()).booleangetUserbyAid(String aid, org.sakaiproject.user.api.UserEdit user)LdapUserDatagetUserByAid(String aid)protected LdapUserDatagetUserByEid(String eid)Finds a user record using aneidas an index.protected booleangetUserByEid(org.sakaiproject.user.api.UserEdit userToUpdate, String eid)Finds a user record using aneidas an index.voidgetUsers(Collection<org.sakaiproject.user.api.UserEdit> users)Similar to iterating overuserspassing each element togetUser(UserEdit), removing theUserEditif that method returnsfalse.voidinit()Typically invoked by Spring to complete bean initialization.protected voidinitLdapAttributeMapper()Lazily "injects" aLdapAttributeMapperif one has not been assigned already.booleanisAllowAuthentication()Access the current global authentication "on/off" switch.booleanisAuthenticateWithProviderFirst()Access the configured global return value forauthenticateWithProviderFirst(String).booleanisAutoBind()Access the LDAP auto-bind configurationbooleanisFollowReferrals()Access LDAP referral following configurationprotected booleanisSearchableEid(String eid)Consults the cachedEidValidatorto determine if the givenUserEID is searchable.booleanisSearchAliases()booleanisSecureConnection()Iftrue, connect to LDAP over a secure protocol.protected StringlookupUserBindDn(String eid)Search the directory for a DN corresponding to a user's EID.protected LdapUserDatamapLdapEntryOntoUserData(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry)Maps attributes from the specifiedLDAPEntryonto a newly instantiatedLdapUserData.protected voidmapUserDataOntoUserEdit(LdapUserData userData, org.sakaiproject.user.api.UserEdit userEdit)Maps attribites from the specifiedLdapUserDataonto aUserEdit.protected LdapAttributeMappernewDefaultLdapAttributeMapper()Factory method for defaultLdapAttributeMapperinstances.protected LdapUserDatanewLdapUserData()Instantiates aLdapUserData.protected StringscrubSearchBaseDn(String searchBaseDn)Responsible for pre-processing base DNs passed to#searchDirectory(String, LDAPConnection, String[], String, int).protected String[]scrubSearchResultPhysicalAttributeNames(String[] searchResultPhysicalAttributeNames)Responsible for pre-processing search result attribute names passed to#searchDirectory(String, LDAPConnection, String[], String, int).protected List<LdapUserData>searchDirectory(String filter, LdapEntryMapper passedMapper, String[] searchResultPhysicalAttributeNames, String unescapedSearchBaseDn, int maxResults)Execute a directory search using the specified filter and connection.protected ObjectsearchDirectoryForSingleEntry(String filter, LdapEntryMapper mapper, String[] searchResultPhysicalAttributeNames, String searchBaseDn)Searches the directory for at most one entry matching the specified filter.List<org.sakaiproject.user.api.UserEdit>searchExternalUsers(String criteria, int first, int last, org.sakaiproject.user.api.UserFactory factory)Search for externally provided users that match this criteria in eid, email, first or last name.voidsetAllowAuthentication(boolean allowAuthentication)Access the current global authentication "on/off" switch.voidsetAttributeMappings(Map<String,String> attributeMappings)voidsetAuthenticateAllowed(boolean authenticateAllowed)An alias ofsetAllowAuthentication(boolean)for backward compatibility with existing customized deployments of this provider which had already implemented this feature.voidsetAuthenticateWithProviderFirst(boolean authenticateWithProviderFirst)Configure the global return value ofauthenticateWithProviderFirst(String).voidsetAutoBind(boolean autoBind)Configure the LDAP auto-bind configuration param autoBind iftrueconnection allocation (LdapConnectionManager#getConnection()) will include a bind attemptvoidsetBasePath(String basePath)voidsetBatchSize(int batchSize)voidsetEidValidator(EidValidator eidValidator)Assign the service used to verify EIDs prior to executing searches on those values.voidsetEnableAid(boolean enableAid)voidsetFollowReferrals(boolean followReferrals)Configures LDAP referral followingvoidsetHealthCheckIntervalMillis(long healthCheckIntervalMillis)voidsetHealthCheckMappings(Map<String,String> healthCheckMappings)voidsetLdapAttributeMapper(LdapAttributeMapper ldapAttributeMapper)Assign theLdapAttributeMapperdelegate.voidsetLdapHost(String[] ldapHost)voidsetLdapPassword(String ldapPassword)voidsetLdapPort(int[] ldapPort)voidsetLdapUser(String ldapUser)voidsetMaxObjectsToQueryFor(int maxObjectsToQueryFor)voidsetMaxResultSize(int maxResultSize)voidsetOperationTimeout(int operationTimeout)voidsetPoolMaxConns(int poolMaxConns)voidsetRetryFailedOperationsDueToInvalidConnections(boolean retryFailedOperationsDueToInvalidConnections)voidsetSearchAliases(boolean searchAliases)voidsetSearchScope(int searchScope)Set the configured search scope for all filters executed by#searchDirectory(String, LDAPConnection, LdapEntryMapper, String[], String, int).voidsetSecureConnection(boolean secureConnection)Set totrueif LDAP connections should occur over a secure protocol.booleanuserExists(String eid)Effectively the same asgetUserByEid(null,eid).
-
-
-
Field Detail
-
DEFAULT_LDAP_PORT
public static final int[] DEFAULT_LDAP_PORT
Default LDAP connection port
-
DEFAULT_IS_SECURE_CONNECTION
public static final boolean DEFAULT_IS_SECURE_CONNECTION
Default secure/unsecure LDAP connection creation behavior- See Also:
- Constant Field Values
-
DEFAULT_OPERATION_TIMEOUT_MILLIS
public static final int DEFAULT_OPERATION_TIMEOUT_MILLIS
Default LDAP access timeout in milliseconds- See Also:
- Constant Field Values
-
DEFAULT_IS_FOLLOW_REFERRALS
public static final boolean DEFAULT_IS_FOLLOW_REFERRALS
Default referral following behavior- See Also:
- Constant Field Values
-
DEFAULT_IS_SEARCH_ALIASES
public static final boolean DEFAULT_IS_SEARCH_ALIASES
- See Also:
- Constant Field Values
-
DEFAULT_SEARCH_SCOPE
public static final com.unboundid.ldap.sdk.SearchScope DEFAULT_SEARCH_SCOPE
Default search scope for filters executed by#searchDirectory(String, LDAPConnection, LdapEntryMapper, String[], String, int)
-
DEFAULT_POOL_MAX_CONNS
public static final int DEFAULT_POOL_MAX_CONNS
Default LDAP maximum number of connections in the pool- See Also:
- Constant Field Values
-
DEFAULT_RETRY_FAILED_OPERATIONS_DUE_TO_INVALID_CONNECTIONS
public static final boolean DEFAULT_RETRY_FAILED_OPERATIONS_DUE_TO_INVALID_CONNECTIONS
- See Also:
- Constant Field Values
-
DEFAULT_HEALTH_CHECK_INTERVAL_MILLIS
public static final long DEFAULT_HEALTH_CHECK_INTERVAL_MILLIS
- See Also:
- Constant Field Values
-
DEFAULT_MAX_RESULT_SIZE
public static final int DEFAULT_MAX_RESULT_SIZE
Default LDAP maximum number of objects in a result- See Also:
- Constant Field Values
-
DEFAULT_BATCH_SIZE
public static final int DEFAULT_BATCH_SIZE
Default LDAP maximum number of objects to query for- See Also:
- Constant Field Values
-
DISPLAY_ID_PROPERTY
public static final String DISPLAY_ID_PROPERTY
Property of the user object to store the display ID under
-
DISPLAY_NAME_PROPERTY
public static final String DISPLAY_NAME_PROPERTY
Property of the user object to store the display Name under
-
DEFAULT_ALLOW_AUTHENTICATION
public static final boolean DEFAULT_ALLOW_AUTHENTICATION
- See Also:
- Constant Field Values
-
DEFAULT_ALLOW_AUTHENTICATION_EXTERNAL
public static final boolean DEFAULT_ALLOW_AUTHENTICATION_EXTERNAL
- See Also:
- Constant Field Values
-
DEFAULT_ALLOW_AUTHENTICATION_ADMIN
public static final boolean DEFAULT_ALLOW_AUTHENTICATION_ADMIN
- See Also:
- Constant Field Values
-
DEFAULT_ALLOW_SEARCH_EXTERNAL
public static final boolean DEFAULT_ALLOW_SEARCH_EXTERNAL
- See Also:
- Constant Field Values
-
DEFAULT_ALLOW_GET_EXTERNAL
public static final boolean DEFAULT_ALLOW_GET_EXTERNAL
- See Also:
- Constant Field Values
-
DEFAULT_AUTHENTICATE_WITH_PROVIDER_FIRST
public static final boolean DEFAULT_AUTHENTICATE_WITH_PROVIDER_FIRST
- See Also:
- Constant Field Values
-
defaultLdapEntryMapper
protected LdapEntryMapper defaultLdapEntryMapper
Defaults to an anon-inner class which handlesLDAPEntry(ies) by passing them tomapLdapEntryOntoUserData(LDAPEntry), the result of which is returned.
-
-
Method Detail
-
init
public void init()
Typically invoked by Spring to complete bean initialization. Ensures initialization of delegateLdapConnectionManagerandLdapAttributeMapper- See Also:
#initLdapConnectionManager(),initLdapAttributeMapper()
-
createConnectionPool
protected boolean createConnectionPool()
Create the LDAP connection pool
-
initLdapAttributeMapper
protected void initLdapAttributeMapper()
Lazily "injects" aLdapAttributeMapperif one has not been assigned already.Implementation note: this approach to initing the attrib mgr preserves forward compatibility of existing config, but config should probably be refactored to inject the appropriate config directly into the attrib mgr.
-
newDefaultLdapAttributeMapper
protected LdapAttributeMapper newDefaultLdapAttributeMapper()
Factory method for defaultLdapAttributeMapperinstances. Ensures forward compatibility of existing config which does not specify a delegateLdapAttributeMapper.- Returns:
- a new
LdapAttributeMapper
-
destroy
public void destroy()
Typically called by Spring to signal bean destruction.
-
clearCache
public void clearCache()
Resets the internalLdapUserDatacache
-
authenticateUser
public boolean authenticateUser(String userLogin, org.sakaiproject.user.api.UserEdit edit, String password)
Authenticates the specified user login by recursively searching for and binding to a DN below the configured base DN. Search results are subsequently added to the cache.Caching search results departs from behavior in <= 2.3.0 versions, which removed cache entries following authentication. If the intention is to ensure fresh user data at each login, the most natural approach is probably to clear the cache before executing the authentication process. At this writing, though, the default
UserDirectoryServiceimpl will invokegetUser(UserEdit)prior to {authenticateUser(String, UserEdit, String)} if the Sakai's local db does not recognize the specified EID. Therefore, clearing the cache at in {authenticateUser(String, UserEdit, String)} at best leads to confusing mid-session attribute changes. In the future we may want to consider strategizing this behavior, or adding an eid parameter to#destroyAuthentication()so cache records can be invalidated on logout without ugly dependencies on theSessionManager- Specified by:
authenticateUserin interfaceorg.sakaiproject.user.api.UserDirectoryProvider- See Also:
#lookupUserBindDn(String, LDAPConnection)
-
findUserByEmail
public boolean findUserByEmail(org.sakaiproject.user.api.UserEdit edit, String email)Locates a user directory entry using an email address as a key. Updates the specifiedUserEditwith directory attributes if the search is successful. TheUserEditparam is technically optional and will be ignored ifnull.All
Exceptions are logged and result in afalsereturn, as do searches which yield no results. (A concession to backward compat.)- Specified by:
findUserByEmailin interfaceorg.sakaiproject.user.api.UserDirectoryProvider- Parameters:
edit- theUserEditto updateemail- the search key- Returns:
- boolean
trueif the search completed without error and found a directory entry
-
getUser
public boolean getUser(org.sakaiproject.user.api.UserEdit edit)
Effectively the same asgetUserByEid(edit, edit.getEid()).- Specified by:
getUserin interfaceorg.sakaiproject.user.api.UserDirectoryProvider- See Also:
getUserByEid(UserEdit, String)
-
getUserbyAid
public boolean getUserbyAid(String aid, org.sakaiproject.user.api.UserEdit user)
- Specified by:
getUserbyAidin interfaceorg.sakaiproject.user.api.AuthenticationIdUDP
-
getUserByAid
public LdapUserData getUserByAid(String aid)
-
getUsers
public void getUsers(Collection<org.sakaiproject.user.api.UserEdit> users)
Similar to iterating overuserspassing each element togetUser(UserEdit), removing theUserEditif that method returnsfalse.Adds search retry capability if any one lookup fails with a directory error. Empties
usersand returns if a retry exits exceptionally- Specified by:
getUsersin interfaceorg.sakaiproject.user.api.UserDirectoryProvider
-
authenticateWithProviderFirst
public boolean authenticateWithProviderFirst(String id)
By default returns the global boolean setting configured viasetAuthenticateWithProviderFirst(boolean).- Specified by:
authenticateWithProviderFirstin interfaceorg.sakaiproject.user.api.UserDirectoryProvider
-
userExists
public boolean userExists(String eid)
Effectively the same asgetUserByEid(null,eid).- See Also:
getUserByEid(UserEdit, String)
-
getUserByEid
protected boolean getUserByEid(org.sakaiproject.user.api.UserEdit userToUpdate, String eid) throws com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPExceptionFinds a user record using aneidas an index. Updates the givenUserEditif a directory entry is found.- Parameters:
userToUpdate- theUserEditto update, may benulleid- the user IDconn- aLDAPConnectionto reuse. may benull- Returns:
trueif the directory entry was found, false if the search returns without error but without results- Throws:
com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException- if the search returns with a directory access error- See Also:
#getUserByEid(String, LDAPConnection)
-
getUserByEid
protected LdapUserData getUserByEid(String eid) throws com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException
Finds a user record using aneidas an index.- Parameters:
eid- the Sakai EID to search onconn- an optionalLDAPConnection- Returns:
- object representing the found LDAP entry, or null if no results
- Throws:
com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException- if the search returns with a directory access error
-
isSearchableEid
protected boolean isSearchableEid(String eid)
Consults the cachedEidValidatorto determine if the givenUserEID is searchable. Allows any EID if noEidValidatorhas been configured.- Parameters:
eid- a user EID, possiblynullor otherwise "empty"- Returns:
trueif noEidValidatorhas been set, or the result ofEidValidator.isSearchableEid(String)
-
lookupUserBindDn
protected String lookupUserBindDn(String eid) throws com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException
Search the directory for a DN corresponding to a user's EID. Typically, this is the same as DN of the object from which the user's attributes are retrieved, but that need not necessarily be the case.- Parameters:
eid- the user's Sakai EIDconn- an optionalLDAPConnection- Returns:
- the user's bindable DN or null if no matching directory entry
- Throws:
com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException- if the directory query exits with an error- See Also:
#getUserByEid(String, LDAPConnection),LdapAttributeMapper.getUserBindDn(LdapUserData)
-
searchDirectoryForSingleEntry
protected Object searchDirectoryForSingleEntry(String filter, LdapEntryMapper mapper, String[] searchResultPhysicalAttributeNames, String searchBaseDn) throws com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException
Searches the directory for at most one entry matching the specified filter.- Parameters:
filter- a search filterconn- an optionalLDAPConnectionsearchResultPhysicalAttributeNames-searchBaseDn-- Returns:
- a matching
LDAPEntryornullif no match - Throws:
com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException- if the search exits with an error
-
searchDirectory
protected List<LdapUserData> searchDirectory(String filter, LdapEntryMapper passedMapper, String[] searchResultPhysicalAttributeNames, String unescapedSearchBaseDn, int maxResults) throws com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException
Execute a directory search using the specified filter and connection. Maps each resultingLDAPEntryto aLdapUserData, returning aListof the latter.- Parameters:
filter- the search filterconn- an optionalLDAPConnectionmapper- result interpreter. Defaults todefaultLdapEntryMapperifnullsearchResultPhysicalAttributeNames- attributes to retrieve. May benull, in which case defaults toLdapAttributeMapper.getSearchResultAttributes().searchBaseDn- base DN from which to begin search. May benull, in which case defaults to assignedbasePathmaxResults- maximum number of retrieved LDAP objects. Ignored if <= 0- Returns:
- An empty
Listif no results. Will not returnnull - Throws:
com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPException- if thrown by the searchRuntimeExction- wrapping any non-LDAPExceptionException
-
scrubSearchBaseDn
protected String scrubSearchBaseDn(String searchBaseDn)
Responsible for pre-processing base DNs passed to#searchDirectory(String, LDAPConnection, String[], String, int). As implemented, simply checks for anullreference, in which case it returns the currently cached "basePath". Otherwise returns the receivedStringas is.- Parameters:
searchBaseDn- a proposed base DN. May benull- Returns:
- a default base DN or the received DN, if non
null. Return value may benullif no default base DN has been configured - See Also:
setBasePath(String)
-
scrubSearchResultPhysicalAttributeNames
protected String[] scrubSearchResultPhysicalAttributeNames(String[] searchResultPhysicalAttributeNames)
Responsible for pre-processing search result attribute names passed to#searchDirectory(String, LDAPConnection, String[], String, int). If the givenString[]>isnull, will useLdapAttributeMapper.getSearchResultAttributes(). If that method returnsnullwill return an emptyString[]>. Otherwise returns the receivedString[]>as-is.- Parameters:
searchResultPhysicalAttributeNames-- Returns:
-
mapLdapEntryOntoUserData
protected LdapUserData mapLdapEntryOntoUserData(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry)
Maps attributes from the specifiedLDAPEntryonto a newly instantiatedLdapUserData. Implemented to delegate to the currently assignedLdapAttributeMapper.- Parameters:
ldapEntry- a non-null directory entry to map- Returns:
- a new
LdapUserData, populated with directory attributes - See Also:
LdapAttributeMapper.mapLdapEntryOntoUserData(LDAPEntry, LdapUserData)
-
newLdapUserData
protected LdapUserData newLdapUserData()
Instantiates aLdapUserData. This method exists primarily for overriding in test cases.- Returns:
- a new
LdapUserData
-
mapUserDataOntoUserEdit
protected void mapUserDataOntoUserEdit(LdapUserData userData, org.sakaiproject.user.api.UserEdit userEdit)
Maps attribites from the specifiedLdapUserDataonto aUserEdit. Implemented to delegate to the currently assignedLdapAttributeMapper.- Parameters:
userData- a non-null user cache entryuserEdit- a non-null user domain object- See Also:
LdapAttributeMapper.mapUserDataOntoUserEdit(LdapUserData, UserEdit)
-
getLdapHost
public String[] getLdapHost()
- Specified by:
getLdapHostin interfaceLdapConnectionManagerConfig- Returns:
- the LDAP host address or name.
-
setLdapHost
public void setLdapHost(String[] ldapHost)
- Specified by:
setLdapHostin interfaceLdapConnectionManagerConfig- Parameters:
ldapHost- The LDAP host address or name.
-
getLdapPort
public int[] getLdapPort()
- Specified by:
getLdapPortin interfaceLdapConnectionManagerConfig- Returns:
- the LDAP connection port.
-
setLdapPort
public void setLdapPort(int[] ldapPort)
- Specified by:
setLdapPortin interfaceLdapConnectionManagerConfig- Parameters:
ldapPort- The LDAP connection port to set.
-
getLdapUser
public String getLdapUser()
- Specified by:
getLdapUserin interfaceLdapConnectionManagerConfig- Returns:
- the LDAP user to bind as, typically a manager acct.
-
setLdapUser
public void setLdapUser(String ldapUser)
- Specified by:
setLdapUserin interfaceLdapConnectionManagerConfig- Parameters:
ldapUser- The user to bind to LDAP as, typically a manager acct, leave blank for anonymous.
-
getLdapPassword
public String getLdapPassword()
- Specified by:
getLdapPasswordin interfaceLdapConnectionManagerConfig- Returns:
- Returns the LDAP password corresponding to the current default bind-as user.
- See Also:
LdapConnectionManagerConfig.getLdapUser()
-
setLdapPassword
public void setLdapPassword(String ldapPassword)
- Specified by:
setLdapPasswordin interfaceLdapConnectionManagerConfig- Parameters:
ldapPassword- the LDAP password corresponding to the current default bind-as user.
-
isSecureConnection
public boolean isSecureConnection()
Iftrue, connect to LDAP over a secure protocol.- Specified by:
isSecureConnectionin interfaceLdapConnectionManagerConfig
-
setSecureConnection
public void setSecureConnection(boolean secureConnection)
Set totrueif LDAP connections should occur over a secure protocol.- Specified by:
setSecureConnectionin interfaceLdapConnectionManagerConfig
-
getBasePath
public String getBasePath()
-
setBasePath
public void setBasePath(String basePath)
-
getOperationTimeout
public int getOperationTimeout()
- Specified by:
getOperationTimeoutin interfaceLdapConnectionManagerConfig- Returns:
- the directory operation timeout
-
setOperationTimeout
public void setOperationTimeout(int operationTimeout)
- Specified by:
setOperationTimeoutin interfaceLdapConnectionManagerConfig- Parameters:
operationTimeout- the directory operation timeout to set.
-
getAttributeMappings
public Map<String,String> getAttributeMappings()
- Returns:
- LDAP attribute map, keys are logical names, values are physical names. may be null
-
setAttributeMappings
public void setAttributeMappings(Map<String,String> attributeMappings)
- Parameters:
attributeMappings- LDAP attribute map, keys are logical names, values are physical names. may be null
-
isFollowReferrals
public boolean isFollowReferrals()
Access LDAP referral following configuration- Specified by:
isFollowReferralsin interfaceLdapConnectionManagerConfig- Returns:
- if
true, directory accesses will follow referrals
-
setFollowReferrals
public void setFollowReferrals(boolean followReferrals)
Configures LDAP referral following- Specified by:
setFollowReferralsin interfaceLdapConnectionManagerConfig- Parameters:
followReferrals- iftrue, directory accesses will follow referrals
-
isAutoBind
public boolean isAutoBind()
Access the LDAP auto-bind configuration- Specified by:
isAutoBindin interfaceLdapConnectionManagerConfig- Returns:
- if
trueconnection allocation (LdapConnectionManager#getConnection()) will include a bind attempt
-
setAutoBind
public void setAutoBind(boolean autoBind)
Configure the LDAP auto-bind configuration param autoBind iftrueconnection allocation (LdapConnectionManager#getConnection()) will include a bind attempt- Specified by:
setAutoBindin interfaceLdapConnectionManagerConfig
-
getPoolMaxConns
public int getPoolMaxConns()
- Specified by:
getPoolMaxConnsin interfaceLdapConnectionManagerConfig- Returns:
- The maximum number of physical connections in the pool
-
setPoolMaxConns
public void setPoolMaxConns(int poolMaxConns)
- Specified by:
setPoolMaxConnsin interfaceLdapConnectionManagerConfig- Parameters:
poolMaxConns- The maximum number of physical connections in the pool
-
getRetryFailedOperationsDueToInvalidConnections
public boolean getRetryFailedOperationsDueToInvalidConnections()
-
setRetryFailedOperationsDueToInvalidConnections
public void setRetryFailedOperationsDueToInvalidConnections(boolean retryFailedOperationsDueToInvalidConnections)
-
getHealthCheckIntervalMillis
public long getHealthCheckIntervalMillis()
-
setHealthCheckIntervalMillis
public void setHealthCheckIntervalMillis(long healthCheckIntervalMillis)
-
getMaxObjectsToQueryFor
public int getMaxObjectsToQueryFor()
-
setMaxObjectsToQueryFor
public void setMaxObjectsToQueryFor(int maxObjectsToQueryFor)
-
getBatchSize
public int getBatchSize()
- Specified by:
getBatchSizein interfaceLdapConnectionManagerConfig- Returns:
- The maximum number of objects to lookup in one query.
-
setBatchSize
public void setBatchSize(int batchSize)
- Specified by:
setBatchSizein interfaceLdapConnectionManagerConfig- Parameters:
batchSize- The maximum number objects to lookup in one query.
-
setEnableAid
public void setEnableAid(boolean enableAid)
- Specified by:
setEnableAidin interfaceLdapConnectionManagerConfig- Parameters:
enableAid- Iftruethen perform searches for users by Authentication ID.
-
getMaxResultSize
public int getMaxResultSize()
- Specified by:
getMaxResultSizein interfaceLdapConnectionManagerConfig- Returns:
- The maximum number of results to ever get back from LDAP.
-
setMaxResultSize
public void setMaxResultSize(int maxResultSize)
- Specified by:
setMaxResultSizein interfaceLdapConnectionManagerConfig- Parameters:
maxResultSize- The maximum number of results to ever get back from LDAP.
-
getLdapAttributeMapper
public LdapAttributeMapper getLdapAttributeMapper()
Access the currently assignedLdapAttributeMapperdelegate. This delegate handles LDAP attribute mappings and encapsulates filter writing.- Returns:
- the current
LdapAttributeMapper. May be null ifinit()has not been called yet.
-
setLdapAttributeMapper
public void setLdapAttributeMapper(LdapAttributeMapper ldapAttributeMapper)
Assign theLdapAttributeMapperdelegate. This delegate handles LDAP attribute mappings and encapsulates filter writing.- Parameters:
ldapAttributeMapper- aLdapAttributeMapper. may be null
-
getEidValidator
public EidValidator getEidValidator()
Access the service used to verify EIDs prior to executing searches on those values.- Returns:
- an
EidValidatorornullif no such dependency has been configured - See Also:
isSearchableEid(String)
-
setEidValidator
public void setEidValidator(EidValidator eidValidator)
Assign the service used to verify EIDs prior to executing searches on those values. This field defaults tonullindicating that all EIDs are searchable.- Parameters:
eidValidator- anEidValidatorornullto indicate that all EIDs are searchable.
-
isAllowAuthentication
public boolean isAllowAuthentication()
Access the current global authentication "on/off" switch.- Returns:
- boolean
- See Also:
setAllowAuthentication(boolean)
-
setAllowAuthentication
public void setAllowAuthentication(boolean allowAuthentication)
Access the current global authentication "on/off" switch.falsecompletely disablesauthenticateUser(String, UserEdit, String)(regardless of the value returned fromauthenticateWithProviderFirst(String)).trueenables theauthenticateUser(String, UserEdit, String)algorithm. To simply authenticate all users without checking credentials, e.g. in a test environment, consider overridingauthenticateUser(String, UserEdit, String)altogether.Defaults to
DEFAULT_ALLOW_AUTHENTICATION- Parameters:
allowAuthentication-
-
setAuthenticateAllowed
public void setAuthenticateAllowed(boolean authenticateAllowed)
An alias ofsetAllowAuthentication(boolean)for backward compatibility with existing customized deployments of this provider which had already implemented this feature.- Parameters:
authenticateAllowed-
-
isAuthenticateWithProviderFirst
public boolean isAuthenticateWithProviderFirst()
Access the configured global return value forauthenticateWithProviderFirst(String). SeesetAuthenticateWithProviderFirst(boolean)for additional semantics.- Returns:
- boolean
-
setAuthenticateWithProviderFirst
public void setAuthenticateWithProviderFirst(boolean authenticateWithProviderFirst)
Configure the global return value ofauthenticateWithProviderFirst(String). Be aware that future development may expose a first-class extension point for custom implementations ofauthenticateWithProviderFirst(String), in which case the value configured here will be treated as a default rather than an override.- Parameters:
authenticateWithProviderFirst-
-
getDisplayId
public String getDisplayId(org.sakaiproject.user.api.User user)
- Specified by:
getDisplayIdin interfaceorg.sakaiproject.user.api.DisplayAdvisorUDP
-
getDisplayName
public String getDisplayName(org.sakaiproject.user.api.User user)
- Specified by:
getDisplayNamein interfaceorg.sakaiproject.user.api.DisplayAdvisorUDP
-
getSearchScope
public com.unboundid.ldap.sdk.SearchScope getSearchScope()
Access the configured search scope for all filters executed by#searchDirectory(String, LDAPConnection, LdapEntryMapper, String[], String, int). int value corresponds to a constant inLDAPConnection: SCOPE_BASE = 0, SCOPE_ONE = 1, SCOPE_SUB = 2. Defaults toDEFAULT_SEARCH_SCOPE.
-
setSearchScope
public void setSearchScope(int searchScope) throws IllegalArgumentExceptionSet the configured search scope for all filters executed by#searchDirectory(String, LDAPConnection, LdapEntryMapper, String[], String, int). Validated- Parameters:
searchScope-- Throws:
IllegalArgumentException- if given scope value is invalid
-
searchExternalUsers
public List<org.sakaiproject.user.api.UserEdit> searchExternalUsers(String criteria, int first, int last, org.sakaiproject.user.api.UserFactory factory)
Search for externally provided users that match this criteria in eid, email, first or last name.Returns a List of UserEdit objects. This list will be empty if no results are returned or null if your external provider does not implement this interface.
The list will also be null if the LDAP server returns an error, for example an '(11) Administrative Limit Exceeded' or '(4) Sizelimit Exceeded', due to a search term being too broad and returning too many results.See LdapAttributeMapper.getFindUserByCrossAttributeSearchFilter for the filter used.
- Specified by:
searchExternalUsersin interfaceorg.sakaiproject.user.api.ExternalUserSearchUDP- Parameters:
criteria- The search criteria.first- The first record position to return. LDAP does not support paging so this value is unused.last- The last record position to return. LDAP does not support paging so this value is unused.factory- Use this factory's newUser() method to create the UserEdit objects you populate and return in the List.- Returns:
- A list (UserEdit) of all the users matching the criteria.
-
findUsersByEmail
public Collection findUsersByEmail(String email, org.sakaiproject.user.api.UserFactory factory)
Find all user objects which have this email address.- Specified by:
findUsersByEmailin interfaceorg.sakaiproject.user.api.UsersShareEmailUDP- Parameters:
email- The email address string.factory- To create all the UserEdit objects you populate and return in the return collection.- Returns:
- Collection (UserEdit) of user objects that have this email address, or an empty Collection if there are none.
-
isSearchAliases
public boolean isSearchAliases()
-
setSearchAliases
public void setSearchAliases(boolean searchAliases)
-
-