本文整理了Java中com.unboundid.ldap.sdk.LDAPConnection.<init>()
方法的一些代码示例,展示了LDAPConnection.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LDAPConnection.<init>()
方法的具体详情如下:
包路径:com.unboundid.ldap.sdk.LDAPConnection
类名称:LDAPConnection
方法名:<init>
[英]Creates a new LDAP connection using the default socket factory and default set of connection options. No actual network connection will be established.
[中]
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* {@inheritDoc}
*/
@Override()
public LDAPConnection getConnection()
throws LDAPException
{
return new LDAPConnection(socketFactory, connectionOptions, address, port);
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* {@inheritDoc}
*/
@Override()
public LDAPConnection getConnection()
throws LDAPException
{
return new LDAPConnection(socketFactory, connectionOptions, address, port);
}
代码示例来源:origin: com.redhat.lightblue.ldap/lightblue-ldap-test
public LDAPConnection getLDAPConnection() throws LDAPException {
return new LDAPConnection("localhost", getPort());
}
代码示例来源:origin: apiman/apiman
private static LDAPConnection getConnection(Map<LdapConfigBean, LDAPConnectionPool> map,
SSLSocketFactory socketFactory, LdapConfigBean config) throws LDAPException {
if (!map.containsKey(config)) {
LDAPConnection template = new LDAPConnection(config.getHost(), config.getPort());
if (socketFactory != null)
template.setSocketFactory(socketFactory);
map.put(config, new LDAPConnectionPool(template, MAX_CONNECTIONS_PER_POOL));
}
return map.get(config).getConnection();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
this.connectionSelected = connectionSelected;
connection = new LDAPConnection(socketFactory, connectionOptions);
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Unbinds and disconnects from the directory server.
*
* @throws LDAPException If a problem occurs.
*/
public void disconnect()
throws LDAPException
{
authDN = null;
authPW = null;
conn.close();
if (socketFactory == null)
{
conn = new com.unboundid.ldap.sdk.LDAPConnection();
}
else
{
conn = new com.unboundid.ldap.sdk.LDAPConnection(
new LDAPToJavaSocketFactory(socketFactory));
}
}
代码示例来源:origin: io.apiman/apiman-gateway-engine-core
private static LDAPConnection getConnection(Map<LdapConfigBean, LDAPConnectionPool> map,
SSLSocketFactory socketFactory, LdapConfigBean config) throws LDAPException {
if (!map.containsKey(config)) {
LDAPConnection template = new LDAPConnection(config.getHost(), config.getPort());
if (socketFactory != null)
template.setSocketFactory(socketFactory);
map.put(config, new LDAPConnectionPool(template, MAX_CONNECTIONS_PER_POOL));
}
return map.get(config).getConnection();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Creates a new LDAP connection which will use the provided socket factory.
*
* @param socketFactory The socket factory to use when creating the socket
* to use for communicating with the server.
*/
public LDAPConnection(final LDAPSocketFactory socketFactory)
{
this.socketFactory = socketFactory;
if (socketFactory == null)
{
conn = new com.unboundid.ldap.sdk.LDAPConnection();
}
else
{
conn = new com.unboundid.ldap.sdk.LDAPConnection(
new LDAPToJavaSocketFactory(socketFactory));
}
authDN = null;
authPW = null;
constraints = new LDAPConstraints();
searchConstraints = new LDAPSearchConstraints();
}
代码示例来源:origin: otto-de/edison-microservice
public LDAPConnection buildLdapConnection() throws GeneralSecurityException, LDAPException {
SSLSocketFactory sslSocketFactory = SSL_UTIL.createSSLSocketFactory();
return new LDAPConnection(sslSocketFactory, ldapProperties.getHost(), ldapProperties.getPort());
}
}
代码示例来源:origin: tmobile/pacbot
/**
* fall back to connect using IP itself
* @return
*/
private LDAPConnection tryGettingConnectionWithDirectIP() throws LDAPException {
LDAPConnection ldapConnection = new LDAPConnection();
try{
hostIps.forEach(
ip->{
try{
ldapConnection.connect(ip, ntPort,connectTimeout);
throw new BreakLoopException();
}catch(LDAPException exception){
log.debug("unable to connect using" + ip + ", trying next ip");
}
}
);
}catch(BreakLoopException br){
log.info("got connected using IP");
}
if(ldapConnection.isConnected())
return ldapConnection;
else{
throw new LDAPException(ResultCode.CONNECT_ERROR,"unable to connect using IP");
}
}
代码示例来源:origin: tmobile/pacbot
numberOfTries++;
log.debug(String.format("trial number -> %s" , numberOfTries));
ldapConnection = new LDAPConnection(connectionOptions);
ldapConnection.connect(ntDomain, ntPort,connectTimeout);
break;
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
if (socketFactory == null)
conn = new com.unboundid.ldap.sdk.LDAPConnection(host, port);
conn = new com.unboundid.ldap.sdk.LDAPConnection(
new LDAPToJavaSocketFactory(socketFactory), host, port);
代码示例来源:origin: otto-de/edison-microservice
public LDAPConnection buildLdapConnection() throws GeneralSecurityException, LDAPException {
final LDAPConnection ldapConnection = new LDAPConnection(ldapProperties.getHost(), ldapProperties.getPort());
ldapConnection.processExtendedOperation(new StartTLSExtendedRequest(SSL_UTIL.createSSLContext()));
return ldapConnection;
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-staticsecurity-ldap
protected SearchResult execute(SearchRequest request, String bindDN, String password) {
LDAPConnection connection = null;
try {
if (allowAllSocketFactory) {
SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager());
connection = new LDAPConnection(sslUtil.createSSLSocketFactory(), serverHost, serverPort);
} else {
connection = new LDAPConnection(serverHost, serverPort);
}
if (bindDN != null) {
BindResult auth = connection.bind(bindDN, password);
if (!auth.getResultCode().isConnectionUsable()) {
log.error("Connection not usable, result code : " + auth.getResultCode());
}
}
return connection.search(request);
} catch (LDAPException le) {
String message = le.getMessage();
if (!message.startsWith("Unable to bind as user ")) {
log.error(le.getMessage(), le);
}
} catch (GeneralSecurityException gse) {
log.error(gse.getMessage(), gse);
} finally {
if (null != connection) {
connection.close();
}
}
return null;
}
代码示例来源:origin: org.esbtools.auth/cert-ldap-login-module-common
SSLSocketFactory socketFactory = new SSLUtil(trustStoreTrustManager).createSSLSocketFactory();
ldapConnection = new LDAPConnection(socketFactory, options);
} else {
LOGGER.warn("Not using SSL to connect to ldap. This is very insecure - do not use in prod environments!");
ldapConnection = new LDAPConnection(options);
代码示例来源:origin: gsvigruha/cosyan
public AuthToken auth(String username, String password, String token) throws AuthException {
String ldapHost = config.get(Config.LDAP_HOST);
try {
LDAPConnection connection = new LDAPConnection(
ldapHost,
Integer.valueOf(config.get(Config.LDAP_PORT)),
username + "@" + ldapHost,
password);
if (connection.isConnected()) {
return new LDAPToken(connection, username, token);
} else {
connection.close();
throw new AuthException("Connection not connected.");
}
} catch (LDAPException e) {
throw new AuthException(e.getExceptionMessage());
}
}
}
代码示例来源:origin: io.vertx/vertx-auth-service
private void insertTestUsers() throws LDAPException {
LDAPConnection connection = null;
try {
connection = new LDAPConnection("localhost", 10389);
// entry tim/sausages
List<Attribute> addRequest = new ArrayList<Attribute>();
addRequest.add(new Attribute("objectClass", "top"));
addRequest.add(new Attribute("objectClass", "person"));
addRequest.add(new Attribute("objectClass", "organizationalPerson"));
addRequest.add(new Attribute("objectClass", "inetOrgPerson"));
addRequest.add(new Attribute("cn", "Tim Fox"));
addRequest.add(new Attribute("sn", "Fox"));
addRequest.add(new Attribute("mail", "tim@example.com"));
addRequest.add(new Attribute("uid", "tim"));
addRequest.add(new Attribute("userPassword", "{ssha}d0M5Z2qjOOCSCQInvZHgVAleCqU5I+ag9ZHXMw=="));
connection.add("uid=tim,ou=users,dc=foo,dc=com", addRequest);
} finally {
if (connection != null) {
connection.close();
}
}
}
代码示例来源:origin: io.vertx/vertx-auth-shiro
private void insertTestUsers() throws LDAPException {
LDAPConnection connection = null;
try {
connection = new LDAPConnection("localhost", 10389);
// entry tim/sausages
List<Attribute> addRequest = new ArrayList<>();
addRequest.add(new Attribute("objectClass", "top"));
addRequest.add(new Attribute("objectClass", "person"));
addRequest.add(new Attribute("objectClass", "organizationalPerson"));
addRequest.add(new Attribute("objectClass", "inetOrgPerson"));
addRequest.add(new Attribute("cn", "Tim Fox"));
addRequest.add(new Attribute("sn", "Fox"));
addRequest.add(new Attribute("mail", "tim@example.com"));
addRequest.add(new Attribute("uid", "tim"));
addRequest.add(new Attribute("userPassword", "{ssha}d0M5Z2qjOOCSCQInvZHgVAleCqU5I+ag9ZHXMw=="));
connection.add("uid=tim,ou=users,dc=foo,dc=com", addRequest);
} finally {
if (connection != null) {
connection.close();
}
}
}
代码示例来源:origin: de.otto.edison/edison-togglz
ExtendedRequest extRequest = new StartTLSExtendedRequest(context);
ldapConnection = new LDAPConnection(ldapProperties.getHost(), ldapProperties.getPort());
ldapConnection.processExtendedOperation(extRequest);
BindResult bindResult = ldapConnection.bind(
代码示例来源:origin: org.seedstack.seed/seed-security-support-ldap
LDAPConnection connection;
try {
connection = new LDAPConnection(host, port, accountDn, ldapConfiguration.getString(ACCOUNT_PASSWORD_PROP));
ldapConnectionPool = new LDAPConnectionPool(connection, numConnections);
} catch (LDAPException e) {
内容来源于网络,如有侵权,请联系作者删除!