org.apache.directory.server.core
Class DefaultDirectoryService

java.lang.Object
  extended by org.apache.directory.server.core.DefaultDirectoryService
All Implemented Interfaces:
DirectoryService, ServerEntryFactory

public class DefaultDirectoryService
extends java.lang.Object
implements DirectoryService

Default implementation of DirectoryService.

Author:
Apache Directory Project
'XBean'

Field Summary
static int MAX_SIZE_LIMIT_DEFAULT
           
static int MAX_TIME_LIMIT_DEFAULT
           
 
Fields inherited from interface org.apache.directory.server.core.DirectoryService
JNDI_KEY
 
Constructor Summary
DefaultDirectoryService()
          Creates a new instance of the directory service.
 
Method Summary
 void addPartition(Partition parition)
           
 CoreSession getAdminSession()
           
 ChangeLog getChangeLog()
          Gets the ChangeLog service for this DirectoryService used for tracking changes (revisions) to the server and using them to revert the server to earier revisions.
 EventService getEventService()
           
 java.lang.String getInstanceId()
           
 InterceptorChain getInterceptorChain()
           
 java.util.List<Interceptor> getInterceptors()
          Returns interceptors in the server.
 int getMaxSizeLimit()
           
 int getMaxTimeLimit()
           
 OperationManager getOperationManager()
          Gets the operation manager.
 PartitionNexus getPartitionNexus()
           
 java.util.Set<? extends Partition> getPartitions()
          Gets the Partitions used by this DirectoryService.
 Registries getRegistries()
           
 SchemaService getSchemaService()
           
 CoreSession getSession()
          Gets a logical session to perform operations on this DirectoryService as the anonymous user.
 CoreSession getSession(org.apache.directory.shared.ldap.name.LdapDN principalDn, byte[] credentials)
          Gets a logical session to perform operations on this DirectoryService as a specific user with a separate authorization principal.
 CoreSession getSession(org.apache.directory.shared.ldap.name.LdapDN principalDn, byte[] credentials, java.lang.String saslMechanism, java.lang.String saslAuthId)
          Gets a logical session to perform operations on this DirectoryService as a specific user with a separate authorization principal.
 CoreSession getSession(LdapPrincipal principal)
          Gets a logical session to perform operations on this DirectoryService as a specific user.
 Partition getSystemPartition()
           
 java.util.List<org.apache.directory.shared.ldap.ldif.LdifEntry> getTestEntries()
          Returns test directory entries(LdifEntry) to be loaded while bootstrapping.
 java.io.File getWorkingDirectory()
          Returns working directory (counterpart of var/lib) where partitions are stored by default.
 boolean isAccessControlEnabled()
          Returns true if access control checks are enabled.
 boolean isAllowAnonymousAccess()
          Returns true if anonymous access is allowed on entries besides the RootDSE.
 boolean isDenormalizeOpAttrsEnabled()
           
 boolean isExitVmOnShutdown()
           
 boolean isFirstStart()
           
 boolean isShutdownHookEnabled()
          Checks to see if this DirectoryService has registered a JVM shutdown hook to flush caches and synchronize to disk safely.
 boolean isStarted()
          Returns true if this service is started.
 ServerEntry newEntry(org.apache.directory.shared.ldap.name.LdapDN dn)
          Creates a new ServerEntry which has not yet been added to the directory.
 ServerEntry newEntry(java.lang.String ldif, java.lang.String dn)
          Create a new ServerEntry
 void removePartition(Partition partition)
           
 long revert()
          Reverts the server's state to the latest tagged snapshot if one was taken.
 long revert(long revision)
          Reverts the server's state to an earlier revision.
 void setAccessControlEnabled(boolean accessControlEnabled)
          Sets whether to enable basic access control checks or not.
 void setAllowAnonymousAccess(boolean enableAnonymousAccess)
          Sets whether to allow anonymous access to entries other than the RootDSE.
 void setChangeLog(ChangeLog changeLog)
          Sets the ChangeLog service for this DirectoryService used for tracking changes (revisions) to the server and using them to revert the server to earier revisions.
 void setDenormalizeOpAttrsEnabled(boolean denormalizeOpAttrsEnabled)
           
 void setEventService(EventService eventService)
           
 void setExitVmOnShutdown(boolean exitVmOnShutdown)
           
 void setInstanceId(java.lang.String instanceId)
           
 void setInterceptors(java.util.List<Interceptor> interceptors)
          Sets the interceptors in the server.
 void setMaxSizeLimit(int maxSizeLimit)
           
 void setMaxTimeLimit(int maxTimeLimit)
           
 void setPartitions(java.util.Set<? extends Partition> partitions)
          Sets Partitions used by this DirectoryService.
 void setRegistries(Registries registries)
           
 void setSchemaService(SchemaService schemaService)
           
 void setShutdownHookEnabled(boolean shutdownHookEnabled)
          Sets the shutdown hook flag which controls whether or not this DirectoryService registers a JVM shutdown hook to flush caches and synchronize to disk safely.
 void setSystemPartition(Partition systemPartition)
           
 void setTestEntries(java.util.List<? extends org.apache.directory.shared.ldap.ldif.LdifEntry> testEntries)
          Sets test directory entries(Attributes) to be loaded while bootstrapping.
 void setWorkingDirectory(java.io.File workingDirectory)
          Sets working directory (counterpart of var/lib) where partitions are stored by default.
 void shutdown()
          Shuts down this service.
 void startup()
          Starts up this service.
 void sync()
          Calls Partition.sync() for all registered Partitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_SIZE_LIMIT_DEFAULT

