String principal = getPrincipal( env );
byte[] credential = getCredential( env );
String authentication = getAuthentication( env );
String providerUrl = getProviderUrl( env );
DirectoryService service = DirectoryService.getInstance( cfg.getInstanceId() );
// Execute configuration
if( cfg instanceof ShutdownConfiguration )
{
service.shutdown();
}
else if( cfg instanceof SyncConfiguration )
{
service.sync();
}
else if( cfg instanceof StartupConfiguration )
{
service.startup( this, env );
}
else if( cfg instanceof AddDirectoryPartitionConfiguration )
{
new DirectoryPartitionNexusProxy(
service.getJndiContext( principal, credential, authentication, providerUrl ),
service).addContextPartition( ( ( AddDirectoryPartitionConfiguration ) cfg ).getDirectoryPartitionConfiguration() );
}
else if( cfg instanceof RemoveDirectoryPartitionConfiguration )
{
new DirectoryPartitionNexusProxy(
service.getJndiContext( principal, credential, authentication, providerUrl ),
service).removeContextPartition( ( ( RemoveDirectoryPartitionConfiguration ) cfg ).getSuffix() );
}
else if( service == null )
{
throw new NamingException( "Unknown configuration: " + cfg );
}
return service.getJndiContext( principal, credential, authentication, providerUrl );
}