org.apache.directory.server.annotations.CreateTransport Java Examples

The following examples show how to use org.apache.directory.server.annotations.CreateTransport. 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: LdapRoleMappingG2UTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@BeforeClass
@CreateDS(
        name = "WildFlyDS",
        factory = org.jboss.as.test.integration.mgmt.access.ldap.InMemoryDirectoryServiceFactory.class,
        partitions = @CreatePartition(name = "wildfly", suffix = "dc=wildfly,dc=org"),
        allowAnonAccess = true
)
@CreateLdapServer(
        transports = @CreateTransport(protocol = "LDAP", address = "localhost", port = 10389),
        allowAnonymousAccess = true
)
public static void setUp() throws Exception {
    directoryService = DSAnnotationProcessor.getDirectoryService();
    SchemaManager schemaManager = directoryService.getSchemaManager();
    InputStream ldif = LdapRoleMappingG2UTestCase.class.getResourceAsStream("/" + LdapRoleMappingG2UTestCase.class.getSimpleName() + ".ldif");
    for (LdifEntry ldifEntry : new LdifReader(ldif)) {
        directoryService.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
    }
    ldapServer = ServerAnnotationProcessor.getLdapServer(directoryService);

    startServer();
}
 
Example #2
Source File: LdapRoleMappingU2GTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@BeforeClass
@CreateDS(
        name = "WildFlyDS",
        factory = org.jboss.as.test.integration.mgmt.access.ldap.InMemoryDirectoryServiceFactory.class,
        partitions = @CreatePartition(name = "wildfly", suffix = "dc=wildfly,dc=org"),
        allowAnonAccess = true
)
@CreateLdapServer(
        transports = @CreateTransport(protocol = "LDAP", address = "localhost", port = 10389),
        allowAnonymousAccess = true
)
public static void setUp() throws Exception {
    directoryService = DSAnnotationProcessor.getDirectoryService();
    SchemaManager schemaManager = directoryService.getSchemaManager();
    InputStream ldif = LdapRoleMappingU2GTestCase.class.getResourceAsStream("/" + LdapRoleMappingU2GTestCase.class.getSimpleName() + ".ldif");
    for (LdifEntry ldifEntry : new LdifReader(ldif)) {
        directoryService.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
    }
    ldapServer = ServerAnnotationProcessor.getLdapServer(directoryService);

    startServer();
}
 
Example #3
Source File: OutboundLdapConnectionTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@BeforeClass
@CreateDS(
    name = "WildFlyDS",
    factory = InMemoryDirectoryServiceFactory.class,
    partitions = @CreatePartition(name = "wildfly", suffix = "dc=wildfly,dc=org"),
    allowAnonAccess = true
)
@CreateLdapServer(
    transports = @CreateTransport(protocol = "LDAP", address = "localhost", port = 10389),
    allowAnonymousAccess = true
)
public static void setUpLdap() throws Exception {
    directoryService = DSAnnotationProcessor.getDirectoryService();
    final SchemaManager schemaManager = directoryService.getSchemaManager();
    final InputStream ldif = OutboundLdapConnectionTestCase.class
            .getResourceAsStream("/" + OutboundLdapConnectionTestCase.class.getSimpleName() + ".ldif");
    for (LdifEntry ldifEntry : new LdifReader(ldif)) {
        directoryService.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
    }
    ldapServer = ServerAnnotationProcessor.getLdapServer(directoryService);
}
 
Example #4
Source File: KDCServerAnnotationProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Transport createTransport( CreateTransport transportBuilder, int startPort ) {
    String protocol = transportBuilder.protocol();
    int port = transportBuilder.port();
    int nbThreads = transportBuilder.nbThreads();
    int backlog = transportBuilder.backlog();
    String address = transportBuilder.address();

    if ( port == -1 )
    {
        port = AvailablePortFinder.getNextAvailable( startPort );
        startPort = port + 1;
    }

    if ( protocol.equalsIgnoreCase( "TCP" ) )
    {
        Transport tcp = new TcpTransport( address, port, nbThreads, backlog );
        return tcp;
    }
    else if ( protocol.equalsIgnoreCase( "UDP" ) )
    {
        UdpTransport udp = new UdpTransport( address, port );
        return udp;
    }
    else
    {
        throw new IllegalArgumentException( I18n.err( I18n.ERR_689, protocol ) );
    }
}
 
Example #5
Source File: KerberosTestUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Fixes/replaces LDAP bind address in the CreateTransport annotation of ApacheDS.
 *
 * @param createLdapServer
 * @param address
 */
public static void fixApacheDSTransportAddress(ManagedCreateLdapServer createLdapServer, String address) {
    final CreateTransport[] createTransports = createLdapServer.transports();
    for (int i = 0; i < createTransports.length; i++) {
        final ManagedCreateTransport mgCreateTransport = new ManagedCreateTransport(createTransports[i]);
        // localhost is a default used in original CreateTransport annotation. We use it as a fallback.
        mgCreateTransport.setAddress(address != null ? address : "localhost");
        createTransports[i] = mgCreateTransport;
    }
}
 
Example #6
Source File: ManagedCreateTransport.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a new ManagedCreateTransport.
 *
 * @param createLdapServer
 */
public ManagedCreateTransport(final CreateTransport original) {
    protocol = original.protocol();
    type = original.type();
    port = original.port();
    address = original.address();
    backlog = original.backlog();
    ssl = original.ssl();
    nbThreads = original.nbThreads();
}
 
Example #7
Source File: AbstractKerberosMgmtSaslTestBase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Fixes/replaces LDAP bind address in the CreateTransport annotation of ApacheDS.
 *
 * @param createLdapServer
 * @param address
 */
public static void fixApacheDSTransportAddress(ManagedCreateLdapServer createLdapServer, String address) {
    final CreateTransport[] createTransports = createLdapServer.transports();
    for (int i = 0; i < createTransports.length; i++) {
        final ManagedCreateTransport mgCreateTransport = new ManagedCreateTransport(createTransports[i]);
        // localhost is a default used in original CreateTransport annotation. We use it as a fallback.
        mgCreateTransport.setAddress(address != null ? address : "localhost");
        createTransports[i] = mgCreateTransport;
    }
}
 
Example #8
Source File: ManagedCreateLdapServer.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 *
 * @return
 * @see org.apache.directory.server.annotations.CreateLdapServer#transports()
 */
public CreateTransport[] transports() {
    return transports;
}
 
Example #9
Source File: ManagedCreateLdapServer.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Set the transports.
 *
 * @param transports The transports to set.
 */
public void setTransports(CreateTransport[] transports) {
    this.transports = transports;
}