当前位置: 首页>>代码示例>>Java>>正文


Java LdapServer类代码示例

本文整理汇总了Java中org.apache.directory.server.ldap.LdapServer的典型用法代码示例。如果您正苦于以下问题:Java LdapServer类的具体用法?Java LdapServer怎么用?Java LdapServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LdapServer类属于org.apache.directory.server.ldap包,在下文中一共展示了LdapServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
public static IoFilterChainBuilder init( LdapServer server ) throws LdapException
{
    SSLContext sslCtx;
    try
    {
    	sslCtx = server.getSSLContext();
    	
    }
    catch ( Exception e )
    {
        throw new LdapException( I18n.err( I18n.ERR_683 ), e );
    }

    DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
    SslFilter sslFilter = new SslFilter( sslCtx );

    List<String> cipherSuites = server.getEnabledCipherSuites();
    if( ( cipherSuites != null ) && !cipherSuites.isEmpty() )
    {
        sslFilter.setEnabledCipherSuites( cipherSuites.toArray( new String[cipherSuites.size()] ) );
    }
    
    sslFilter.setWantClientAuth( true );
    chain.addLast( "sslFilter", sslFilter );
    return chain;
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:27,代码来源:LdapsInitializer.java

示例2: setUp

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
/**
 * Get's the initial context factory for the provider's ou=system context root.
 *
 * @throws Exception
 *             if there is a failure of any kind
 */
protected void setUp() throws Exception {
    setStart(getStart() + 1);
    setDirectoryService(new DefaultDirectoryService());
    getDirectoryService().setShutdownHookEnabled(false);
    setPort(AvailablePortFinder.getNextAvailable(1024));
    setLdapServer(new LdapServer());
    getLdapServer().setTransports(new TcpTransport(getPort()));
    getLdapServer().setDirectoryService(getDirectoryService());

    setupSaslMechanisms(getLdapServer());
    getDirectoryService().setWorkingDirectory(
            new File("target" + File.separator + "server-work"));
    doDelete(getDirectoryService().getWorkingDirectory());
    configureDirectoryService();
    getDirectoryService().startup();

    configureLdapServer();

    // TODO shouldn't this be before calling configureLdapServer() ???
    getLdapServer().addExtendedOperationHandler(new StartTlsHandler());
    getLdapServer().addExtendedOperationHandler(new StoredProcedureExtendedOperationHandler());

    getLdapServer().start();
    setContexts(ServerDNConstants.ADMIN_SYSTEM_DN, "secret");
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:32,代码来源:AbstractApacheDSServer.java

示例3: setupSaslMechanisms

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
/**
 * @param server
 *            The server
 */
private void setupSaslMechanisms(LdapServer server) {
    HashMap<String, MechanismHandler> mechanismHandlerMap = new HashMap<String, MechanismHandler>();

    mechanismHandlerMap.put(SupportedSaslMechanisms.PLAIN, new PlainMechanismHandler());

    CramMd5MechanismHandler cramMd5MechanismHandler = new CramMd5MechanismHandler();
    mechanismHandlerMap.put(SupportedSaslMechanisms.CRAM_MD5, cramMd5MechanismHandler);

    DigestMd5MechanismHandler digestMd5MechanismHandler = new DigestMd5MechanismHandler();
    mechanismHandlerMap.put(SupportedSaslMechanisms.DIGEST_MD5, digestMd5MechanismHandler);

    GssapiMechanismHandler gssapiMechanismHandler = new GssapiMechanismHandler();
    mechanismHandlerMap.put(SupportedSaslMechanisms.GSSAPI, gssapiMechanismHandler);

    NtlmMechanismHandler ntlmMechanismHandler = new NtlmMechanismHandler();
    // TODO - set some sort of default NtlmProvider implementation here
    // ntlmMechanismHandler.setNtlmProvider( provider );
    // TODO - or set FQCN of some sort of default NtlmProvider implementation here
    // ntlmMechanismHandler.setNtlmProviderFqcn( "com.foo.BarNtlmProvider" );
    mechanismHandlerMap.put(SupportedSaslMechanisms.NTLM, ntlmMechanismHandler);
    mechanismHandlerMap.put(SupportedSaslMechanisms.GSS_SPNEGO, ntlmMechanismHandler);

    getLdapServer().setSaslMechanismHandlers(mechanismHandlerMap);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:29,代码来源:AbstractApacheDSServer.java

示例4: EmbeddedLdapServer

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
public EmbeddedLdapServer(
    File workingDir,
    String partitionDn,
    String partitionId,
    int port,
    boolean enableChangelog,
    boolean allowAnonymousAccess,
    long maxSizeLimit)
    throws Exception {
  requireNonNull(partitionDn, "Required non-null partition dn");
  requireNonNull(partitionId, "Required non-null partition id");
  this.workingDir = workingDir;
  this.baseDn = new DN(partitionDn);
  this.port = port > 0 ? port : PORT_SERVICE.acquire();
  this.url = "ldap://localhost:" + this.port;
  ldapServer = new LdapServer();
  ldapServer.setTransports(new TcpTransport(this.port));
  if (maxSizeLimit > 0) {
    ldapServer.setMaxSizeLimit(maxSizeLimit);
  }
  service =
      initDirectoryService(
          workingDir, partitionId, partitionDn, enableChangelog, allowAnonymousAccess);
  ldapServer.setDirectoryService(service);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:26,代码来源:EmbeddedLdapServer.java

示例5: afterPropertiesSet

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {

		if (this.enabledLdapOverSsl && this.keyStoreFile == null) {
			throw new IllegalArgumentException("When LdapOverSsl is enabled, the keyStoreFile property must be set.");
		}

		if (workingDir == null) {
			String apacheWorkDir = System.getProperty("apacheDSWorkDir");

			if (apacheWorkDir == null) {
				apacheWorkDir = createTempDirectory("apacheds-spring-security-");
			}

			setWorkingDirectory(new File(apacheWorkDir));
		}

		server = new LdapServer();

		// AbstractLdapIntegrationTests assume IPv4, so we specify the same here
		TcpTransport transport = new TcpTransport(port);

		if (enabledLdapOverSsl) {
			transport.setEnableSSL(true);
			server.setKeystoreFile(this.keyStoreFile.getAbsolutePath());
			server.setCertificatePassword(this.keyStorePassword);
		}

		server.setTransports(transport);
		server.setDirectoryService(service);
		start();
	}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:32,代码来源:ApacheDSContainerWithSecurity.java

示例6: addTcpServer

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
/**
 * Adds a TCP server to the directory service.
 *
 * Note: The TCP server is not started until start() is called on this Builder.
 *
 * @param serviceName - The name of this server.
 * @param hostName - The host name to listen on.
 * @param port - The port to listen on.
 * @return This Builder for subsequent changes.
 */
public Builder addTcpServer(final String serviceName, final String hostName, final int port, final String keyStore, final String keyStorePassword) throws URISyntaxException {
    assertNotStarted();
    if (directoryService == null) {
        throw new IllegalStateException("The Directory service has not been created.");
    }

    LdapServer server = new LdapServer();
    server.setServiceName(serviceName);
    Transport ldaps = new TcpTransport( hostName, port, 3, 5 );
    ldaps.enableSSL(true);
    server.addTransports(ldaps);
    server.setKeystoreFile(getClass().getResource(keyStore).getFile());
    server.setCertificatePassword(keyStorePassword);
    server.setDirectoryService(directoryService);
    servers.add(server);

    return this;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:29,代码来源:LdapService.java

示例7: startMasterLdapServer

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
private static void startMasterLdapServer() throws Exception {
    masterWorkingDir = createWorkingDir(masterWorkingDir, "master");
    DirectoryServiceFactory dsf = new InMemoryDirectoryServiceFactory();
    dsf.init(MASTER_DIRECTORY_NAME);
    masterDirectoryService = dsf.getDirectoryService();
    masterDirectoryService.getChangeLog().setEnabled(false);
    SchemaManager schemaManager = masterDirectoryService.getSchemaManager();

    createPartition(dsf, schemaManager, "simple", "dc=simple,dc=wildfly,dc=org", masterDirectoryService, masterWorkingDir);
    createPartition(dsf, schemaManager, "group-to-principal", "dc=group-to-principal,dc=wildfly,dc=org", masterDirectoryService, masterWorkingDir);
    createPartition(dsf, schemaManager, "principal-to-group", "dc=principal-to-group,dc=wildfly,dc=org", masterDirectoryService, masterWorkingDir);

    CoreSession adminSession = masterDirectoryService.getAdminSession();
    processLdif(schemaManager, adminSession, "memberOf-schema.ldif");
    processLdif(schemaManager, adminSession, "simple-partition.ldif");
    processLdif(schemaManager, adminSession, "group-to-principal.ldif");
    processLdif(schemaManager, adminSession, "principal-to-group.ldif");

    masterLdapServer = new LdapServer();
    masterLdapServer.setServiceName("DefaultLDAP");
    Transport ldap = new TcpTransport( "0.0.0.0", MASTER_LDAP_PORT, 3, 5 );
    masterLdapServer.addTransports(ldap);
    masterLdapServer.setDirectoryService(masterDirectoryService);
    masterLdapServer.start();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:LdapTestSuite.java

示例8: startSlaveLdapServer

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
private static void startSlaveLdapServer() throws Exception {
    slaveWorkingDir = createWorkingDir(slaveWorkingDir, "slave");
    DirectoryServiceFactory dsf = new InMemoryDirectoryServiceFactory();
    dsf.init(SLAVE_DIRECTORY_NAME);
    slaveDirectoryService = dsf.getDirectoryService();
    slaveDirectoryService.getChangeLog().setEnabled(false);
    SchemaManager schemaManager = slaveDirectoryService.getSchemaManager();

    createPartition(dsf, schemaManager, "simple", "dc=simple,dc=wildfly,dc=org", slaveDirectoryService, slaveWorkingDir);
    createPartition(dsf, schemaManager, "group-to-principal", "dc=group-to-principal,dc=wildfly,dc=org", slaveDirectoryService, slaveWorkingDir);
    createPartition(dsf, schemaManager, "principal-to-group", "dc=principal-to-group,dc=wildfly,dc=org", slaveDirectoryService, slaveWorkingDir);

    CoreSession adminSession = slaveDirectoryService.getAdminSession();
    processLdif(schemaManager, adminSession, "memberOf-schema.ldif");
    processLdif(schemaManager, adminSession, "simple-partition-slave.ldif");
    processLdif(schemaManager, adminSession, "group-to-principal-slave.ldif");
    processLdif(schemaManager, adminSession, "principal-to-group-slave.ldif");

    slaveLdapServer = new LdapServer();
    slaveLdapServer.setServiceName("DefaultLDAP");
    Transport ldap = new TcpTransport( "0.0.0.0", SLAVE_LDAP_PORT, 3, 5 );
    slaveLdapServer.addTransports(ldap);
    slaveLdapServer.setDirectoryService(slaveDirectoryService);
    slaveLdapServer.start();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:LdapTestSuite.java

示例9: ApacheDS

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
private ApacheDS(String realm, String baseDn) {
  this.realm = realm;
  this.baseDn = baseDn;
  directoryService = new DefaultDirectoryService();
  ldapServer = new LdapServer();
  kdcServer = new KdcServer();
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-activedirectory,代码行数:8,代码来源:ApacheDS.java

示例10: stopService

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
/** stops the LdapServer */
public void stopService() throws Exception {
  final LdapServer server = this.server;
  if (server != null && server.isStarted()) {
    server.stop();
  }
  service.shutdown();
  FileUtils.deleteQuietly(service.getWorkingDirectory());
  // null the singleton instance
  instance = null;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:12,代码来源:LdapTestServer.java

示例11: contextInitialized

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
/**
 * Startup ApacheDS embedded.
 *
 * @param sce ServletContext event
 */
@Override
public void contextInitialized(final ServletContextEvent sce) {
    File workDir = (File) sce.getServletContext().getAttribute(
            "javax.servlet.context.tempdir");
    workDir = new File(workDir, "server-work");
    if (!workDir.mkdirs()) {
        throw new RuntimeException("Could not create " + workDir.
                getAbsolutePath());
    }

    Entry result;
    try {
        initDirectoryService(sce.getServletContext(), workDir);

        server = new LdapServer();
        server.setTransports(new TcpTransport(Integer.valueOf(
                sce.getServletContext().
                getInitParameter("testds.port"))));
        server.setDirectoryService(service);

        server.start();

        // store directoryService in context to provide it to servlets etc.
        sce.getServletContext().setAttribute(DirectoryService.JNDI_KEY,
                service);

        result = service.getAdminSession().lookup(new DN("o=isp"));
    } catch (Exception e) {
        sce.getServletContext().log("Fatal error in context init", e);
        throw new RuntimeException(e);
    }

    if (result == null) {
        throw new RuntimeException("Base DN not found");
    } else {
        sce.getServletContext().log(
                "ApacheDS startup completed succesfully");
    }
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:45,代码来源:ApacheDSStartStopListener.java

示例12: startServer

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
/**
 * starts the LdapServer
 *
 * @throws Exception
 */
public void startServer() throws Exception {
	server = new LdapServer();
	int serverPort = 10389;
	server.setTransports(new TcpTransport(serverPort));
	server.setDirectoryService(service);

	server.start();
}
 
开发者ID:OWASP,项目名称:Benchmark,代码行数:14,代码来源:LDAPServer.java

示例13: start

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
public void start() throws Exception {
    DirectoryServiceFactory factory = new DefaultDirectoryServiceFactory();
    factory.init("server");
    service = factory.getDirectoryService();
    service.addPartition(createPartition("default", "cn=test"));
    service.addPartition(createPartition("domain", "dc=example,dc=com"));

    server = new LdapServer();
    server.setDirectoryService(service);
    server.setTransports(new TcpTransport(PORT));
    server.start();
}
 
开发者ID:ctco,项目名称:cukes,代码行数:13,代码来源:EmbeddedLDAPServer.java

示例14: initializeLDAPServer

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
protected void initializeLDAPServer()
        throws DirectoryServerException {

    if (null == this.service || null == this.ldapConfigurations) {
        throw new DirectoryServerException(
                "The default apacheds service is not initialized. " +
                        "Make sure apacheds service is initialized first.");
    }

    this.ldapServer = new LdapServer();

    this.ldapServer.setTransports(new TcpTransport(this.ldapConfigurations.getLdapPort()));

    // set server initial properties
    this.ldapServer.setAllowAnonymousAccess(false);
    this.ldapServer.setMaxTimeLimit(this.ldapConfigurations.getMaxTimeLimit());
    this.ldapServer.setMaxSizeLimit(this.ldapConfigurations.getMaxSizeLimit());
    this.ldapServer.setSaslHost(this.ldapConfigurations.getSaslHostName());
    this.ldapServer.setSaslPrincipal(this.ldapConfigurations.getSaslPrincipalName());

    // add the apacheds service
    this.ldapServer.setDirectoryService(this.service);

    setupSaslMechanisms();

    try {
        this.ldapServer.addExtendedOperationHandler(new StartTlsHandler());
        this.ldapServer.addExtendedOperationHandler(
                new StoredProcedureExtendedOperationHandler());
    } catch (Exception e) {
        throw new DirectoryServerException("can not add the extension handlers ", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:34,代码来源:ApacheLDAPServer.java

示例15: contextInitialized

import org.apache.directory.server.ldap.LdapServer; //导入依赖的package包/类
/**
 * Startup ApacheDS embedded.
 *
 * @param sce ServletContext event
 */
@Override
public void contextInitialized(final ServletContextEvent sce) {
    File workDir = (File) sce.getServletContext().getAttribute("javax.servlet.context.tempdir");
    workDir = new File(workDir, "server-work");

    final boolean loadDefaultContent = !workDir.exists();

    if (loadDefaultContent && !workDir.mkdirs()) {
        throw new RuntimeException("Could not create " + workDir.getAbsolutePath());
    }

    Entry result;
    try {
        initDirectoryService(sce.getServletContext(), workDir, loadDefaultContent);

        server = new LdapServer();
        server.setTransports(new TcpTransport(Integer.parseInt(
                WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext()).
                getBean("testds.port", String.class))));
        server.setDirectoryService(service);

        server.start();

        // store directoryService in context to provide it to servlets etc.
        sce.getServletContext().setAttribute(DirectoryService.JNDI_KEY, service);

        result = service.getAdminSession().lookup(new Dn("o=isp"));
    } catch (Exception e) {
        LOG.error("Fatal error in context init", e);
        throw new RuntimeException(e);
    }

    if (result == null) {
        throw new RuntimeException("Base DN not found");
    } else {
        LOG.info("ApacheDS startup completed succesfully");
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:44,代码来源:ApacheDSStartStopListener.java


注:本文中的org.apache.directory.server.ldap.LdapServer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。