Search in sources :

Example 1 with DirectoryService

use of org.apache.directory.server.core.api.DirectoryService in project qpid-broker-j by apache.

the class SimpleLDAPAuthenticationManagerTest method createPrincipal.

private void createPrincipal(final String sn, final String cn, final String uid, final String userPassword, final String kerberosPrincipalName) throws LdapException {
    final DirectoryService directoryService = LDAP.getDirectoryService();
    final Entry entry = new DefaultEntry(directoryService.getSchemaManager());
    entry.setDn(String.format("uid=%s,%s", uid, USERS_DN));
    entry.add("objectClass", "top", "person", "inetOrgPerson", "krb5principal", "krb5kdcentry");
    entry.add("cn", cn);
    entry.add("sn", sn);
    entry.add("uid", uid);
    entry.add("userPassword", userPassword);
    entry.add("krb5PrincipalName", kerberosPrincipalName);
    entry.add("krb5KeyVersionNumber", "0");
    directoryService.getAdminSession().add(entry);
}
Also used : KeytabEntry(org.apache.directory.server.kerberos.shared.keytab.KeytabEntry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) DirectoryService(org.apache.directory.server.core.api.DirectoryService)

Example 2 with DirectoryService

use of org.apache.directory.server.core.api.DirectoryService in project syncope by apache.

the class ApacheDSRootDseServlet method createEnv.

/**
 * Creates an environment configuration for JNDI access.
 */
private Properties createEnv() {
    // Fetch directory service from servlet context
    ServletContext servletContext = this.getServletContext();
    DirectoryService directoryService = (DirectoryService) servletContext.getAttribute(DirectoryService.JNDI_KEY);
    Properties env = new Properties();
    env.put(DirectoryService.JNDI_KEY, directoryService);
    env.put(Context.PROVIDER_URL, "");
    env.put(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName());
    env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
    env.put(Context.SECURITY_CREDENTIALS, "secret");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    return env;
}
Also used : ServletContext(javax.servlet.ServletContext) DirectoryService(org.apache.directory.server.core.api.DirectoryService) Properties(java.util.Properties) CoreContextFactory(org.apache.directory.server.core.jndi.CoreContextFactory)

Example 3 with DirectoryService

use of org.apache.directory.server.core.api.DirectoryService in project structr by structr.

the class LDAPServerService method initialized.

@Override
public void initialized() {
    try {
        // TEST
        final DirectoryService service = server.getDirectoryService();
        final SchemaManager schemaManager = service.getSchemaManager();
        final Dn structrDn = new Dn(schemaManager, "dc=org");
        final Partition apachePartition = new StructrPartition(schemaManager, "structr", structrDn);
        apachePartition.initialize();
        service.addPartition(apachePartition);
        try {
            service.getAdminSession().lookup(structrDn);
        } catch (LdapException lnnfe) {
            Entry structrEntry = service.newEntry(structrDn);
            structrEntry.add("objectClass", "top", "domain", "extensibleObject");
            structrEntry.add("dc", "structr");
            service.getAdminSession().add(structrEntry);
        }
        try {
            System.out.println("######: " + service.getAdminSession().lookup(structrDn));
            System.out.flush();
        } catch (LdapException lnnfe) {
            logger.warn("", lnnfe);
        }
    } catch (Throwable t) {
        logger.warn("", t);
    }
}
Also used : Partition(org.apache.directory.server.core.api.partition.Partition) SchemaPartition(org.apache.directory.server.core.api.schema.SchemaPartition) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) JarEntry(java.util.jar.JarEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) ZipEntry(java.util.zip.ZipEntry) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) DirectoryService(org.apache.directory.server.core.api.DirectoryService) DefaultDirectoryService(org.apache.directory.server.core.DefaultDirectoryService) Dn(org.apache.directory.api.ldap.model.name.Dn) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 4 with DirectoryService

use of org.apache.directory.server.core.api.DirectoryService in project cloudstack by apache.

the class LdapDirectoryServerConnectionTest method testEmbeddedLdapServerInitialization.

@Test
public void testEmbeddedLdapServerInitialization() throws IndexNotFoundException {
    LdapServer ldapServer = embeddedLdapServer.getLdapServer();
    assertNotNull(ldapServer);
    DirectoryService directoryService = embeddedLdapServer.getDirectoryService();
    assertNotNull(directoryService);
    assertNotNull(directoryService.getSchemaPartition());
    assertNotNull(directoryService.getSystemPartition());
    assertNotNull(directoryService.getSchemaManager());
    assertNotNull(directoryService.getDnFactory());
    assertNotNull(directoryService.isDenormalizeOpAttrsEnabled());
    ChangeLog changeLog = directoryService.getChangeLog();
    assertNotNull(changeLog);
    assertFalse(changeLog.isEnabled());
    assertNotNull(directoryService.isStarted());
    assertNotNull(ldapServer.isStarted());
    List userList = new ArrayList(embeddedLdapServer.getUserIndexMap().keySet());
    java.util.Collections.sort(userList);
    List checkList = Arrays.asList("uid");
    assertEquals(userList, checkList);
}
Also used : LdapServer(org.apache.directory.server.ldap.LdapServer) ArrayList(java.util.ArrayList) DirectoryService(org.apache.directory.server.core.api.DirectoryService) ArrayList(java.util.ArrayList) List(java.util.List) ChangeLog(org.apache.directory.server.core.api.changelog.ChangeLog) Test(org.junit.Test)

Example 5 with DirectoryService

use of org.apache.directory.server.core.api.DirectoryService in project keycloak by keycloak.

the class KerberosEmbeddedServer method createDirectoryService.

@Override
protected DirectoryService createDirectoryService() throws Exception {
    DirectoryService directoryService = super.createDirectoryService();
    directoryService.addLast(new KeyDerivationInterceptor());
    return directoryService;
}
Also used : KeyDerivationInterceptor(org.apache.directory.server.core.kerberos.KeyDerivationInterceptor) DirectoryService(org.apache.directory.server.core.api.DirectoryService)

Aggregations

DirectoryService (org.apache.directory.server.core.api.DirectoryService)6 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)2 Entry (org.apache.directory.api.ldap.model.entry.Entry)2 Partition (org.apache.directory.server.core.api.partition.Partition)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1 JarEntry (java.util.jar.JarEntry)1 ZipEntry (java.util.zip.ZipEntry)1 ServletContext (javax.servlet.ServletContext)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 LdifEntry (org.apache.directory.api.ldap.model.ldif.LdifEntry)1 Dn (org.apache.directory.api.ldap.model.name.Dn)1 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)1 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)1 DefaultDirectoryService (org.apache.directory.server.core.DefaultDirectoryService)1 ChangeLog (org.apache.directory.server.core.api.changelog.ChangeLog)1 Interceptor (org.apache.directory.server.core.api.interceptor.Interceptor)1 SchemaPartition (org.apache.directory.server.core.api.schema.SchemaPartition)1