I am trying to utilize up to the minute, bleeding edge ApacheDS server. Since
I am moving from 1.5.3, lots of stuff is new. I have tried to use some docs I
found and the docs I built with doc book, but I have not found an example that
works with the head of trunk.
What I have does not work yet, I am still trying different things, but not
getting a server running yet.
This is what I have. The first time I run it, it tries to extract the Ldifs
from my build/classes directory, where there are no ldifs. Any time after that
I try to run, it says directory exists and throws.
@CreateDS
public void startApacheDS(SessionContext ctx)
throws Exception
{
try
{
Security.addProvider(new com.polycom.sasl.PlcmNtlmSaslProvider()); //
required for GSS-SPNEGO against
log.info("ldif directory ["
+ new
File(Environment.getResourcePaths().getLDIFDir()).getAbsoluteFile() + "]");
System.setProperty( "workingDirectory", new
File(Environment.getResourcePaths().getLDIFDir()).getParentFile().getAbsolutePath()
);
DirectoryService directoryService =
DSAnnotationProcessor.getDirectoryService();
File workDir = new
File(Environment.getResourcePaths().getADSWorkDir()).getAbsoluteFile();
// Attempt to remove the workDir if LDIFs are newer than the system
// and schema cache files
cleanWorkDir(workDir);
// SMH TODO directoryService.setWorkingDirectory(workDir);
InstanceLayout instanceLayout = new
InstanceLayout(workDir.getParentFile());
instanceLayout.setLogDir(new
File(Environment.getResourcePaths().getLogFilePath()));
directoryService.setInstanceLayout(instanceLayout);
directoryService.setShutdownHookEnabled(false);
directoryService.setAllowAnonymousAccess(false);
List<Interceptor> ints = directoryService.getInterceptors();
for (Interceptor i : ints)
{
if (i instanceof CollectiveAttributeInterceptor)
{
ints.remove(i);
break;
}
}
directoryService.setInterceptors(ints);
directoryService.startup();
LdapServer ldapServer = new LdapServer();
ldapServer.setDirectoryService(directoryService);
ldapServer.setTransports(new TcpTransport(ADS_PORT));
// SMH test and turn on before release
ldapServer.setConfidentialityRequired(false);
// LDAPS is required for the XMPP server (Openfire doesn't support
LDAP StartTLS)
// apacheds.setEnableLdaps(true);
// -----------------------------------------------------------------
// NTLM Configuration Start
// -----------------------------------------------------------------
// Enable NTLM Based Sasl Mechanism w/ Polycom Local Domain Handler
NtlmMechanismHandler ntlmMechanismHandler = new NtlmMechanismHandler();
ntlmMechanismHandler.setNtlmProvider(new JcifsNtlmProvider());
ldapServer.removeSaslMechanismHandler(SupportedSaslMechanisms.NTLM);
ldapServer.addSaslMechanismHandler(SupportedSaslMechanisms.NTLM,
ntlmMechanismHandler);
ldapServer.removeSaslMechanismHandler(SupportedSaslMechanisms.GSS_SPNEGO);
ldapServer.addSaslMechanismHandler(SupportedSaslMechanisms.GSS_SPNEGO,
ntlmMechanismHandler);
// -----------------------------------------------------------------
// NTLM Configuration End
// -----------------------------------------------------------------
StartTlsHandler tls = new StartTlsHandler();
Collection<ExtendedOperationHandler> handlers = new
ArrayList<ExtendedOperationHandler>();
handlers.add(tls);
// ldapServer.addExtendedOperationHandler( tls );
ldapServer.setExtendedOperationHandlers(handlers);
directoryService.setAllowAnonymousAccess(false);
ldapServer.setLdifDirectory(new
File(Environment.getResourcePaths().getLDIFDir()).getAbsoluteFile());
ldapServer.start();
ads = ldapServer;
directoryService.addPartition(makeCMAPartition("ReadiManager
Partition","ou=ReadiManager"));
directoryService.addPartition(makeCMAPartition("ReadiManager
alternate","dc=polycom,dc=com"));