本文整理汇总了Java中org.apache.directory.server.ldap.LdapServer.setTransports方法的典型用法代码示例。如果您正苦于以下问题:Java LdapServer.setTransports方法的具体用法?Java LdapServer.setTransports怎么用?Java LdapServer.setTransports使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.server.ldap.LdapServer
的用法示例。
在下文中一共展示了LdapServer.setTransports方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: 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");
}
}
示例4: 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();
}
示例5: 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();
}
示例6: 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");
}
}
示例7: 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();
}
示例8: newEmbeddedServer
import org.apache.directory.server.ldap.LdapServer; //导入方法依赖的package包/类
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);
}
示例9: startServer
import org.apache.directory.server.ldap.LdapServer; //导入方法依赖的package包/类
/**
* 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();
}