public static final int MAX_SIZE_LIMIT_DEFAULT
See Also:
Constant Field Values

MAX_TIME_LIMIT_DEFAULT

public static final int MAX_TIME_LIMIT_DEFAULT
See Also:
Constant Field Values
Constructor Detail

DefaultDirectoryService

public DefaultDirectoryService()
Creates a new instance of the directory service.

Method Detail

setInstanceId

public void setInstanceId(java.lang.String instanceId)
Specified by:
setInstanceId in interface DirectoryService

getInstanceId

public java.lang.String getInstanceId()
Specified by:
getInstanceId in interface DirectoryService

getPartitions

public java.util.Set<? extends Partition> getPartitions()
Gets the Partitions used by this DirectoryService.

Specified by:
getPartitions in interface DirectoryService
Returns:
the set of partitions used
'XBean Property'
nestedType="org.apache.directory.server.core.partition.Partition"

setPartitions

public void setPartitions(java.util.Set<? extends Partition> partitions)
Sets Partitions used by this DirectoryService.

Specified by:
setPartitions in interface DirectoryService
Parameters:
partitions - the partitions to used
'XBean Property'
nestedType="org.apache.directory.server.core.partition.Partition"

isAccessControlEnabled

public boolean isAccessControlEnabled()
Returns true if access control checks are enabled.

Specified by:
isAccessControlEnabled in interface DirectoryService
Returns:
true if access control checks are enabled, false otherwise

setAccessControlEnabled

public void setAccessControlEnabled(boolean accessControlEnabled)
Sets whether to enable basic access control checks or not.

Specified by:
setAccessControlEnabled in interface DirectoryService
Parameters:
accessControlEnabled - true to enable access control checks, false otherwise

isAllowAnonymousAccess

public boolean isAllowAnonymousAccess()
Returns true if anonymous access is allowed on entries besides the RootDSE. If the access control subsystem is enabled then access to some entries may not be allowed even when full anonymous access is enabled.

Specified by:
isAllowAnonymousAccess in interface DirectoryService
Returns:
true if anonymous access is allowed on entries besides the RootDSE, false if anonymous access is allowed to all entries.

setAllowAnonymousAccess

public void setAllowAnonymousAccess(boolean enableAnonymousAccess)
Sets whether to allow anonymous access to entries other than the RootDSE. If the access control subsystem is enabled then access to some entries may not be allowed even when full anonymous access is enabled.

Specified by:
setAllowAnonymousAccess in interface DirectoryService
Parameters:
enableAnonymousAccess - true to enable anonymous access, false to disable it

getInterceptors

public java.util.List<Interceptor> getInterceptors()
Returns interceptors in the server.

Specified by:
getInterceptors in interface DirectoryService
Returns:
the interceptors in the server.

setInterceptors

public void setInterceptors(java.util.List<Interceptor> interceptors)
Sets the interceptors in the server.

Specified by:
setInterceptors in interface DirectoryService
Parameters:
interceptors - the interceptors to be used in the server.
'XBean Property'
nestedType="org.apache.directory.server.core.interceptor.Interceptor"

getTestEntries

public java.util.List<org.apache.directory.shared.ldap.ldif.LdifEntry> getTestEntries()
Returns test directory entries(LdifEntry) to be loaded while bootstrapping.

Specified by:
getTestEntries in interface DirectoryService
Returns:
test entries to load during bootstrapping
'XBean Property'
nestedType="org.apache.directory.shared.ldap.ldif.Entry"

setTestEntries

public void setTestEntries(java.util.List<? extends org.apache.directory.shared.ldap.ldif.LdifEntry> testEntries)
Sets test directory entries(Attributes) to be loaded while bootstrapping.

Specified by:
setTestEntries in interface DirectoryService
Parameters:
testEntries - the test entries to load while bootstrapping
'XBean Property'
nestedType="org.apache.directory.shared.ldap.ldif.Entry"

getWorkingDirectory

