Wednesday, July 16, 2014

LDAP integration with AEM6 (OSGi Config way)

In AEM 6, LDAP support comes with a new implementation that requires a different type of configuration than with previous versions.

All LDAP configurations are now available as OSGi configurations. They can be configured via the Web Management console at:

http://serveraddress:4502/system/console/configMgr

The required config classes are listed below.
  1. org.apache.jackrabbit.oak.security.authentication.ldap.impl.LdapIdentityProvider
  2. org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler
  3. org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalLoginModuleFactory. 
The configs can be updated manually via OSGi console or via deployment. We can use the follow steps & config files to add/update an LDAP provider.


Create OSGi config file of type  "sling:OsgiConfig" & name it to 
"org.apache.jackrabbit.oak.security.authentication.ldap.impl.LdapIdentityProvider.xml". 

See here for reference.


Similarly create two more config files & name them as below.

org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler.xml



org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalLoginModuleFactory.xml



Now with this config files in place, do a config/content deployment & upon successful deployment your AEM instance is configured with the provided LDAP server.

Tested with OpenDS 2.2 & AEM 6

Please Note: You may need to restart your AEM instance once the configs are applied.

Tuesday, July 8, 2014

Inject OSGi services in Sling models (Pojos) - Sling model way

Create the injection point in the sling model class with @Source annotation & assign "osgi-services" as a value to the source annotation. 

By this we can inject the below OSGi service in the Sling Model class.

JCR content mapping with Sling Model

follow the easy steps to use sling model for JCR content mapping.

  1. Add sling model bundle dependency information in pom.xml  
  2. Add Sling-Model-Packages declaration in the instruction 
  3. Annotate pojo class with @Model annotation and use @Inject against the fields (with getters)  
  4. Now adapt this pojo with resource.adaptTo() 
  5. This Will map the below content structure easily without the bulgy or cluttered code.