org.apache.directory.server.core.DirectoryService Java Examples

The following examples show how to use org.apache.directory.server.core.DirectoryService. 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: ApacheKDCServer.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private void setSchemaContext(KdcConfiguration configuration, DirectoryService service,
                              String connectionUser)
        throws DirectoryServerException {
    Hashtable<String, Object> env = new Hashtable<String, Object>();
    env.put(DirectoryService.JNDI_KEY, service);
    env.put(Context.SECURITY_PRINCIPAL, connectionUser);
    env.put(Context.SECURITY_CREDENTIALS, configuration.getSystemAdminPassword());
    env.put(Context.SECURITY_AUTHENTICATION, ConfigurationConstants.SIMPLE_AUTHENTICATION);
    env.put(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName());

    env.put(Context.PROVIDER_URL, SchemaConstants.OU_SCHEMA);

    try {
        schemaRoot = new InitialLdapContext(env, null);
    } catch (NamingException e) {
        throw new DirectoryServerException(
                "Unable to create Schema context with user " + connectionUser, e);
    }

}
 
Example #2
Source File: EmbeddedLdapServer.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
private static Partition addPartition(
    DirectoryService service, String partitionId, String partitionDn) throws Exception {
  final JdbmPartition partition = new JdbmPartition();
  partition.setId(partitionId);
  partition.setPartitionDir(new File(service.getWorkingDirectory(), partitionId));
  partition.setSuffix(partitionDn);
  service.addPartition(partition);
  return partition;
}
 
Example #3
Source File: EmbeddedLdapServer.java    From codenvy with Eclipse Public License 1.0 4 votes vote down vote up
/** Returns service instance of this server. */
public DirectoryService getService() {
  return service;
}
 
Example #4
Source File: ApacheKDCServer.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void init(final KdcConfiguration configuration, LDAPServer ldapServer)
        throws DirectoryServerException {

    if (configuration == null) {
        throw new DirectoryServerException("Could not initialize KDC server. " +
                "KDC configurations are null");
    }

    if (ldapServer == null) {
        throw new DirectoryServerException("Could not initialize KDC server. " +
                "Directory service is null.");
    }

    if (!(ldapServer instanceof ApacheLDAPServer)) {
        throw new DirectoryServerException("Apache KDC server is only compatible with " +
                "ApacheLDAPServer");
    }

    ApacheLDAPServer apacheLDAP = (ApacheLDAPServer) ldapServer;

    this.kdcServer.setServiceName(configuration.getKdcName());
    this.kdcServer.setKdcPrincipal(configuration.getKdcPrinciple());
    this.kdcServer.setPrimaryRealm(configuration.getPrimaryRealm());
    this.kdcServer.setMaximumTicketLifetime(configuration.getMaxTicketLifeTime());
    this.kdcServer.setMaximumRenewableLifetime(configuration.getMaxRenewableLifeTime());
    this.kdcServer.setSearchBaseDn(configuration.getSearchBaseDomainName());
    this.kdcServer.setPaEncTimestampRequired(
            configuration.isPreAuthenticateTimeStampRequired());

    configureTransportHandlers(configuration);

    DirectoryService directoryService = apacheLDAP.getService();

    if (directoryService == null) {
        throw new DirectoryServerException("LDAP service is null. " +
                "Could not configure Kerberos.");
    }

    this.kdcServer.setDirectoryService(directoryService);

    setSchemaContext(configuration, directoryService, ldapServer.getConnectionDomainName());

    enableKerberoseSchema();

}
 
Example #5
Source File: ApacheDirectoryPartitionManager.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public ApacheDirectoryPartitionManager(DirectoryService directoryService, String wd) {
    this.directoryService = directoryService;
    this.workingDirectory = wd;
    this.partitionFactory = new JdbmPartitionFactory();
}
 
Example #6
Source File: CarbonDirectoryServiceFactory.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public DirectoryService getDirectoryService()
        throws Exception {
    return directoryService;
}
 
Example #7
Source File: ApacheLDAPServer.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public DirectoryService getService() {
    return service;
}
 
Example #8
Source File: ApacheLDAPServer.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public void setService(DirectoryService service) {
    this.service = service;
}
 
Example #9
Source File: EmbeddedLdapServer.java    From spring-ldap with Apache License 2.0 4 votes vote down vote up
private EmbeddedLdapServer(DirectoryService directoryService,
                           LdapServer ldapServer) {
    this.directoryService = directoryService;
    this.ldapServer = ldapServer;
}