public java.io.File getWorkingDirectory()
Returns working directory (counterpart of var/lib) where partitions are stored by default.

Specified by:
getWorkingDirectory in interface DirectoryService
Returns:
the directory where partition's are stored.

setWorkingDirectory

public void setWorkingDirectory(java.io.File workingDirectory)
Sets working directory (counterpart of var/lib) where partitions are stored by default.

Specified by:
setWorkingDirectory in interface DirectoryService
Parameters:
workingDirectory - the directory where the server's partitions are stored by default.

setShutdownHookEnabled

public void setShutdownHookEnabled(boolean shutdownHookEnabled)
Description copied from interface: DirectoryService
Sets the shutdown hook flag which controls whether or not this DirectoryService registers a JVM shutdown hook to flush caches and synchronize to disk safely. This is enabled by default.

Specified by:
setShutdownHookEnabled in interface DirectoryService
Parameters:
shutdownHookEnabled - true to enable the shutdown hook, false to disable

isShutdownHookEnabled

public boolean isShutdownHookEnabled()
Description copied from interface: DirectoryService
Checks to see if this DirectoryService has registered a JVM shutdown hook to flush caches and synchronize to disk safely. This is enabled by default.

Specified by:
isShutdownHookEnabled in interface DirectoryService
Returns:
true if a shutdown hook is registered, false if it is not

setExitVmOnShutdown

public void setExitVmOnShutdown(boolean exitVmOnShutdown)
Specified by:
setExitVmOnShutdown in interface DirectoryService

isExitVmOnShutdown

public boolean isExitVmOnShutdown()
Specified by:
isExitVmOnShutdown in interface DirectoryService

setMaxSizeLimit

public void setMaxSizeLimit(int maxSizeLimit)
Specified by:
setMaxSizeLimit in interface DirectoryService

getMaxSizeLimit

public int getMaxSizeLimit()
Specified by:
getMaxSizeLimit in interface DirectoryService

setMaxTimeLimit

public void setMaxTimeLimit(int maxTimeLimit)
Specified by:
setMaxTimeLimit in interface DirectoryService

getMaxTimeLimit

public int getMaxTimeLimit()
Specified by:
getMaxTimeLimit in interface DirectoryService

setSystemPartition

public void setSystemPartition(Partition systemPartition)
Specified by:
setSystemPartition in interface DirectoryService

getSystemPartition

public Partition getSystemPartition()
Specified by:
getSystemPartition in interface DirectoryService

isDenormalizeOpAttrsEnabled

public boolean isDenormalizeOpAttrsEnabled()
Specified by:
isDenormalizeOpAttrsEnabled in interface DirectoryService

setDenormalizeOpAttrsEnabled

public void setDenormalizeOpAttrsEnabled(boolean denormalizeOpAttrsEnabled)
Specified by:
setDenormalizeOpAttrsEnabled in interface DirectoryService

getChangeLog

public ChangeLog getChangeLog()
Description copied from interface: DirectoryService
Gets the ChangeLog service for this DirectoryService used for tracking changes (revisions) to the server and using them to revert the server to earier revisions.

Specified by:
getChangeLog in interface DirectoryService
Returns:
the change log service

setChangeLog

public void setChangeLog(ChangeLog changeLog)
Description copied from interface: DirectoryService
Sets the ChangeLog service for this DirectoryService used for tracking changes (revisions) to the server and using them to revert the server to earier revisions.

Specified by:
setChangeLog in interface DirectoryService
Parameters:
changeLog - the change log service to set

addPartition

public void addPartition(Partition parition)
                  throws java.lang.Exception
Specified by:
addPartition in interface DirectoryService
Throws:
java.lang.Exception

removePartition

public void removePartition(Partition partition)
                     throws java.lang.Exception
Specified by:
removePartition in interface DirectoryService
Throws:
java.lang.Exception

getAdminSession

public CoreSession getAdminSession()
Specified by:
getAdminSession in interface DirectoryService

getSession

public CoreSession getSession()
Description copied from interface: DirectoryService
Gets a logical session to perform operations on this DirectoryService as the anonymous user. This bypasses authentication without propagating a bind operation into the core.

Specified by:
getSession in interface DirectoryService
Returns:
a logical session as the anonymous user

getSession

public CoreSession getSession(LdapPrincipal principal)
Description copied from interface: DirectoryService
Gets a logical session to perform operations on this DirectoryService as a specific user. This bypasses authentication without propagating a bind operation into the core.

Specified by:
getSession in interface DirectoryService
Returns:
a logical session as a specific user

getSession

public CoreSession getSession(org.apache.directory.shared.ldap.name.LdapDN principalDn,
                              byte[] credentials)
                       throws java.lang.Exception
