Java Code Examples for org.apache.directory.server.ldap.LdapServer#loadKeyStore()

The following examples show how to use org.apache.directory.server.ldap.LdapServer#loadKeyStore() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApacheDirectoryServer.java    From light-oauth2 with Apache License 2.0 5 votes vote down vote up
private static void startLdapServer() throws Exception {
    createWorkingDir();
    DirectoryServiceFactory dsf = new DefaultDirectoryServiceFactory();
    dsf.init(DIRECTORY_NAME);
    directoryService = dsf.getDirectoryService();
    directoryService.addLast(new KeyDerivationInterceptor()); // Derives the Kerberos keys for new entries.
    directoryService.getChangeLog().setEnabled(false);
    SchemaManager schemaManager = directoryService.getSchemaManager();

    createPartition(dsf, schemaManager, "users", "ou=users,dc=undertow,dc=io");

    CoreSession adminSession = directoryService.getAdminSession();
    //Map<String, String> mappings = Collections.singletonMap("hostname", DefaultServer.getDefaultServerAddress().getHostString());
    Map<String, String> mappings = Collections.singletonMap("hostname", "localhost");
    processLdif(schemaManager, adminSession, "partition.ldif", mappings);
    processLdif(schemaManager, adminSession, "krbtgt.ldif", mappings);
    processLdif(schemaManager, adminSession, "user.ldif", mappings);
    processLdif(schemaManager, adminSession, "server.ldif", mappings);

    ldapServer = new LdapServer();
    ldapServer.setServiceName("DefaultLDAP");
    Transport ldap = new TcpTransport( "0.0.0.0", LDAPS_PORT, 3, 5 );
    ldap.enableSSL(true);
    ldapServer.addTransports(ldap);
    ldapServer.setKeystoreFile(ApacheDirectoryServer.class.getResource("/config/server.keystore").getFile());
    ldapServer.setCertificatePassword("password");
    ldapServer.loadKeyStore();
    ldapServer.setDirectoryService(directoryService);
    ldapServer.start();
}
 
Example 2
Source File: ApacheDirectoryServer.java    From light-oauth2 with Apache License 2.0 5 votes vote down vote up
private static void startLdapServer() throws Exception {
    createWorkingDir();
    DirectoryServiceFactory dsf = new DefaultDirectoryServiceFactory();
    dsf.init(DIRECTORY_NAME);
    directoryService = dsf.getDirectoryService();
    directoryService.addLast(new KeyDerivationInterceptor()); // Derives the Kerberos keys for new entries.
    directoryService.getChangeLog().setEnabled(false);
    SchemaManager schemaManager = directoryService.getSchemaManager();

    createPartition(dsf, schemaManager, "users", "ou=users,dc=undertow,dc=io");

    CoreSession adminSession = directoryService.getAdminSession();
    //Map<String, String> mappings = Collections.singletonMap("hostname", DefaultServer.getDefaultServerAddress().getHostString());
    Map<String, String> mappings = Collections.singletonMap("hostname", "localhost");
    processLdif(schemaManager, adminSession, "partition.ldif", mappings);
    processLdif(schemaManager, adminSession, "krbtgt.ldif", mappings);
    processLdif(schemaManager, adminSession, "user.ldif", mappings);
    processLdif(schemaManager, adminSession, "server.ldif", mappings);

    ldapServer = new LdapServer();
    ldapServer.setServiceName("DefaultLDAP");
    Transport ldap = new TcpTransport( "0.0.0.0", LDAPS_PORT, 3, 5 );
    ldap.enableSSL(true);
    ldapServer.addTransports(ldap);
    ldapServer.setKeystoreFile(ApacheDirectoryServer.class.getResource("/config/server.keystore").getFile());
    ldapServer.setCertificatePassword("password");
    ldapServer.loadKeyStore();
    ldapServer.setDirectoryService(directoryService);
    ldapServer.start();
}