no.feide.moria.directory
Class DirectoryManager

java.lang.Object
  extended by no.feide.moria.directory.DirectoryManager

public class DirectoryManager
extends java.lang.Object

The Directory Manager (sometimes referred to as DM) component in Moria 2. Responsible for all backend operations, such as user authentication and attribute retrieval from the backend sources.


Field Summary
private  DirectoryManagerBackendFactory backendFactory
          Internal representation of the backend factory.
private  DirectoryManagerConfiguration configuration
          The currently used (valid) Directory Manager configuration.
private  DirectoryManagerIndex index
          Internal representation of the index.
private  java.util.Timer indexTimer
          This timer uses IndexUpdater to periodically call updateIndex().
private  no.feide.moria.log.MessageLogger log
          The message logger.
 
Constructor Summary
DirectoryManager()
           
 
Method Summary
 java.util.HashMap authenticate(java.lang.String sessionTicket, Credentials userCredentials, java.lang.String[] attributeRequest)
          Forwards an authentication attempt to the underlying backend.
 void destroy()
          Destructor.
 java.lang.String getRealm(java.lang.String username)
          Resolves the realm of a given username.
 void setConfig(java.util.Properties config)
          Sets or updates the Directory Manager's configuration.
 void stop()
          Stops the Directory Manager.
protected  void updateIndex(DirectoryManagerIndex newIndex)
          Sets or updates the internal index structure.
 boolean userExists(java.lang.String sessionTicket, java.lang.String username)
          Checks that a user actually exists by querying the underlying backend.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private final no.feide.moria.log.MessageLogger log
The message logger.


index

private DirectoryManagerIndex index
Internal representation of the index.


indexTimer

private java.util.Timer indexTimer
This timer uses IndexUpdater to periodically call updateIndex().


backendFactory

private DirectoryManagerBackendFactory backendFactory
Internal representation of the backend factory.


configuration

private DirectoryManagerConfiguration configuration
The currently used (valid) Directory Manager configuration.

Constructor Detail

DirectoryManager

public DirectoryManager()
Method Detail

destroy

public final void destroy()
Destructor. Will call stop().

See Also:
stop()

setConfig

public final void setConfig(java.util.Properties config)
Sets or updates the Directory Manager's configuration. The first time this method is used, it will force an initial index update by reading the index through IndexUpdater.readIndex().

Parameters:
config - The configuration. The actual parsing is done by the DirectoryManagerConfiguration constructor.
Throws:
DirectoryManagerConfigurationException - If unable create a new configuration object from config or config is null, and also not able to fall back to a previous working configuration to fall back to (in which case a warning will be logged instead). Also thrown if unable to resolve the backend factory class (as specified in the configuration file) or if unable to instantiate this class.
See Also:
DirectoryManagerConfiguration.DirectoryManagerConfiguration(Properties), IndexUpdater.readIndex()

updateIndex

protected final void updateIndex(DirectoryManagerIndex newIndex)
Sets or updates the internal index structure. Used by IndexUpdater.run() to periodically update the index.

Parameters:
newIndex - The new index object. A null value is taken to indicate that the index should not be updated.
Throws:
DirectoryManagerConfigurationException - If newIndex is null and the index has not been previously set.
See Also:
IndexUpdater.run()

userExists

public final boolean userExists(java.lang.String sessionTicket,
                                java.lang.String username)
                         throws BackendException
Checks that a user actually exists by querying the underlying backend.

Parameters:
sessionTicket - Passed on to instances of DirectoryManagerBackend, for logging purposes. May be null or an empty string.
username - The username to look up.
Returns:
true if the user element corresponding to the username actually exists, otherwise false.
Throws:
BackendException - A subclass of BackendException is thrown if there was a problem accessing the backend.
java.lang.IllegalStateException - If attempting to use this method without successfully using setConfig(Properties) first.
See Also:
DirectoryManagerBackend.userExists(String)

authenticate

public final java.util.HashMap authenticate(java.lang.String sessionTicket,
                                            Credentials userCredentials,
                                            java.lang.String[] attributeRequest)
                                     throws AuthenticationFailedException,
                                            BackendException,
                                            java.lang.IllegalStateException
Forwards an authentication attempt to the underlying backend.

Parameters:
sessionTicket - Passed on to instances of DirectoryManagerBackend, for logging purposes. May be null or an empty string.
userCredentials - The user credentials passed on for authentication.
attributeRequest - An array containing the attribute names requested for retrieval after successful authentication.
Returns:
The user attributes matching the attribute request, if those were available. The keys will be String objects, while the values will be String arrays containing one or more attribute values. Note that if any of the requested attributes could not be retrieved from the backend following a successful authentication (for example, if they simply do not exist in the backend in question), the HashMap will still include those attributes that could be retrieved. If no attributes were requested, or if no attributes were retrievable from the backend, an empty HashMap will be returned. This still indicates a successful authentication.
Throws:
BackendException - A subclass of BackendException is thrown if there was a problem accessing the backend.
AuthenticationFailedException - If we managed to access the backend, and the authentication failed. In other words, the user credentials are incorrect. Also thrown if the user credentials are null.
java.lang.IllegalStateException - If attempting to use this method without successfully using setConfig(Properties) first.
See Also:
setConfig(Properties), DirectoryManagerBackend.authenticate(Credentials, String[])

getRealm

public final java.lang.String getRealm(java.lang.String username)
Resolves the realm of a given username. Even for usernames on the form user@realm this method should be used, since it is possible to retain such a username even when changing one's realm or home organization.

Parameters:
username - The username to check.
Returns:
The realm, or null if no such realm can be resolved.
See Also:
DirectoryManagerIndex.getRealm(String)

stop

public final void stop()
Stops the Directory Manager.

Will stop the index updater thread. Note that the Directory Manager may be used after stop(), but this is discouraged.



Copyright © 2001-2006 UNINETT FAS. All Rights Reserved.