Class DelegatedAuthenticationDirectory
- All Implemented Interfaces:
MultiValuesQueriesSupport,RemoteDirectory,Attributes
RemoteDirectory provides delegated
authentication to an underlying remote LDAP implementation.
In essence this means that a User's groups and roles are managed internally to Crowd and only authentication is delegated to the LDAP directory.
Users, group and memberships exist in an internal directory and all query and mutation operations execute on the internal directory.
For a user to successfully authenticate, they must exist in LDAP and must authenticate against LDAP. Passwords are not stored internally.
If the ATTRIBUTE_CREATE_USER_ON_AUTH attribute is
enabled, the delegated authentication directory will automatically
create the user in the internal portion of this directory, once they
successfully authenticate against LDAP. The initial user details, in
this case, will be obtained from LDAP.
If the ATTRIBUTE_UPDATE_USER_ON_AUTH attribute is
enabled, the delegated authentication directory will also update
the user's details from LDAP automatically whenever they
authenticate. The same behaviour will happen if the attribute is not
enabled and the user is deleted internally and then re-authenticates.
If the create-on-auth option is not enabled, then users must always be manually created in this directory, before they can authenticate against LDAP. In this scenario, the user details will never be retrieved from LDAP. This is OSUser's default LDAP behaviour.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDelegatedAuthenticationDirectory(RemoteDirectory ldapDirectory, InternalRemoteDirectory internalDirectory, com.atlassian.event.api.EventPublisher eventPublisher, DirectoryDao directoryDao) -
Method Summary
Modifier and TypeMethodDescriptionaddGroup(GroupTemplate group) addOrUpdateLdapUser(String name) Copies or updates a user in the internal directory from their counterpart in the LDAP directory.authenticate(String name, PasswordCredential credential) In addition to the normal authentication behaviour, following a successful authentication the following may occur: If the user does not exist in the internal directory andATTRIBUTE_CREATE_USER_ON_AUTHis enabled, the user's details will be added to the internal directory. If the user exists in the internal directory andATTRIBUTE_UPDATE_USER_ON_AUTHis enabled, the user's details will be updated in the internal directory. If the user exists in the internal directory andATTRIBUTE_UPDATE_USER_ON_AUTHis enabled and the username was changed in remote directory, the user's name will be updated in the internal directory. A user marked as inactive locally will not be authenticated, retrieved, renamed or updated from the LDAP server.protected InternalRemoteDirectorybooleanvoidsetAttributes(Map<String, String> attributes) voidsetDirectoryId(long directoryId) booleanbooleanbooleanDelegated authentication directories don't support setting non-hashed credentials, let alone hashed credentials.voidvoidupdateUserCredential(String username, PasswordCredential credential) updateUserFromRemoteDirectory(User ldapUser) userAuthenticated(String username) Methods inherited from class com.atlassian.crowd.directory.AbstractForwardingDirectory
addGroupToGroup, addUser, addUser, addUserToGroup, countDirectMembersOfGroup, expireAllPasswords, findGroupByName, findGroupWithAttributesByName, findUserByExternalId, findUserByName, findUserWithAttributesByName, getDirectoryId, getKeys, getMemberships, getUserAvatarByName, getValue, getValues, isEmpty, isGroupDirectGroupMember, isUserDirectGroupMember, removeGroup, removeGroupAttributes, removeGroupFromGroup, removeUser, removeUserAttributes, removeUserFromGroup, renameGroup, renameUser, searchGroupRelationships, searchGroups, searchUsers, storeGroupAttributes, storeUserAttributes, supportsInactiveAccounts, updateGroup, updateUserMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.crowd.embedded.api.Attributes
getKeys, getValue, getValues, isEmptyMethods inherited from interface com.atlassian.crowd.directory.MultiValuesQueriesSupport
searchGroupRelationshipsMethods inherited from interface com.atlassian.crowd.directory.RemoteDirectory
addGroupToGroup, addUser, addUser, addUserToGroup, countDirectMembersOfGroup, expireAllPasswords, findGroupByName, findGroupWithAttributesByName, findUserByExternalId, findUserByName, findUserWithAttributesByName, getDirectoryId, getLocallyFilteredGroupNames, getMemberships, getUserAvatarByName, isGroupDirectGroupMember, isUserDirectGroupMember, removeGroup, removeGroupAttributes, removeGroupFromGroup, removeUser, removeUserAttributes, removeUserFromGroup, renameGroup, renameUser, searchGroupRelationships, searchGroups, searchUsers, storeGroupAttributes, storeUserAttributes, supportsInactiveAccounts, updateGroup, updateUser
-
Field Details
-
ATTRIBUTE_CREATE_USER_ON_AUTH
- See Also:
-
ATTRIBUTE_UPDATE_USER_ON_AUTH
- See Also:
-
ATTRIBUTE_LDAP_DIRECTORY_CLASS
- See Also:
-
ATTRIBUTE_KEY_IMPORT_GROUPS
- See Also:
-
-
Constructor Details
-
DelegatedAuthenticationDirectory
public DelegatedAuthenticationDirectory(RemoteDirectory ldapDirectory, InternalRemoteDirectory internalDirectory, com.atlassian.event.api.EventPublisher eventPublisher, DirectoryDao directoryDao)
-
-
Method Details
-
setDirectoryId
public void setDirectoryId(long directoryId) - Specified by:
setDirectoryIdin interfaceRemoteDirectory- Overrides:
setDirectoryIdin classAbstractForwardingDirectory
-
getDescriptiveName
- Specified by:
getDescriptiveNamein interfaceRemoteDirectory- Overrides:
getDescriptiveNamein classAbstractForwardingDirectory
-
setAttributes
- Specified by:
setAttributesin interfaceRemoteDirectory- Overrides:
setAttributesin classAbstractForwardingDirectory
-
authenticate
public User authenticate(String name, PasswordCredential credential) throws UserNotFoundException, InactiveAccountException, InvalidAuthenticationException, ExpiredCredentialException, OperationFailedException In addition to the normal authentication behaviour, following a successful authentication the following may occur:- If the user does not exist in the internal directory and
ATTRIBUTE_CREATE_USER_ON_AUTHis enabled, the user's details will be added to the internal directory. - If the user exists in the internal directory and
ATTRIBUTE_UPDATE_USER_ON_AUTHis enabled, the user's details will be updated in the internal directory. - If the user exists in the internal directory and
ATTRIBUTE_UPDATE_USER_ON_AUTHis enabled and the username was changed in remote directory, the user's name will be updated in the internal directory.
- Specified by:
authenticatein interfaceRemoteDirectory- Overrides:
authenticatein classAbstractForwardingDirectory- Throws:
OperationFailedException- when user rename is not possibleUserNotFoundExceptionInactiveAccountExceptionInvalidAuthenticationExceptionExpiredCredentialException- See Also:
- If the user does not exist in the internal directory and
-
userAuthenticated
public User userAuthenticated(String username) throws OperationFailedException, UserNotFoundException, InactiveAccountException - Specified by:
userAuthenticatedin interfaceRemoteDirectory- Throws:
OperationFailedExceptionUserNotFoundExceptionInactiveAccountException
-
updateUserFromRemoteDirectory
public User updateUserFromRemoteDirectory(@Nonnull User ldapUser) throws OperationFailedException, UserNotFoundException - Specified by:
updateUserFromRemoteDirectoryin interfaceRemoteDirectory- Overrides:
updateUserFromRemoteDirectoryin classAbstractForwardingDirectory- Throws:
OperationFailedExceptionUserNotFoundException
-
addOrUpdateLdapUser
Copies or updates a user in the internal directory from their counterpart in the LDAP directory. Used by custom authenticators to ensure users exist when external authentication mechanisms just provide us with just a username.- Parameters:
name- the username of the user to copy- Returns:
- the newly updated internal user
- Throws:
UserNotFoundException- if no user with the given username exists in LDAPOperationFailedException- if there was a problem communicating with the LDAP server or the user could not be cloned to the internal directory
-
updateUserCredential
public void updateUserCredential(String username, PasswordCredential credential) throws UserNotFoundException, InvalidCredentialException, OperationFailedException - Specified by:
updateUserCredentialin interfaceRemoteDirectory- Overrides:
updateUserCredentialin classAbstractForwardingDirectory- Throws:
UserNotFoundExceptionInvalidCredentialExceptionOperationFailedException
-
addGroup
- Specified by:
addGroupin interfaceRemoteDirectory- Overrides:
addGroupin classAbstractForwardingDirectory- Throws:
InvalidGroupExceptionOperationFailedException
-
testConnection
- Specified by:
testConnectionin interfaceRemoteDirectory- Overrides:
testConnectionin classAbstractForwardingDirectory- Throws:
OperationFailedException
-
supportsNestedGroups
public boolean supportsNestedGroups()- Specified by:
supportsNestedGroupsin interfaceRemoteDirectory- Overrides:
supportsNestedGroupsin classAbstractForwardingDirectory
-
supportsPasswordExpiration
public boolean supportsPasswordExpiration()- Specified by:
supportsPasswordExpirationin interfaceRemoteDirectory- Overrides:
supportsPasswordExpirationin classAbstractForwardingDirectory
-
supportsSettingEncryptedCredential
public boolean supportsSettingEncryptedCredential()Delegated authentication directories don't support setting non-hashed credentials, let alone hashed credentials.- Specified by:
supportsSettingEncryptedCredentialin interfaceRemoteDirectory- Overrides:
supportsSettingEncryptedCredentialin classAbstractForwardingDirectory- Returns:
false, always.
-
isRolesDisabled
public boolean isRolesDisabled()- Specified by:
isRolesDisabledin interfaceRemoteDirectory- Overrides:
isRolesDisabledin classAbstractForwardingDirectory
-
getAuthoritativeDirectory
- Specified by:
getAuthoritativeDirectoryin interfaceRemoteDirectory- Overrides:
getAuthoritativeDirectoryin classAbstractForwardingDirectory
-
getDelegate
- Specified by:
getDelegatein classAbstractForwardingDirectory- Returns:
- the directory to delegate method calls to
-
searchGroupRelationshipsGroupedByName
- Specified by:
searchGroupRelationshipsGroupedByNamein interfaceMultiValuesQueriesSupport
-