use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project jackrabbit-oak by apache.
the class AbstractServer method setupLdapServer.
protected void setupLdapServer() throws Exception {
ldapServer.setTransports(new TcpTransport(port));
ldapServer.setDirectoryService(directoryService);
ldapServer.addExtendedOperationHandler(new StartTlsHandler());
ldapServer.addExtendedOperationHandler(new StoredProcedureExtendedOperationHandler());
}
use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project knox by apache.
the class SimpleLdapDirectoryServer method main.
public static void main(String[] args) throws Exception {
PropertyConfigurator.configure(System.getProperty("log4j.configuration"));
SimpleLdapDirectoryServer ldap;
File file;
if (args.length < 1) {
file = new File("conf/users.ldif");
} else {
File dir = new File(args[0]);
if (!dir.exists() || !dir.isDirectory()) {
throw new FileNotFoundException(dir.getAbsolutePath());
}
file = new File(dir, "users.ldif");
}
if (!file.exists() || !file.canRead()) {
throw new FileNotFoundException(file.getAbsolutePath());
}
int port = 33389;
// Make sure the port is free.
ServerSocket socket = new ServerSocket(port);
socket.close();
TcpTransport transport = new TcpTransport(port);
ldap = new SimpleLdapDirectoryServer("dc=hadoop,dc=apache,dc=org", file, transport);
ldap.start();
}
use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project knox by apache.
the class GatewayHealthFuncTest method setupLdap.
public static void setupLdap() throws Exception {
String basedir = System.getProperty("basedir");
if (basedir == null) {
basedir = new File(".").getCanonicalPath();
}
final Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/users.ldif");
ldapTransport = new TcpTransport(0);
ldap = new SimpleLdapDirectoryServer("dc=hadoop,dc=apache,dc=org", path.toFile(), ldapTransport);
ldap.start();
LOG.info("LDAP port = " + ldapTransport.getPort());
}
use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project syncope by apache.
the class ApacheDSStartStopListener method contextInitialized.
/**
* 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");
}
}
use of org.apache.directory.server.protocol.shared.transport.TcpTransport in project structr by structr.
the class LDAPServerService method initialize.
@Override
public boolean initialize(final StructrServices services) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
logger.info("Initializing directory service");
try {
ds = new DefaultDirectoryService();
final SchemaManager schemaManager = new DefaultSchemaManager();
final SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
final StructrPartition structrSchemaPartition = new StructrPartition(schemaManager, "schema", new Dn("ou=system"));
schemaPartition.setWrappedPartition(structrSchemaPartition);
ds.setInstanceLayout(new InstanceLayout(new File("/tmp/ldap-test")));
ds.setSchemaPartition(schemaPartition);
ds.setSchemaManager(schemaManager);
ds.setSystemPartition(new StructrPartition(schemaManager, "system", new Dn("ou=system")));
ds.startup();
logger.info("Importing schema..");
initSchema(schemaManager, ds.getAdminSession(), structrSchemaPartition);
server = new LdapServer();
int serverPort = 10389;
server.setTransports(new TcpTransport(serverPort));
server.setDirectoryService(ds);
server.start();
} catch (Throwable t) {
t.printStackTrace();
logger.warn("Unable to start LDAP server: {}", t.getMessage());
return false;
}
return true;
}
Aggregations