Description copied from interface: DirectoryService
Gets a logical session to perform operations on this DirectoryService as a specific user with a separate authorization principal. This bypasses authentication without propagating a bind operation into the core.

Specified by:
getSession in interface DirectoryService
Returns:
a logical session as a specific user
Throws:
java.lang.Exception

getSession

public CoreSession getSession(org.apache.directory.shared.ldap.name.LdapDN principalDn,
                              byte[] credentials,
                              java.lang.String saslMechanism,
                              java.lang.String saslAuthId)
                       throws java.lang.Exception
Description copied from interface: DirectoryService
Gets a logical session to perform operations on this DirectoryService as a specific user with a separate authorization principal. This bypasses authentication without propagating a bind operation into the core.

Specified by:
getSession in interface DirectoryService
Returns:
a logical session as a specific user
Throws:
java.lang.Exception

revert

public long revert()
            throws java.lang.Exception
Description copied from interface: DirectoryService
Reverts the server's state to the latest tagged snapshot if one was taken. If there is no tag a illegal state exception will result. If the latest revision is not earlier than the current revision (both are same), then no changes were made to the directory to be reverted. In this case we return the current revision and do nothiig loggin the fact that we ignored the request to revert.

Specified by:
revert in interface DirectoryService
Returns:
the new revision reached by applying all changes needed to revert to the new state or the same version before this call if no revert actually took place
Throws:
java.lang.Exception - if there are problems reverting back to the earlier state
java.lang.UnsupportedOperationException - if this feature is not supported by the change log

revert

public long revert(long revision)
            throws java.lang.Exception
Description copied from interface: DirectoryService
Reverts the server's state to an earlier revision. Note that the revsion number still increases to revert back even though the state reverted to is the same. Note that implementations may lock the server from making changes or searching the directory until this operation has completed.

Specified by:
revert in interface DirectoryService
Parameters:
revision - the revision number to revert to
Returns:
the new revision reached by applying all changes needed to revert to the original state
Throws:
java.lang.Exception - if there are problems reverting back to the earlier state
java.lang.IllegalArgumentException - if the revision provided is greater than the current revision or less than 0
java.lang.UnsupportedOperationException - if this feature is not supported by the change log

getOperationManager

public OperationManager getOperationManager()
Description copied from interface: DirectoryService
Gets the operation manager.

Specified by:
getOperationManager in interface DirectoryService

startup

public void startup()
             throws java.lang.Exception
Description copied from interface: DirectoryService
Starts up this service.

Specified by:
startup in interface DirectoryService
Throws:
javax.naming.NamingException - if the LDAP server cannot be started
java.lang.Exception - if failed to start up

sync

public void sync()
          throws java.lang.Exception
Description copied from interface: DirectoryService
Calls Partition.sync() for all registered Partitions.

Specified by:
sync in interface DirectoryService
Throws:
java.lang.Exception - if synchronization failed

shutdown

public void shutdown()
              throws java.lang.Exception
Description copied from interface: DirectoryService
Shuts down this service.

Specified by:
shutdown in interface DirectoryService
Throws:
java.lang.Exception - if failed to shut down

getRegistries

public Registries getRegistries()
Specified by:
getRegistries in interface DirectoryService

setRegistries

public void setRegistries(Registries registries)
Specified by:
setRegistries in interface DirectoryService

getSchemaService

public SchemaService getSchemaService()
Specified by:
getSchemaService in interface DirectoryService

setSchemaService

public void setSchemaService(SchemaService schemaService)
Specified by:
setSchemaService in interface DirectoryService

getPartitionNexus

public PartitionNexus getPartitionNexus()
Specified by:
getPartitionNexus in interface DirectoryService

getInterceptorChain

public InterceptorChain getInterceptorChain()
Specified by:
getInterceptorChain in interface DirectoryService

isFirstStart

public boolean isFirstStart()

isStarted

public boolean isStarted()
Description copied from interface: DirectoryService
Returns true if this service is started.

Specified by:
isStarted in interface DirectoryService
Returns:
true if the service has started, false otherwise

newEntry

public ServerEntry newEntry(org.apache.directory.shared.ldap.name.LdapDN dn)
Description copied from interface: ServerEntryFactory
Creates a new ServerEntry which has not yet been added to the directory.

Specified by:
newEntry in interface ServerEntryFactory

newEntry

public ServerEntry newEntry(java.lang.String ldif,
                            java.lang.String dn)
Create a new ServerEntry

Specified by:
newEntry in interface DirectoryService
Parameters:
ldif - The String representing the attributes, as a LDIF file
dn - The DN for this new entry

getEventService

public EventService getEventService()
Specified by:
getEventService in interface DirectoryService

setEventService

public void setEventService(EventService eventService)
Specified by:
setEventService in interface DirectoryService


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.