use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project undertow by undertow-io.
the class KerberosKDCUtil method startLdapServer.
private static void startLdapServer() throws Exception {
createWorkingDir();
DirectoryServiceFactory dsf = new DefaultDirectoryServiceFactory();
dsf.init(DIRECTORY_NAME);
directoryService = dsf.getDirectoryService();
// Derives the Kerberos keys for new entries.
directoryService.addLast(new KeyDerivationInterceptor());
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();
}
use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project wildfly by wildfly.
the class NoReplayKdcServer method createTransport.
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));
}
}
use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project wildfly by wildfly.
the class NoReplayKdcServer method createKdcServer.
// Private methods -------------------------------------------------------
/**
* Creates and starts {@link KdcServer} instance based on given configuration.
*
* @param createKdcServer
* @param directoryService
* @param startPort
* @return
*/
private static KdcServer createKdcServer(CreateKdcServer createKdcServer, DirectoryService directoryService, int startPort, String bindAddress) {
if (createKdcServer == null) {
return null;
}
KerberosConfig kdcConfig = new KerberosConfig();
kdcConfig.setServicePrincipal(createKdcServer.kdcPrincipal());
kdcConfig.setPrimaryRealm(createKdcServer.primaryRealm());
kdcConfig.setMaximumTicketLifetime(createKdcServer.maxTicketLifetime());
kdcConfig.setMaximumRenewableLifetime(createKdcServer.maxRenewableLifetime());
kdcConfig.setPaEncTimestampRequired(false);
KdcServer kdcServer = new NoReplayKdcServer(kdcConfig);
kdcServer.setSearchBaseDn(createKdcServer.searchBaseDn());
CreateTransport[] transportBuilders = createKdcServer.transports();
if (transportBuilders == null) {
// create only UDP transport if none specified
UdpTransport defaultTransport = new UdpTransport(bindAddress, AvailablePortFinder.getNextAvailable(startPort));
kdcServer.addTransports(defaultTransport);
} else if (transportBuilders.length > 0) {
for (CreateTransport transportBuilder : transportBuilders) {
String protocol = transportBuilder.protocol();
int port = transportBuilder.port();
int nbThreads = transportBuilder.nbThreads();
int backlog = transportBuilder.backlog();
final String address = bindAddress != null ? bindAddress : transportBuilder.address();
if (port == -1) {
port = AvailablePortFinder.getNextAvailable(startPort);
startPort = port + 1;
}
if (protocol.equalsIgnoreCase("TCP")) {
Transport tcp = new TcpTransport(address, port, nbThreads, backlog);
kdcServer.addTransports(tcp);
} else if (protocol.equalsIgnoreCase("UDP")) {
UdpTransport udp = new UdpTransport(address, port);
kdcServer.addTransports(udp);
} else {
throw new IllegalArgumentException(I18n.err(I18n.ERR_689, protocol));
}
}
}
CreateChngPwdServer[] createChngPwdServers = createKdcServer.chngPwdServer();
if (createChngPwdServers.length > 0) {
CreateChngPwdServer createChngPwdServer = createChngPwdServers[0];
ChangePasswordConfig config = new ChangePasswordConfig(kdcConfig);
config.setServicePrincipal(createChngPwdServer.srvPrincipal());
ChangePasswordServer chngPwdServer = new ChangePasswordServer(config);
for (CreateTransport transportBuilder : createChngPwdServer.transports()) {
Transport t = createTransport(transportBuilder, startPort);
startPort = t.getPort() + 1;
chngPwdServer.addTransports(t);
}
chngPwdServer.setDirectoryService(directoryService);
kdcServer.setChangePwdServer(chngPwdServer);
}
kdcServer.setDirectoryService(directoryService);
// Launch the server
try {
kdcServer.start();
} catch (Exception e) {
e.printStackTrace();
}
return kdcServer;
}
use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project cloudstack by apache.
the class EmbeddedLdapServer method init.
public void init() throws Exception {
if (getDirectoryService() == null) {
if (getDeleteInstanceDirectoryOnStartup()) {
deleteDirectory(getGuessedInstanceDirectory());
}
DefaultDirectoryServiceFactory serviceFactory = new DefaultDirectoryServiceFactory();
serviceFactory.init(getDirectoryServiceName());
setDirectoryService(serviceFactory.getDirectoryService());
getDirectoryService().getChangeLog().setEnabled(false);
getDirectoryService().setDenormalizeOpAttrsEnabled(true);
createBasePartition();
getDirectoryService().startup();
createRootEntry();
}
if (getLdapServer() == null) {
setLdapServer(new LdapServer());
getLdapServer().setDirectoryService(getDirectoryService());
getLdapServer().setTransports(new TcpTransport(getLdapServerPort()));
getLdapServer().start();
}
}
use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project aws-iam-ldap-bridge by denismo.
the class Runner method startServer.
/**
* starts the LdapServer
*
* @throws Exception
*/
public void startServer() throws Exception {
server = new LdapServer();
server.setTransports(new TcpTransport(serverPort));
server.setDirectoryService(service);
server.start();
}
Aggregations