directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <>
Subject Re: Queston on Interceptor
Date Thu, 22 Sep 2016 19:32:09 GMT
Le 22/09/16 à 20:55, Sathyanarayan, Harish a écrit :
> Hi Emmanuel,
> The custom interceptor I wrote looks like:
> public class ProxyInterceptor extends BaseInterceptor {
> @Override
> 	public EntryFilteringCursor search(final SearchOperationContext searchContext) throws
LdapException {
> // call connector
> }
> @Override
> 	public void add(final AddOperationContext addContext) throws LdapException {
> 		try {"addContext.getEntry() ");
> 			proxyConnector.add(addContext.getEntry());
> 		} catch (CursorException e) {
> 		}
> 		next(addContext);
> 	}
> @Override
> public void modify(final ModifyOperationContext modifyContext) throws LdapException {
> 	}
> }
> I am calling this interceptor from my resource class. For example the rest call for modify
does not work:
> 		               Modification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
> 			    "test123456" );
> 			ModifyRequest modifyRequest = new ModifyRequestImpl();
> 			modifyRequest.setName(new Dn("dc=example,dc=com"));
> 			modifyRequest.addModification(mod);
> 			getConnection().modify(modifyRequest);
> 				// connection.modify("test", );
>"after modify");
> 				releaseConnection(connection);
> Hope this helps, let me know if anything else...thanks!

Ok, makes sense.

The interceptors are weird little beasts... The way they are called is a
bit complex.

Basically, each interceptor can implement as many method as needed, from
the interface they implement. Each of those method is going to be called
by the previous interceptor. Up to this point, you get it right.

Now, the tricky part is how the interceptors get called, and how ne
interceptor know which is the next one.

Each operation is associated with an ordered list of interceptor As you
may not want to implement some operation, these lists may be longer or
shorter. For instance, the search operation is handled by pretty much
all the interceptor, but ChangeLogInterceptor or JournalInterceptor
(because we don't log searches, and a search is not an change). This is
true for every interceptor.
This list may change, depending on which interceptor is loaded and
enabled. If you add your own interceptor, then the lists are going to be

All in all we use a map<Operation, List<Interceptor>> to store this
information. the tricky part is to have this map created. Actually, you
need to modify the server's configuration, insterting your
intercerceptor are the place you want, and this is the moment the map is

Let's do that  : can you check the content of this map? You can get each
operation list by calling DirectoryService.getInterceptors(
OperationEnum ) where OperationEnum is one of :


Typically, try with SEARH, and see what list you have, and try with ADD
to see what you have. Your interceptor must be listed in both case.

> -----Original Message-----
> From: Emmanuel Lécharny [] 
> Sent: Thursday, September 22, 2016 2:48 PM
> To: Apache Directory Developers List <>
> Subject: Re: Queston on Interceptor
> Le 22/09/16 à 20:32, Sathyanarayan, Harish a écrit :
>> Hi:
>> I have written a proxy interceptor that implements BaseInterceptor operations like
Search, add, modify etc. I have tried inserting both next to the normalizationinterceptor
and at the very end of the chain. I run the ApacheDS as embedded service under dropwizard.
> You probably want to insert your interceptor after the normalizerInterceptor : That wuld
be the natural position
>> I have a REST API performing CRUD operations. My question is: when I 
>> call the Resource to perform add and search it calls the interceptor
> Hmm. Not sure I understand this sentence : do you call the interceptor directly, or is
the interceptor called by the uer layer ?
>> that talks to the connector to perform the proxy operation.  This works as intended.
But if I try modify and delete, it does not even hit the interceptor and there is no response.
Wondering what could be the root cause of this issue?
> Can you show the signature for these operations ?
> The information contained in this electronic mail transmission may be privileged and
confidential, and therefore, protected from disclosure. If you have received this communication
in error, please notify us immediately by replying to this message and deleting the email
and its attachments from all computers without copying or disclosing it.

View raw message