org.apache.directory.server.core.kerberos.KeyDerivationInterceptor Java Examples

The following examples show how to use org.apache.directory.server.core.kerberos.KeyDerivationInterceptor. 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: KerberosKDCUtil.java    From quarkus-http with Apache License 2.0 8 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());
    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", LDAP_PORT, 3, 5 );
    ldapServer.addTransports(ldap);
    ldapServer.setDirectoryService(directoryService);
    ldapServer.start();
}
 
Example #2
Source File: ApacheLDAPServer.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private void configureDirectoryService()
        throws NamingException, DirectoryServerException {

    if (null == this.ldapConfigurations) {
        throw new DirectoryServerException("Directory service is not initialized.");
    }

    System.setProperty("workingDirectory", this.ldapConfigurations.getWorkingDirectory());

    this.service.setShutdownHookEnabled(false);

    this.service.setInstanceId(this.ldapConfigurations.getInstanceId());
    this.service.setAllowAnonymousAccess(this.ldapConfigurations.isAllowAnonymousAccess());
    this.service.setAccessControlEnabled(this.ldapConfigurations.isAccessControlOn());
    this.service.setDenormalizeOpAttrsEnabled(
            this.ldapConfigurations.isDeNormalizedAttributesEnabled());
    this.service.setMaxPDUSize(this.ldapConfigurations.getMaxPDUSize());

    this.service.getChangeLog().setEnabled(this.ldapConfigurations.isChangeLogEnabled());

    // Add interceptors
    List<Interceptor> list = this.service.getInterceptors();
    list.add(new KeyDerivationInterceptor());
    this.service.setInterceptors(list);

}
 
Example #3
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 #4
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 #5
Source File: KerberosEmbeddedServer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
protected DirectoryService createDirectoryService() throws Exception {
    DirectoryService directoryService = super.createDirectoryService();

    directoryService.addLast(new KeyDerivationInterceptor());
    return directoryService;
}
 
Example #6
Source File: MiniKdc.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void initDirectoryService() throws Exception {
  ds = new DefaultDirectoryService();
  ds.setInstanceLayout(new InstanceLayout(workDir));

  CacheService cacheService = new CacheService();
  ds.setCacheService(cacheService);

  // first load the schema
  InstanceLayout instanceLayout = ds.getInstanceLayout();
  File schemaPartitionDirectory = new File(
          instanceLayout.getPartitionsDirectory(), "schema");
  SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(
          instanceLayout.getPartitionsDirectory());
  extractor.extractOrCopy();

  SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
  SchemaManager schemaManager = new DefaultSchemaManager(loader);
  schemaManager.loadAllEnabled();
  ds.setSchemaManager(schemaManager);
  // Init the LdifPartition with schema
  LdifPartition schemaLdifPartition = new LdifPartition(schemaManager);
  schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

  // The schema partition
  SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
  schemaPartition.setWrappedPartition(schemaLdifPartition);
  ds.setSchemaPartition(schemaPartition);

  JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager());
  systemPartition.setId("system");
  systemPartition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(),
          systemPartition.getId()).toURI());
  systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
  systemPartition.setSchemaManager(ds.getSchemaManager());
  ds.setSystemPartition(systemPartition);

  ds.getChangeLog().setEnabled(false);
  ds.setDenormalizeOpAttrsEnabled(true);
  ds.addLast(new KeyDerivationInterceptor());

  // create one partition
  String orgName= conf.getProperty(ORG_NAME).toLowerCase(Locale.ENGLISH);
  String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase(Locale.ENGLISH);

  JdbmPartition partition = new JdbmPartition(ds.getSchemaManager());
  partition.setId(orgName);
  partition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI());
  partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain));
  ds.addPartition(partition);
  // indexes
  Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>();
  indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false));
  partition.setIndexedAttributes(indexedAttributes);

  // And start the ds
  ds.setInstanceId(conf.getProperty(INSTANCE));
  ds.startup();
  // context entry, after ds.startup()
  Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain);
  Entry entry = ds.newEntry(dn);
  entry.add("objectClass", "top", "domain");
  entry.add("dc", orgName);
  ds.getAdminSession().add(entry);
}
 
Example #7
Source File: MiniKdc.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void initDirectoryService() throws Exception {
  ds = new DefaultDirectoryService();
  ds.setInstanceLayout(new InstanceLayout(workDir));

  CacheService cacheService = new CacheService();
  ds.setCacheService(cacheService);

  // first load the schema
  InstanceLayout instanceLayout = ds.getInstanceLayout();
  File schemaPartitionDirectory = new File(
          instanceLayout.getPartitionsDirectory(), "schema");
  SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(
          instanceLayout.getPartitionsDirectory());
  extractor.extractOrCopy();

  SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
  SchemaManager schemaManager = new DefaultSchemaManager(loader);
  schemaManager.loadAllEnabled();
  ds.setSchemaManager(schemaManager);
  // Init the LdifPartition with schema
  LdifPartition schemaLdifPartition = new LdifPartition(schemaManager);
  schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

  // The schema partition
  SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
  schemaPartition.setWrappedPartition(schemaLdifPartition);
  ds.setSchemaPartition(schemaPartition);

  JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager());
  systemPartition.setId("system");
  systemPartition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(),
          systemPartition.getId()).toURI());
  systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
  systemPartition.setSchemaManager(ds.getSchemaManager());
  ds.setSystemPartition(systemPartition);

  ds.getChangeLog().setEnabled(false);
  ds.setDenormalizeOpAttrsEnabled(true);
  ds.addLast(new KeyDerivationInterceptor());

  // create one partition
  String orgName= conf.getProperty(ORG_NAME).toLowerCase(Locale.ENGLISH);
  String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase(Locale.ENGLISH);

  JdbmPartition partition = new JdbmPartition(ds.getSchemaManager());
  partition.setId(orgName);
  partition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI());
  partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain));
  ds.addPartition(partition);
  // indexes
  Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>();
  indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false));
  partition.setIndexedAttributes(indexedAttributes);

  // And start the ds
  ds.setInstanceId(conf.getProperty(INSTANCE));
  ds.startup();
  // context entry, after ds.startup()
  Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain);
  Entry entry = ds.newEntry(dn);
  entry.add("objectClass", "top", "domain");
  entry.add("dc", orgName);
  ds.getAdminSession().add(entry);
}