本文整理汇总了Java中com.unboundid.ldap.listener.InMemoryListenerConfig类的典型用法代码示例。如果您正苦于以下问题:Java InMemoryListenerConfig类的具体用法?Java InMemoryListenerConfig怎么用?Java InMemoryListenerConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InMemoryListenerConfig类属于com.unboundid.ldap.listener包,在下文中一共展示了InMemoryListenerConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
public void start() {
try {
final InMemoryDirectoryServerConfig dsConfig = new InMemoryDirectoryServerConfig(BASE_DN);
dsConfig.setSchema(null);
dsConfig.setEnforceAttributeSyntaxCompliance(false);
dsConfig.setEnforceSingleStructuralObjectClass(false);
dsConfig.setListenerConfigs(new InMemoryListenerConfig("myListener", null, PORT, null, null, null));
dsConfig.addAdditionalBindCredentials(CN + "=" + GOOD_USERNAME + "," + BASE_PEOPLE_DN, PASSWORD);
dsConfig.addAdditionalBindCredentials(CN + "=" + GOOD_USERNAME2 + "," + BASE_PEOPLE_DN, PASSWORD);
this.ds = new InMemoryDirectoryServer(dsConfig);
this.ds.add("dn: " + BASE_DN, "objectClass: organizationalUnit", "objectClass: top");
this.ds.add("dn: " + BASE_PEOPLE_DN, "objectClass: organizationalUnit");
this.ds.add("dn: " + CN + "=" + GOOD_USERNAME + "," + BASE_PEOPLE_DN, CN + ": " + GOOD_USERNAME, SN + ": "
+ FIRSTNAME_VALUE, "objectClass: person");
this.ds.add("dn: " + CN + "=" + GOOD_USERNAME2 + "," + BASE_PEOPLE_DN, ROLE + ": " + ROLE1, ROLE + ": " + ROLE2,
"objectClass: person");
//Debug.setEnabled(true);
this.ds.startListening();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
示例2: start
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
@Override
public void start() {
try {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=MyDomain");
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", 1389));
config.setSchema(null);
ds = new InMemoryDirectoryServer(config);
ds.startListening();
ds.importFromLDIF(true, new LDIFReader(getClass().getResourceAsStream("/conf/realm.ldif")));
} catch (LDAPException e) {
ds = null;
log.error("Failed to start UnboundID LDAP server!", e);
}
}
示例3: getInMemoryListenerConfigs
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
/**
* Returns the Listener Configs to register with he InMemory LDAP server.
*
* @return The server object loaded from XML file by JAXB.
* @throws Exception
*/
public Collection<InMemoryListenerConfig> getInMemoryListenerConfigs() throws Exception {
Collection<InMemoryListenerConfig> listenerConfigs = new ArrayList<InMemoryListenerConfig>();
if (configuration.getListeners() != null) {
for (Listener listener : configuration.getListeners()) {
InetAddress listenAddress = null; //according to javadoc, will listen for all connections on all addresses on all interfaces.
if (!StringUtils.isEmpty(listener.getAddress())) {
listenAddress = InetAddress.getByName(listener.getAddress());
}
int listenPort = Integer.parseInt(listener.getPort());
javax.net.ServerSocketFactory serverSocketFactory = null; //if null uses the JVM default socket factory.
javax.net.SocketFactory clientSocketFactory = null; //if null uses the JVM default socket factory.
javax.net.ssl.SSLSocketFactory startTLSSocketFactory = null; //StartTLS is not supported on this listener.
InMemoryListenerConfig listenerConfig = new InMemoryListenerConfig(listener.getName(), listenAddress, listenPort, serverSocketFactory, clientSocketFactory, startTLSSocketFactory);
listenerConfigs.add(listenerConfig);
}
}
return listenerConfigs;
}
示例4: before
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(imlsAnnotation.baseDns());
for (BindCriteria bindCriteria : imlsAnnotation.bindCriteria()) {
config.addAdditionalBindCredentials(bindCriteria.bindableDn(), bindCriteria.password());
}
InMemoryListenerConfig listenerConfig = new InMemoryListenerConfig(
imlsAnnotation.name(), null, imlsAnnotation.port(), null, null, null);
config.setListenerConfigs(listenerConfig);
config.setSchema(schema); // do not check (attribute) schema
server = new InMemoryDirectoryServer(config);
server.startListening();
preloadData();
}
示例5: configureWithPort
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
protected InMemoryDirectoryServer configureWithPort(int port) throws LDAPException,BindException {
LdapConfiguration config = defaultConfiguration();
InMemoryListenerConfig listenerConfig = (port > 0) ?
InMemoryListenerConfig.createLDAPConfig("default", config.port()) :
InMemoryListenerConfig.createLDAPConfig("default");
InMemoryDirectoryServerConfig c = new InMemoryDirectoryServerConfig(new DN(config.base().dn()));
c.setListenerConfigs(listenerConfig);
c.addAdditionalBindCredentials(config.bindDn(), config.password());
c.setSchema(null);
server = new InMemoryDirectoryServer(c);
try {
server.startListening();
return server;
} catch (LDAPException ldapException) {
if (ldapException.getMessage().contains("java.net.BindException")) {
throw new BindException(ldapException.getMessage());
}
throw ldapException;
}
}
示例6: before
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
@Before
public void before() throws Exception {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=org");
config.addAdditionalBindCredentials("cn=test,dc=staticsecurity,dc=geomajas,dc=org", "cred");
InMemoryListenerConfig listenerConfig = new InMemoryListenerConfig("test", null, PORT, null, null, null);
config.setListenerConfigs(listenerConfig);
config.setSchema(null); // do not check (attribute) schema
server = new InMemoryDirectoryServer(config);
server.startListening();
server.add("dn: dc=org", "objectClass: top", "objectClass: domain", "dc: org");
server.add("dn: dc=geomajas,dc=org", "objectClass: top", "objectClass: domain", "dc: geomajas");
server.add("dn: dc=roles,dc=geomajas,dc=org", "objectClass: top", "objectClass: domain",
"dc: roles");
server.add("dn: dc=staticsecurity,dc=geomajas,dc=org", "objectClass: top", "objectClass: domain",
"dc: staticsecurity");
server.add("dn: cn=testgroup,dc=roles,dc=geomajas,dc=org", "objectClass: groupOfUniqueNames",
"cn: testgroup");
server.add("dn: cn=devgroup,dc=roles,dc=geomajas,dc=org", "objectClass: groupOfUniqueNames",
"cn: devgroup");
server.add("dn: cn=test,dc=staticsecurity,dc=geomajas,dc=org", "objectClass: person", "locale: nl_BE",
"sn: Tester", "givenName: Joe", "cn: test", "memberOf: cn=testgroup,dc=roles,dc=geomajas,dc=org");
server.add("dn: cn=jill,dc=staticsecurity,dc=geomajas,dc=org", "objectClass: person", "locale: nl_BE",
"sn: Developer", "givenName: Jill", "cn: dev", "memberOf: cn=devgroup,dc=roles,dc=geomajas,dc=org");
}
示例7: newEmbeddedServer
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
public static EmbeddedLdapServer newEmbeddedServer(String defaultPartitionName,
String defaultPartitionSuffix, int port) throws Exception {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(
defaultPartitionSuffix);
config.addAdditionalBindCredentials("uid=admin,ou=system", "secret");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", port));
config.setEnforceSingleStructuralObjectClass(false);
config.setEnforceAttributeSyntaxCompliance(true);
Entry entry = new Entry(new DN(defaultPartitionSuffix));
entry.addAttribute("objectClass", "top", "domain", "extensibleObject");
entry.addAttribute("dc", defaultPartitionName);
InMemoryDirectoryServer directoryServer = new InMemoryDirectoryServer(config);
directoryServer.add(entry);
directoryServer.startListening();
return new EmbeddedLdapServer(directoryServer);
}
示例8: configureWithPort
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
protected InMemoryDirectoryServer configureWithPort(int port) throws LDAPException, BindException {
InMemoryListenerConfig listenerConfig = (port > 0) ?
InMemoryListenerConfig.createLDAPConfig("default", config.port()) :
InMemoryListenerConfig.createLDAPConfig("default");
InMemoryDirectoryServerConfig c = new InMemoryDirectoryServerConfig(new DN(config.base().dn()));
c.setListenerConfigs(listenerConfig);
c.addAdditionalBindCredentials(config.bindDn(), config.password());
if (!config.useSchema()) {
c.setSchema(null);
}
server = new InMemoryDirectoryServer(c);
try {
server.startListening();
return server;
} catch (LDAPException ldape) {
if (ldape.getMessage().contains("BindException")) {
throw new BindException(ldape.getMessage());
}
throw ldape;
}
}
示例9: startup
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
public void startup() throws LDAPException, IOException {
logger.warn("Starting embedded LDAP");
InMemoryDirectoryServerConfig serverconfig = new InMemoryDirectoryServerConfig("dc=example,dc=com");
serverconfig.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig(
"default",
InetAddress.getLoopbackAddress(), 1338, null));
serverconfig.setSchema(null);
dirServer = new InMemoryDirectoryServer(serverconfig);
dirServer.startListening();
reset();
}
示例10: main
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
public static void main ( String[] args ) {
int port = 1389;
if ( args.length < 1 || args[ 0 ].indexOf('#') < 0 ) {
System.err.println(LDAPRefServer.class.getSimpleName() + " <codebase_url#classname> [<port>]"); //$NON-NLS-1$
System.exit(-1);
}
else if ( args.length > 1 ) {
port = Integer.parseInt(args[ 1 ]);
}
try {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(LDAP_BASE);
config.setListenerConfigs(new InMemoryListenerConfig(
"listen", //$NON-NLS-1$
InetAddress.getByName("0.0.0.0"), //$NON-NLS-1$
port,
ServerSocketFactory.getDefault(),
SocketFactory.getDefault(),
(SSLSocketFactory) SSLSocketFactory.getDefault()));
config.addInMemoryOperationInterceptor(new OperationInterceptor(new URL(args[ 0 ])));
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
System.out.println("Listening on 0.0.0.0:" + port); //$NON-NLS-1$
ds.startListening();
}
catch ( Exception e ) {
e.printStackTrace();
}
}
示例11: createInMemoryLdapServer
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
@BeforeClass
public static void createInMemoryLdapServer() throws Exception {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=MyDomain");
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", ldapPort));
config.setSchema(null);
ds = new InMemoryDirectoryServer(config);
ds.startListening();
}
示例12: setUpClass
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=springframework,dc=org");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", 8389));
config.addAdditionalBindCredentials("uid=admin,ou=system", "secret");
server = new InMemoryDirectoryServer(config);
server.startListening();
LdapTestUtils.loadLdif(server, new ClassPathResource("test-server.ldif"));
Map<String, String> defaultSettings = SecurityUtils.getLdapSettingsForApp(new App("test"));
bindAuthenticator = new LDAPAuthenticator(defaultSettings);
defaultSettings.put("security.ldap.compare_passwords", "true");
passComparingAuthenticator = new LDAPAuthenticator(defaultSettings);
}
示例13: createInMemoryLdapServer
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
@BeforeClass
public static void createInMemoryLdapServer() throws Exception {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=MyDomain");
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", ldapPort));
config.setSchema(null);
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
ds.importFromLDIF(true, new LDIFReader(LdapUserServiceTest.class.getResourceAsStream("resources/ldapUserServiceSampleData.ldif")));
ds.startListening();
}
示例14: setupClass
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
@Before
public void setupClass() throws Exception {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=com");
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", 389));
config.setSchema(
Schema.getSchema(
"src/test/resources/schema.ldif"
));
ds = new InMemoryDirectoryServer(config);
ds.importFromLDIF(true, "src/test/resources/data.ldif");
ds.startListening();
}
示例15: initPort
import com.unboundid.ldap.listener.InMemoryListenerConfig; //导入依赖的package包/类
private void initPort(InMemoryDirectoryServerConfig config) {
if (_port != null) {
try {
InMemoryListenerConfig listenerConfig =
new InMemoryListenerConfig("default listener", null, _port, null, null, null);
config.setListenerConfigs(listenerConfig);
LOG.debug("Successfully configured listener on port: {}", _port);
} catch (LDAPException e) {
throw propagate(e);
}
}
}