Class CrowdDirectoryServiceImpl
java.lang.Object
com.atlassian.crowd.embedded.core.CrowdDirectoryServiceImpl
- All Implemented Interfaces:
CrowdDirectoryService
-
Constructor Summary
ConstructorsConstructorDescriptionCrowdDirectoryServiceImpl
(ApplicationFactory applicationFactory, DirectoryInstanceLoader directoryInstanceLoader, DirectoryManager directoryManager, ApplicationManager applicationManager, DirectoryValidatorFactory directoryValidatorFactory) -
Method Summary
Modifier and TypeMethodDescriptionaddDirectory
(Directory directory) Will add a newDirectory
into the local database.Will return aList<Directory>
ordered by the order specified by the application.findDirectoryById
(long directoryId) Will return aDirectory
based on the givendirectoryId
findDirectoryByName
(String name) Will return aDirectory
based on the givenname
getDirectorySynchronisationInformation
(long directoryId) Returns the synchronisation information for the directory.getPasswordComplexityMessage
(long directoryId) Get password complexity message which is displayed to end user when they try to set a password which does not match the directory's (internal only) password complexity policy.getPasswordPolicyConfiguration
(long directoryId) Retrieve password policy configuration of an internal directory.Retrieves the stored JNDI LDAP connection pool properties which will be applied when the system restarts.Retrieves the system JNDI LDAP connection pool properties (i.e.void
Initializes JNDI LDAP connection pool by setting system properties.boolean
isDirectorySynchronisable
(long directoryId) Returns true if the underlying directory implementation supports manual synchronisation of the directory's local cache.boolean
isDirectorySynchronising
(long directoryId) Returns true if the given Directory is currently synchronising.boolean
boolean
removeDirectory
(long directoryId) Will remove a directory from the Application, this will also remove all associated entities (users/groups/memberships).void
setConnectionPoolProperties
(ConnectionPoolProperties poolProperties) Stores JNDI LDAP connection pool properties.void
setDirectoryPosition
(long directoryId, int position) Will place the directory with the givendirectoryId
and the passed inposition
in the current list of directories configured for an application.void
setMembershipAggregationEnabled
(boolean enabled) Store the membership aggregation semantic to use across the directories.void
setPasswordPolicyConfiguration
(long directoryId, PasswordPolicyConfiguration passwordPolicyConfiguration, String passwordComplexityMessage) Store password policy configuration for an internal directory and a passwordComplexityMessage which is displayed when a user tries to set a non-compliant password.boolean
supportsNestedGroups
(long directoryId) Returns true if the underlying directory implementation supports nested groups.void
synchroniseDirectory
(long directoryId) Requests that this directory should update its cache by synchronising with the remote server.void
synchroniseDirectory
(long directoryId, boolean runInBackground) Requests that this directory should update its cache by synchronising with the remote server.void
testConnection
(Directory directory) Test if a connection to the directory server can be established.updateDirectory
(Directory directory) Will update theDirectory
.validateDirectoryConfiguration
(Directory directory, EnumSet<DirectoryValidationContext> validationContexts) Will validate the attributes of the given directory, depending upon the directory type
-
Constructor Details
-
CrowdDirectoryServiceImpl
public CrowdDirectoryServiceImpl(ApplicationFactory applicationFactory, DirectoryInstanceLoader directoryInstanceLoader, DirectoryManager directoryManager, ApplicationManager applicationManager, DirectoryValidatorFactory directoryValidatorFactory)
-
-
Method Details
-
initJndiLdapConnectionPool
public void initJndiLdapConnectionPool()Description copied from interface:CrowdDirectoryService
Initializes JNDI LDAP connection pool by setting system properties. This method should be invoked as early as possible, e.g. after bean initialization.Note: This method requires database access, so make sure it is called at the right time.
- Specified by:
initJndiLdapConnectionPool
in interfaceCrowdDirectoryService
-
addDirectory
Description copied from interface:CrowdDirectoryService
Will add a newDirectory
into the local database.- Specified by:
addDirectory
in interfaceCrowdDirectoryService
- Parameters:
directory
- The directory to be saved- Returns:
- the persisted
Directory
- Throws:
OperationFailedException
- if the operation failed for any reason
-
validateDirectoryConfiguration
public List<ValidationError> validateDirectoryConfiguration(Directory directory, EnumSet<DirectoryValidationContext> validationContexts) Description copied from interface:CrowdDirectoryService
Will validate the attributes of the given directory, depending upon the directory type- Specified by:
validateDirectoryConfiguration
in interfaceCrowdDirectoryService
- Parameters:
directory
- directory to be validatedvalidationContexts
- List ofDirectoryValidationContext
that are required to be validated- Returns:
- a
List
, which are errors generated during validation, or an empty list if no error was generated
-
findDirectoryByName
Description copied from interface:CrowdDirectoryService
Will return aDirectory
based on the givenname
- Specified by:
findDirectoryByName
in interfaceCrowdDirectoryService
- Parameters:
name
- the name of the directory- Returns:
- the
Directory
ornull
if no directory exists with given name
-
testConnection
Description copied from interface:CrowdDirectoryService
Test if a connection to the directory server can be established. This method will test the connection without any additional intermediaries such as pooling to ensure quick results, lack of side effects like creation of a pooled connection and consistent results regardless of directory configuration not related to making a connection.- Specified by:
testConnection
in interfaceCrowdDirectoryService
- Parameters:
directory
- Directory to test- Throws:
OperationFailedException
- underlying directory implementation failed to execute the operation.
-
findAllDirectories
Description copied from interface:CrowdDirectoryService
Will return aList<Directory>
ordered by the order specified by the application.- Specified by:
findAllDirectories
in interfaceCrowdDirectoryService
- Returns:
- a
List<Directory>
or if there are no directories, an empty list (this should never happen)
-
findDirectoryById
Description copied from interface:CrowdDirectoryService
Will return aDirectory
based on the givendirectoryId
- Specified by:
findDirectoryById
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- the id of the directory- Returns:
- the directory or
null
if the directory is not found
-
updateDirectory
Description copied from interface:CrowdDirectoryService
Will update theDirectory
. The Directory must have at the bare minimum anDirectory.getId()
,Directory.getName()
,Directory.getType()
andDirectory.getImplementationClass()
}- Specified by:
updateDirectory
in interfaceCrowdDirectoryService
- Parameters:
directory
- the directory to update- Returns:
- the updated directory
- Throws:
OperationFailedException
- if the directory does not exist or the operation failed for any other reason.
-
setDirectoryPosition
Description copied from interface:CrowdDirectoryService
Will place the directory with the givendirectoryId
and the passed inposition
in the current list of directories configured for an application.- Specified by:
setDirectoryPosition
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- the id of the directoryposition
- the position in the list of directories where you would like this one to be- Throws:
OperationFailedException
- if the directory does not exist or the operation failed for any other reason
-
removeDirectory
public boolean removeDirectory(long directoryId) throws DirectoryCurrentlySynchronisingException, OperationFailedException Description copied from interface:CrowdDirectoryService
Will remove a directory from the Application, this will also remove all associated entities (users/groups/memberships). TODO: We should discuss this- Specified by:
removeDirectory
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- the directory id of theDirectory
to remove.- Returns:
true
if the directory and associated entities were removed, orfalse
otherwise- Throws:
DirectoryCurrentlySynchronisingException
- if the Directory is currently synchronising.OperationFailedException
- if the directory does not exist or the operation failed for any other reason
-
supportsNestedGroups
Description copied from interface:CrowdDirectoryService
Returns true if the underlying directory implementation supports nested groups.- Specified by:
supportsNestedGroups
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- ID of directory.- Returns:
- true if the directory supports nested groups
- Throws:
OperationFailedException
- if the operation failed for any reason
-
isDirectorySynchronisable
Description copied from interface:CrowdDirectoryService
Returns true if the underlying directory implementation supports manual synchronisation of the directory's local cache.- Specified by:
isDirectorySynchronisable
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- ID of directory.- Returns:
- true if the directory supports synchronisation
- Throws:
OperationFailedException
- if the operation failed for any reason
-
synchroniseDirectory
Description copied from interface:CrowdDirectoryService
Requests that this directory should update its cache by synchronising with the remote server. The synchronisation will occur asynchronously, i.e. this method returns immediately and the synchronization continues in the background.If a synchronisation is currently in progress when this method is called, then this method does nothing.
- Specified by:
synchroniseDirectory
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- ID of directory.- Throws:
OperationFailedException
- if the operation failed for any reason
-
synchroniseDirectory
public void synchroniseDirectory(long directoryId, boolean runInBackground) throws OperationFailedException Description copied from interface:CrowdDirectoryService
Requests that this directory should update its cache by synchronising with the remote server.If a synchronisation is currently in progress when this method is called, then this method does nothing if runInBackGround is true, otherwise it will throw OperationFailedException.
- Specified by:
synchroniseDirectory
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- ID of directory.runInBackground
- If True the synchronise will happen asynchronously.- Throws:
OperationFailedException
- if the operation failed for any reason
-
isDirectorySynchronising
Description copied from interface:CrowdDirectoryService
Returns true if the given Directory is currently synchronising.- Specified by:
isDirectorySynchronising
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- ID of directory.- Returns:
- true if the given Directory is currently synchronising.
- Throws:
OperationFailedException
- if the operation failed for any reason
-
getDirectorySynchronisationInformation
public DirectorySynchronisationInformation getDirectorySynchronisationInformation(long directoryId) throws OperationFailedException Description copied from interface:CrowdDirectoryService
Returns the synchronisation information for the directory. This includes the last sync start time and duration, and the current sync start time (if directory is currently synchronising).- Specified by:
getDirectorySynchronisationInformation
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- ID of directory- Returns:
- a DirectorySynchronisationInformation object that contains the synchronisation information for the directory. null if the RemoteDirectory is not an instance of SynchronisableDirectory
- Throws:
OperationFailedException
- if the operation failed for any reason
-
setConnectionPoolProperties
Stores JNDI LDAP connection pool properties. They will be applied on next restart.- Specified by:
setConnectionPoolProperties
in interfaceCrowdDirectoryService
- Parameters:
poolProperties
- the new JNDI LDAP connection pool property values- See Also:
-
getStoredConnectionPoolProperties
Description copied from interface:CrowdDirectoryService
Retrieves the stored JNDI LDAP connection pool properties which will be applied when the system restarts.- Specified by:
getStoredConnectionPoolProperties
in interfaceCrowdDirectoryService
- Returns:
- LdapPoolProperties the stored JNDI LDAP connection pool settings
- See Also:
-
setPasswordPolicyConfiguration
public void setPasswordPolicyConfiguration(long directoryId, PasswordPolicyConfiguration passwordPolicyConfiguration, String passwordComplexityMessage) throws OperationNotSupportedException, DirectoryNotFoundException Description copied from interface:CrowdDirectoryService
Store password policy configuration for an internal directory and a passwordComplexityMessage which is displayed when a user tries to set a non-compliant password.- Specified by:
setPasswordPolicyConfiguration
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- id of directory (must be internal)passwordPolicyConfiguration
-PasswordPolicyConfiguration
of the specified directory- Throws:
OperationNotSupportedException
- when trying to perform operation on external directoryDirectoryNotFoundException
- when directory with directoryId does not exist
-
getPasswordPolicyConfiguration
public PasswordPolicyConfiguration getPasswordPolicyConfiguration(long directoryId) throws OperationNotSupportedException, DirectoryNotFoundException Description copied from interface:CrowdDirectoryService
Retrieve password policy configuration of an internal directory.- Specified by:
getPasswordPolicyConfiguration
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- id of directory (must be internal)- Returns:
PasswordPolicyConfiguration
of the specified directory- Throws:
OperationNotSupportedException
- when trying to perform operation on external directoryDirectoryNotFoundException
- when directory with directoryId does not exist
-
getPasswordComplexityMessage
public String getPasswordComplexityMessage(long directoryId) throws OperationNotSupportedException, DirectoryNotFoundException Description copied from interface:CrowdDirectoryService
Get password complexity message which is displayed to end user when they try to set a password which does not match the directory's (internal only) password complexity policy.- Specified by:
getPasswordComplexityMessage
in interfaceCrowdDirectoryService
- Parameters:
directoryId
- id of directory (must be internal)- Returns:
- password complexity message. null if it is not present
- Throws:
OperationNotSupportedException
- when trying to perform operation on external directoryDirectoryNotFoundException
- when directory with directoryId does not exist
-
getSystemConnectionPoolProperties
Description copied from interface:CrowdDirectoryService
Retrieves the system JNDI LDAP connection pool properties (i.e. the currently active settings).- Specified by:
getSystemConnectionPoolProperties
in interfaceCrowdDirectoryService
- Returns:
- LdapPoolProperties the system JNDI LDAP connection pool settings
- See Also:
-
isMembershipAggregationEnabled
public boolean isMembershipAggregationEnabled()- Specified by:
isMembershipAggregationEnabled
in interfaceCrowdDirectoryService
- Returns:
true
if membership aggregation is enabled across the directories.
-
setMembershipAggregationEnabled
public void setMembershipAggregationEnabled(boolean enabled) Description copied from interface:CrowdDirectoryService
Store the membership aggregation semantic to use across the directories.- Specified by:
setMembershipAggregationEnabled
in interfaceCrowdDirectoryService
- Parameters:
enabled
-true</tt> if membership aggregation should be enabled, <tt>false
to disable
-