Package com.nimbusds.common.ldap
Class SampleDirectory
java.lang.Object
com.nimbusds.common.ldap.SampleDirectory
- All Implemented Interfaces:
jakarta.servlet.ServletContextListener
,EventListener
Sample in-memory LDAP directory server for demonstration and testing
purposes. Access is limited to read and bind (authenticate) only.
The directory server is configured by a set of "sampleDirectoryServer.*"
properties which can be overridden with Java system properties, see
SampleDirectory.Configuration
.
The sample directory implements ServletContextListener
. This
enables its automatic startup and shutdown in a servlet container (Java web
server), such as Apache Tomcat. When started from a servlet container the
directory configuration is obtained from a properties file specified by a
context parameter named sampleDirectoryServer.configurationFile
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The sample directory server configuration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
contextDestroyed
(jakarta.servlet.ServletContextEvent sce) Handler for servlet context shutdown events.void
contextInitialized
(jakarta.servlet.ServletContextEvent sce) Handler for servlet context startup events.void
start
(SampleDirectory.Configuration config) Starts the sample in-memory directory server.void
stop()
Stops the sample in-memory directory server (if previously started).
-
Constructor Details
-
SampleDirectory
public SampleDirectory()
-
-
Method Details
-
start
public void start(SampleDirectory.Configuration config) throws com.unboundid.ldap.sdk.LDAPException, IOException, com.unboundid.ldif.LDIFException Starts the sample in-memory directory server.- Parameters:
config
- The sample directory server configuration. Must not benull
.- Throws:
com.unboundid.ldap.sdk.LDAPException
- If the in-memory directory server couldn't be started or its initialisation failed.IOException
- If a schema file was specified and it couldn't be read.com.unboundid.ldif.LDIFException
- If a schema file was specified that is not valid LDIF.
-
stop
Stops the sample in-memory directory server (if previously started). Information and status messages are logged at INFO level. -
contextInitialized
Handler for servlet context startup events. Launches the sample in-memory directory server (if enabled per configuration). Exceptions are logged at ERROR level, information and status messages at INFO level.The sample directory server configuration is retrieved from a properties file which location is specified by a servlet context parameter named
sampleDirectory.configurationFile
.- Specified by:
contextInitialized
in interfacejakarta.servlet.ServletContextListener
- Parameters:
sce
- A servlet context event.
-
contextDestroyed
Handler for servlet context shutdown events. Stops the sample in-memory directory server (if previously started).- Specified by:
contextDestroyed
in interfacejakarta.servlet.ServletContextListener
- Parameters:
sce
- A servlet context event.
-