public class DelegatedAuthenticationDirectory extends AbstractForwardingDirectory implements RemoteDirectory
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.
Modifier and Type | Field and Description |
---|---|
static String |
ATTRIBUTE_CREATE_USER_ON_AUTH |
static String |
ATTRIBUTE_KEY_IMPORT_GROUPS |
static String |
ATTRIBUTE_LDAP_DIRECTORY_CLASS |
static String |
ATTRIBUTE_UPDATE_USER_ON_AUTH |
Constructor and Description |
---|
DelegatedAuthenticationDirectory(RemoteDirectory ldapDirectory,
InternalRemoteDirectory internalDirectory,
com.atlassian.event.api.EventPublisher eventPublisher,
DirectoryDao directoryDao) |
Modifier and Type | Method and Description |
---|---|
Group |
addGroup(GroupTemplate group)
Adds a
group to the directory store. |
User |
addOrUpdateLdapUser(String name)
Copies or updates a user in the internal directory from their counterpart in the LDAP directory.
|
User |
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 and
ATTRIBUTE_CREATE_USER_ON_AUTH is 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_AUTH is 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_AUTH is 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. |
RemoteDirectory |
getAuthoritativeDirectory() |
protected InternalRemoteDirectory |
getDelegate() |
String |
getDescriptiveName()
Returns a descriptive name for the type of directory.
|
boolean |
isRolesDisabled()
Expose whether the directory has roles disabled.
|
void |
setAttributes(Map<String,String> attributes)
When a directory store is loaded, the attributes map will be
set by the Crowd framework.
|
void |
setDirectoryId(long directoryId)
When a directory store is loaded, the
directoryId will be set by the
crowd framework. |
boolean |
supportsNestedGroups()
Allows us to only display nested-group related UI for directories that support it.
|
boolean |
supportsPasswordExpiration()
Return true if this directory supports manually expiring passwords.
|
boolean |
supportsSettingEncryptedCredential()
Delegated authentication directories don't support setting non-hashed credentials, let alone hashed credentials.
|
void |
testConnection()
Test if a connection to the directory server can be established.
|
void |
updateUserCredential(String username,
PasswordCredential credential)
|
User |
updateUserFromRemoteDirectory(User ldapUser) |
User |
userAuthenticated(String username) |
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, updateUser
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addGroupToGroup, addUser, addUser, addUserToGroup, countDirectMembersOfGroup, expireAllPasswords, findGroupByName, findGroupWithAttributesByName, findUserByExternalId, findUserByName, findUserWithAttributesByName, getDirectoryId, getMemberships, getUserAvatarByName, isGroupDirectGroupMember, isUserDirectGroupMember, removeGroup, removeGroupAttributes, removeGroupFromGroup, removeUser, removeUserAttributes, removeUserFromGroup, renameGroup, renameUser, searchGroupRelationships, searchGroups, searchUsers, storeGroupAttributes, storeUserAttributes, supportsInactiveAccounts, updateGroup, updateUser
getKeys, getValue, getValues, isEmpty
public static final String ATTRIBUTE_CREATE_USER_ON_AUTH
public static final String ATTRIBUTE_UPDATE_USER_ON_AUTH
public static final String ATTRIBUTE_LDAP_DIRECTORY_CLASS
public static final String ATTRIBUTE_KEY_IMPORT_GROUPS
public DelegatedAuthenticationDirectory(RemoteDirectory ldapDirectory, InternalRemoteDirectory internalDirectory, com.atlassian.event.api.EventPublisher eventPublisher, DirectoryDao directoryDao)
public void setDirectoryId(long directoryId)
RemoteDirectory
directoryId
will be set by the
crowd framework.setDirectoryId
in interface RemoteDirectory
setDirectoryId
in class AbstractForwardingDirectory
directoryId
- The unique directoryId
of the DirectoryImpl
stored in the database.public String getDescriptiveName()
RemoteDirectory
getDescriptiveName
in interface RemoteDirectory
getDescriptiveName
in class AbstractForwardingDirectory
public void setAttributes(Map<String,String> attributes)
RemoteDirectory
The Map is immutable and implementations are required to maintain immutability.
setAttributes
in interface RemoteDirectory
setAttributes
in class AbstractForwardingDirectory
attributes
- attributes map.public User authenticate(String name, PasswordCredential credential) throws UserNotFoundException, InactiveAccountException, InvalidAuthenticationException, ExpiredCredentialException, OperationFailedException
ATTRIBUTE_CREATE_USER_ON_AUTH
is enabled, the user's details
will be added to the internal directory.ATTRIBUTE_UPDATE_USER_ON_AUTH
is enabled, the user's details
will be updated in the internal directory.ATTRIBUTE_UPDATE_USER_ON_AUTH
is enabled and
the username was changed in remote directory, the user's name
will be updated in the internal directory.authenticate
in interface RemoteDirectory
authenticate
in class AbstractForwardingDirectory
name
- The name of the user (username).credential
- The supplied credentials (password).OperationFailedException
- when user rename is not possibleUserNotFoundException
- The user with the supplied name does not exist.InactiveAccountException
- The supplied user is inactive.InvalidAuthenticationException
- Authentication with the provided credentials failed.ExpiredCredentialException
- The user's credentials have expired. The user must change their credentials in order to successfully authenticate.RemoteDirectory.authenticate(String, PasswordCredential)
public User userAuthenticated(String username) throws OperationFailedException, UserNotFoundException, InactiveAccountException
userAuthenticated
in interface RemoteDirectory
OperationFailedException
UserNotFoundException
InactiveAccountException
public User updateUserFromRemoteDirectory(@Nonnull User ldapUser) throws OperationFailedException, UserNotFoundException
updateUserFromRemoteDirectory
in interface RemoteDirectory
updateUserFromRemoteDirectory
in class AbstractForwardingDirectory
OperationFailedException
UserNotFoundException
public User addOrUpdateLdapUser(String name) throws UserNotFoundException, OperationFailedException
name
- the username of the user to copyUserNotFoundException
- 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 directorypublic void updateUserCredential(String username, PasswordCredential credential) throws UserNotFoundException, InvalidCredentialException, OperationFailedException
RemoteDirectory
updateUserCredential
in interface RemoteDirectory
updateUserCredential
in class AbstractForwardingDirectory
username
- The name of the user (username).credential
- The new credential (password).UserNotFoundException
- The user does not exist.InvalidCredentialException
- The supplied credential is invalid.OperationFailedException
- underlying directory implementation failed to execute the operation.RemoteDirectory.supportsSettingEncryptedCredential()
public Group addGroup(GroupTemplate group) throws InvalidGroupException, OperationFailedException
RemoteDirectory
group
to the directory store.addGroup
in interface RemoteDirectory
addGroup
in class AbstractForwardingDirectory
group
- template of the group to add.InvalidGroupException
- The supplied group is invalid or it already exists in the directory.OperationFailedException
- underlying directory implementation failed to execute the operation.public void testConnection() throws OperationFailedException
RemoteDirectory
testConnection
in interface RemoteDirectory
testConnection
in class AbstractForwardingDirectory
OperationFailedException
- underlying directory implementation failed to execute the operation.public boolean supportsNestedGroups()
RemoteDirectory
supportsNestedGroups
in interface RemoteDirectory
supportsNestedGroups
in class AbstractForwardingDirectory
public boolean supportsPasswordExpiration()
RemoteDirectory
supportsPasswordExpiration
in interface RemoteDirectory
supportsPasswordExpiration
in class AbstractForwardingDirectory
public boolean supportsSettingEncryptedCredential()
supportsSettingEncryptedCredential
in interface RemoteDirectory
supportsSettingEncryptedCredential
in class AbstractForwardingDirectory
false
, always.public boolean isRolesDisabled()
RemoteDirectory
isRolesDisabled
in interface RemoteDirectory
isRolesDisabled
in class AbstractForwardingDirectory
public RemoteDirectory getAuthoritativeDirectory()
getAuthoritativeDirectory
in interface RemoteDirectory
getAuthoritativeDirectory
in class AbstractForwardingDirectory
protected InternalRemoteDirectory getDelegate()
getDelegate
in class AbstractForwardingDirectory
Copyright © 2020 Atlassian. All rights reserved.