> On Jul 23, 2019, at 5:24 PM, Emmanuel Lécharny <elecha...@gmail.com> wrote:
> 
> So this is M23. 3 years old. Hmmm. We should have released more often, 
> considering it's currently M25.
Nothing actually stops me from trying to update to the latest. I think I even 
tried to do that, but then ran into some minor things, so decided not to bring 
more changes into the equation, until I have a working solution.

> 
> 
> Regardless, answering to your questions now...
> 
> 
>> 
>> 2) Directory Server created explicitly with the following code as an example:
>> 
>> 
>>             // add our bind interceptor to the front of the list
>>             def interceptors = directoryService.getInterceptors()
>>             interceptors.add(0, bindInterceptor)
>> 
>> //            
>> interceptors.add(findNormalizationInterceptorPosition(interceptors) + 1, 
>> crudInterceptor)
>> 
>>             bindInterceptor.init(directoryService)
> 
> It's not necessary. init() will be called when the addFirst() method will be 
> called.
Here is the first thing where I confused you. There are 2 interceptors: bind 
one is the legacy one, and crudInterceptor is the one I’m working on currently

> 
> 
>> 
>>             directoryService.setInterceptors(interceptors)
>>             directoryService.addFirst(crudInterceptor)
This is the guy!

>> 
>> As you can see from the file, there is a section related to interceptors, 
>> and while setting server up, I see that my interceptors is in the middle of 
>> the pack. I can also see that while doing “modify(opContext)” in my custom 
>> interceptor, where opContext would reflect total number of interceptors and 
>> current number (though still throwing NPE at next(opContext)). Nevertheless, 
>> I tried to grab the default config.ldif from downloaded DS archive and 
>> inserted a section related to interceptors into schemaLdif file. That didn’t 
>> really change anything for me. I think it might be related to the fact that 
>> I can’t see anything with Directory Browser under ou=config, after server is 
>> up. So would be really nice if you can direct me to how I can use 
>> config.ldif while setting the server up programmatically.
> 
> 
> Th ecurrent version, as M23, is now starting the server and configure it 
> using the LDIF file that is stored on disk. If you look at the UberJarMain 
> file, which is the starting point of the whole system, it takes an argument 
> which is the layout (ie, the place where all your server config/data etc are 
> stored), then call start(), then ApacheDsService.start(), which load the 
> schema, initialize the config partition, read it, and create instance of 
> XXXBean:
> 
> 
>         initSchemaManager( instanceLayout );
>         DnFactory bootstrapDnFactory = new DefaultDnFactory( schemaManager, 
> 100 );
>         initSchemaLdifPartition( instanceLayout, bootstrapDnFactory );
>         initConfigPartition( instanceLayout, bootstrapDnFactory );
> 
>         // Read the configuration
>         ConfigPartitionReader cpReader = new ConfigPartitionReader( 
> configPartition );
> 
>         ConfigBean configBean = cpReader.readConfig();
> 
> ConfigBean contains the whole config for your server. Then the 
> initDirectoryService() method is called, which create the DirectoryService:
> 
>         DirectoryService directoryService = 
> ServiceBuilder.createDirectoryService( directoryServiceBean,
>             instanceLayout, schemaManager );
> 
> This is where the interceptors get loaded, the Map computed.
> 
> 
> If you follow the same steps, you should be good to go. At the end, it's 
> really all about defining the proper config file.
Ok, thank you for some insights. I’ll try to follow your recipe.

> 
>> 2) As you can see from the snippet, I tried to do .addFirst(crudInterceptor) 
>> and from a first glance it worked for me, no more NPE, my custom code works 
>> fine, but as you said, I’m not sure if that’s a right way or any 
>> complications can be right around the corner.
> 
> 
> It depends :-)
> 
> The interceptors order is critical for the server to work well. It would make 
> no sense for instance to have the SchemaInterceptor be the first one in the 
> chain, before authent or authz...
> 
> As your interceptor deal with Bind, it's probably correct to have it at first 
> position.
That’s actually a confusion I brought by mentioning a legacy one, as I said 
above.

> 
> Now, I will ask you what is this interceptor doing ? There are other means to 
> implement a mechanism that manage authentication, through Authenticators. But 
> that is another discussion…
The interceptor I’m implementing is actually capturing LDAP add/modify/delete 
commands and calls REST api to reflect the changes in a different system which 
is kinda synced with LDAP. I looked at AvlPartition.add/modify method as a 
possible candidate, but don’t feel like it’s the right place, or is it?


Regards,
Philipp
-- 

CONFIDENTIALITY NOTICE: This message (including any attachments) contains 
confidential information intended for a specific individual and purpose, 
and is protected by law. If you are not the intended recipient, you should 
delete this message. Any disclosure, copying, or distribution of this 
message, or the taking of any action based on it, is strictly prohibited. 
[v.E.1]

Reply via email to