Implementing a simple interceptor
The following is for developers who plan to implement their own interceptors in order to extend or modify the functionality of Apache Directory Server. It contains a simple example as a starting point.
What exactly is an interceptor?
An interceptor filters method calls performed on on the DefaultPartitionNexus just like Servlet filters do. The ApacheDS configuration contains a chain of filters performing several tasks. In order to illustrate this, here is the list of interceptors from the default server configuration of ApacheDS 1.5.5
- org.apache.directory.server.core.normalization.NormalizationInterceptor
- org.apache.directory.server.core.authn.AuthenticationInterceptor
- org.apache.directory.server.core.referral.ReferralInterceptor
- org.apache.directory.server.core.authz.AciAuthorizationInterceptor
- org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor
- org.apache.directory.server.core.exception.ExceptionInterceptor
- org.apache.directory.server.core.changelog.ChangeLogInterceptor
- org.apache.directory.server.core.operational.OperationalAttributeInterceptor
- org.apache.directory.server.core.schema.SchemaInterceptor
- org.apache.directory.server.core.subtree.SubentryInterceptor
- org.apache.directory.server.core.collective.CollectiveAttributeInterceptor
- org.apache.directory.server.core.event.EventInterceptor
- org.apache.directory.server.core.trigger.TriggerInterceptor
- org.apache.directory.server.core.journal.JournalInterceptor
Interceptors should usually pass the control of current invocation to the next interceptor by calling an appropriate method on NextInterceptor. The flow control is returned when the next interceptor's filter method returns. You can therefore implement pre-, post-, around- invocation handler by how you place the statement.
Interceptors are a powerful way to extend and modify the server behavior. But be warned. A mistakenly written interceptor may lead to a dis-functional or corrupt server.
Password hash. A simple interceptor
The sources
Currently, the sources are checked in here
In order to build it, simply check it out and type "mvn install".
Implementing the class PasswordHashInterceptor
The following UML class diagram depicts the structure of the little example.