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

The following examples show how to use org.apache.directory.server.ldap.LdapServer#setTransports() . 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: EmbeddedLdapServer.java    From codenvy with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: TestLdapUserGroup.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
	LdapServer ldapServer = new LdapServer();
	ldapServer.setSaslHost("127.0.0.1");
	ldapServer.setSearchBaseDn("DC=ranger,DC=qe,DC=hortonworks,DC=com");
	String ldapPort = System.getProperty("ldap.port");
	Assert.assertNotNull("Property 'ldap.port' null", ldapPort);
	ldapServer.setTransports(new TcpTransport("127.0.0.1", Integer.parseInt(ldapPort)));
	ldapServer.setDirectoryService(getService());
	ldapServer.setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
	setLdapServer(ldapServer);
	getService().startup();
	getLdapServer().start();
	config = UserGroupSyncConfig.getInstance();	
	ldapBuilder = new LdapUserGroupBuilder();
}
 
Example 3
Source File: ApacheDSContainerWithSecurity.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
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();
	}
 
Example 4
Source File: LDAPServer.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 5
Source File: EmbeddedLDAPServer.java    From cukes with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 6
Source File: EmbeddedADS.java    From vertx-auth with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 7
Source File: Runner.java    From aws-iam-ldap-bridge with Apache License 2.0 5 votes vote down vote up
/**
 * starts the LdapServer
 *
 * @throws Exception
 */
public void startServer() throws Exception
{
    server = new LdapServer();

    server.setTransports( new TcpTransport( serverPort ) );
    server.setDirectoryService( service );

    server.start();
}
 
Example 8
Source File: SpliceTestKDCPlatform.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
public void startLdapServer(MiniKdc miniKdc) throws Exception {
    ldapServer = new LdapServer();
    Field f = MiniKdc.class.getDeclaredField("ds");
    f.setAccessible(true);
    DirectoryService ds = (DirectoryService) f.get(miniKdc);
    ldapServer.setDirectoryService(ds);
    TcpTransport tcpTransport = new TcpTransport(4016);
    ldapServer.setTransports(tcpTransport);
    LOG.info(ds.getAdminSession().getAuthenticatedPrincipal().getDn());
    ldapServer.start();
}
 
Example 9
Source File: EmbeddedLdapServer.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
public static EmbeddedLdapServer newEmbeddedServer(String defaultPartitionName, String defaultPartitionSuffix, int port)
        throws Exception{
    workingDirectory = new File(System.getProperty("java.io.tmpdir") + "/apacheds-test1");
    FileUtils.deleteDirectory(workingDirectory);

    DefaultDirectoryService directoryService = new DefaultDirectoryService();
    directoryService.setShutdownHookEnabled(true);
    directoryService.setAllowAnonymousAccess(true);

    directoryService.setWorkingDirectory(workingDirectory);
    directoryService.getChangeLog().setEnabled( false );

    JdbmPartition partition = new JdbmPartition();
    partition.setId(defaultPartitionName);
    partition.setSuffix(defaultPartitionSuffix);
    directoryService.addPartition(partition);

    directoryService.startup();

    // Inject the apache root entry if it does not already exist
    if ( !directoryService.getAdminSession().exists( partition.getSuffixDn() ) )
    {
        ServerEntry entry = directoryService.newEntry(new LdapDN(defaultPartitionSuffix));
        entry.add("objectClass", "top", "domain", "extensibleObject");
        entry.add("dc", defaultPartitionName);
        directoryService.getAdminSession().add( entry );
    }

    LdapServer ldapServer = new LdapServer();
    ldapServer.setDirectoryService(directoryService);

    TcpTransport ldapTransport = new TcpTransport(port);
    ldapServer.setTransports( ldapTransport );
    ldapServer.start();

    return new EmbeddedLdapServer(directoryService, ldapServer);
}
 
Example 10
Source File: LdapTestEnvironment.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * starts the LdapServer
 *
 * @throws Exception
 */
public void startServer() throws Exception {
  ldapService = new LdapServer();
  Properties properties = loadTestProperties();
  String port = properties.getProperty("ldap.server.port");
  ldapService.setTransports(new TcpTransport(Integer.parseInt(port)));
  ldapService.setDirectoryService(service);
  ldapService.start();
}