if ( ( ldapServerBean == null ) || ldapServerBean.isDisabled() )
{
return null;
}
LdapServer ldapServer = new LdapServer();
ldapServer.setDirectoryService( directoryService );
ldapServer.setEnabled( true );
// The ID
ldapServer.setServiceId( ldapServerBean.getServerId() );
// SearchBaseDN
ldapServer.setSearchBaseDn( ldapServerBean.getSearchBaseDn().getName() );
// KeyStore
ldapServer.setKeystoreFile( ldapServerBean.getLdapServerKeystoreFile() );
// Certificate password
ldapServer.setCertificatePassword( ldapServerBean.getLdapServerCertificatePassword() );
// ConfidentialityRequired
ldapServer.setConfidentialityRequired( ldapServerBean.isLdapServerConfidentialityRequired() );
// Max size limit
ldapServer.setMaxSizeLimit( ldapServerBean.getLdapServerMaxSizeLimit() );
// Max time limit
ldapServer.setMaxTimeLimit( ldapServerBean.getLdapServerMaxTimeLimit() );
// MaxPDUSize
ldapServer.setMaxPDUSize( ldapServerBean.getMaxPDUSize() );
// Sasl Host
ldapServer.setSaslHost( ldapServerBean.getLdapServerSaslHost() );
// Sasl Principal
ldapServer.setSaslPrincipal( ldapServerBean.getLdapServerSaslPrincipal() );
// Sasl realm
ldapServer.setSaslRealms( ldapServerBean.getLdapServerSaslRealms() );
// The transports
Transport[] transports = createTransports( ldapServerBean.getTransports() );
ldapServer.setTransports( transports );
// SaslMechs
for ( SaslMechHandlerBean saslMechHandlerBean : ldapServerBean.getSaslMechHandlers() )
{
if ( saslMechHandlerBean.isEnabled() )
{
String mechanism = saslMechHandlerBean.getSaslMechName();
ldapServer.addSaslMechanismHandler( mechanism, createSaslMechHandler( saslMechHandlerBean ) );
}
}
// ExtendedOpHandlers
for ( ExtendedOpHandlerBean extendedpHandlerBean : ldapServerBean.getExtendedOps() )
{
if ( extendedpHandlerBean.isEnabled() )
{
try
{
Class<?> extendedOpClass = Class.forName( extendedpHandlerBean.getExtendedOpHandlerClass() );
ExtendedOperationHandler extOpHandler = ( ExtendedOperationHandler ) extendedOpClass.newInstance();
ldapServer.addExtendedOperationHandler( extOpHandler );
}
catch ( Exception e )
{
String message = "Failed to load and instantiate ExtendedOperationHandler implementation "
+ extendedpHandlerBean.getExtendedOpId() + ": " + e.getMessage();
LOG.error( message );
throw new ConfigurationException( message );
}
}
}
// ReplReqHandler
boolean replicationEnabled = ldapServerBean.isReplEnabled();
if ( replicationEnabled )
{
String fqcn = ldapServerBean.getReplReqHandler();
if ( fqcn != null )
{
try
{
Class<?> replProvImplClz = Class.forName( fqcn );
ReplicationRequestHandler rp = ( ReplicationRequestHandler ) replProvImplClz.newInstance();
ldapServer.setReplicationReqHandler( rp );
}
catch ( Exception e )
{
String message = "Failed to load and instantiate ReplicationRequestHandler implementation : "
+ fqcn;
LOG.error( message );
throw new ConfigurationException( message );
}
}
else
{
// Try with the default handler
ReplicationRequestHandler rp = new SyncReplRequestHandler();
ldapServer.setReplicationReqHandler( rp );
}
}
ldapServer.setReplConsumers( createReplConsumers( ldapServerBean.getReplConsumers() ) );
return ldapServer;
}