*/
public void start(BundleContext bundleContext) {
try {
/*Read the embedded-ldap configuration file.*/
LDAPConfigurationBuilder configurationBuilder = new LDAPConfigurationBuilder(
getLdapConfigurationFile());
/*Make relevant objects that encapsulate different parts of config file.*/
configurationBuilder.buildConfigurations();
boolean embeddedLDAPEnabled = configurationBuilder.isEmbeddedLDAPEnabled();
//start LDAPServer only if embedded-ldap is enabled.
if (embeddedLDAPEnabled) {
LDAPConfiguration ldapConfiguration = configurationBuilder.getLdapConfiguration();
/*set the embedded-apacheds's schema location which is: carbon-home/repository/data/
is-default-schema.zip
*/
setSchemaLocation();
/* Set working directory where schema directory and ldap partitions are created*/
setWorkingDirectory(ldapConfiguration);
startLdapServer(ldapConfiguration);
/* replace default password with that is provided in the configuration file.*/
this.ldapServer.changeConnectionUserPassword(
configurationBuilder.getConnectionPassword());
// Add admin (default)partition if it is not already created.
PartitionManager partitionManager = this.ldapServer.getPartitionManager();
PartitionInfo defaultPartitionInfo=
configurationBuilder.getPartitionConfigurations();
boolean defaultPartitionAlreadyExisted=partitionManager.partitionDirectoryExists(
defaultPartitionInfo.getPartitionId());
if (!defaultPartitionAlreadyExisted) {
partitionManager.addPartition(defaultPartitionInfo);
} else {
partitionManager.initializeExistingPartition(defaultPartitionInfo);
}
// Start KDC if enabled
if (configurationBuilder.isKdcEnabled()) {
startKDC(configurationBuilder.getKdcConfigurations());
// Add kerberos attributes only if the default partition is newly created.
if (!defaultPartitionAlreadyExisted) {
kdcServer.kerberizePartition(configurationBuilder.
getPartitionConfigurations(), this.ldapServer);
}
}
//create and register LDAPTenantManager implementation in OSGI.