summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/ldapconn/LdapBoundConnection.java
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2011-12-08 21:15:59 -0500
committerAde Lee <alee@redhat.com>2011-12-08 21:15:59 -0500
commit171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch)
tree1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/common/src/com/netscape/cmscore/ldapconn/LdapBoundConnection.java
parentadad2fcee8a29fdb82376fbce07dedb11fccc182 (diff)
downloadpki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz
pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz
pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/ldapconn/LdapBoundConnection.java')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/ldapconn/LdapBoundConnection.java126
1 files changed, 73 insertions, 53 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/ldapconn/LdapBoundConnection.java b/pki/base/common/src/com/netscape/cmscore/ldapconn/LdapBoundConnection.java
index bfc71f78..82e0b315 100644
--- a/pki/base/common/src/com/netscape/cmscore/ldapconn/LdapBoundConnection.java
+++ b/pki/base/common/src/com/netscape/cmscore/ldapconn/LdapBoundConnection.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.ldapconn;
+
import java.util.Properties;
import netscape.ldap.LDAPConnection;
@@ -28,11 +29,13 @@ import netscape.ldap.LDAPv2;
import com.netscape.certsrv.apps.CMS;
+
/**
- * A LDAP connection that is bound to a server host, port, secure type. and
- * authentication. Makes a LDAP connection and authentication when instantiated.
- * Cannot establish another LDAP connection or authentication after
- * construction. LDAPConnection connect and authentication methods are
+ * A LDAP connection that is bound to a server host, port, secure type.
+ * and authentication.
+ * Makes a LDAP connection and authentication when instantiated.
+ * Cannot establish another LDAP connection or authentication after
+ * construction. LDAPConnection connect and authentication methods are
* overridden to prevent this.
*/
public class LdapBoundConnection extends LDAPConnection {
@@ -40,7 +43,7 @@ public class LdapBoundConnection extends LDAPConnection {
*
*/
private static final long serialVersionUID = -2242077674357271559L;
- // LDAPConnection calls authenticate so must set this for first
+ // LDAPConnection calls authenticate so must set this for first
// authenticate call.
private boolean mAuthenticated = false;
@@ -48,27 +51,28 @@ public class LdapBoundConnection extends LDAPConnection {
* Instantiates a connection to a ldap server, secure or non-secure
* connection with Ldap basic bind dn & pw authentication.
*/
- public LdapBoundConnection(LdapConnInfo connInfo, LdapAuthInfo authInfo)
- throws LDAPException {
+ public LdapBoundConnection(
+ LdapConnInfo connInfo, LdapAuthInfo authInfo)
+ throws LDAPException {
// this LONG line to satisfy super being the first call. (yuk)
super(
- authInfo.getAuthType() == LdapAuthInfo.LDAP_AUTHTYPE_SSLCLIENTAUTH ? new LdapJssSSLSocketFactory(
- authInfo.getParms()[0])
- : (connInfo.getSecure() ? new LdapJssSSLSocketFactory()
- : null));
-
- // Set option to automatically follow referrals.
- // Use the same credentials to follow referrals; this is the easiest
- // thing to do without any complicated configuration using
+ authInfo.getAuthType() == LdapAuthInfo.LDAP_AUTHTYPE_SSLCLIENTAUTH ?
+ new LdapJssSSLSocketFactory(authInfo.getParms()[0]) :
+ (connInfo.getSecure() ? new LdapJssSSLSocketFactory() : null));
+
+ // Set option to automatically follow referrals.
+ // Use the same credentials to follow referrals; this is the easiest
+ // thing to do without any complicated configuration using
// different hosts.
// If client auth is used don't have dn and pw to follow referrals.
boolean followReferrals = connInfo.getFollowReferrals();
setOption(LDAPv2.REFERRALS, new Boolean(followReferrals));
- if (followReferrals
- && authInfo.getAuthType() != LdapAuthInfo.LDAP_AUTHTYPE_SSLCLIENTAUTH) {
- LDAPRebind rebindInfo = new ARebindInfo(authInfo.getParms()[0],
+ if (followReferrals &&
+ authInfo.getAuthType() != LdapAuthInfo.LDAP_AUTHTYPE_SSLCLIENTAUTH) {
+ LDAPRebind rebindInfo =
+ new ARebindInfo(authInfo.getParms()[0],
authInfo.getParms()[1]);
setOption(LDAPv2.REFERRALS_REBIND_PROC, rebindInfo);
@@ -77,19 +81,20 @@ public class LdapBoundConnection extends LDAPConnection {
if (authInfo.getAuthType() == LdapAuthInfo.LDAP_AUTHTYPE_SSLCLIENTAUTH) {
// will be bound to client auth cert mapped entry.
super.connect(connInfo.getHost(), connInfo.getPort());
- CMS.debug("Established LDAP connection with SSL client auth to "
- + connInfo.getHost() + ":" + connInfo.getPort());
- } else { // basic auth
+ CMS.debug(
+ "Established LDAP connection with SSL client auth to " +
+ connInfo.getHost() + ":" + connInfo.getPort());
+ } else { // basic auth
String binddn = authInfo.getParms()[0];
String bindpw = authInfo.getParms()[1];
- super.connect(connInfo.getVersion(), connInfo.getHost(),
- connInfo.getPort(), binddn, bindpw);
- CMS.debug("Established LDAP connection using basic authentication to"
- + " host "
- + connInfo.getHost()
- + " port "
- + connInfo.getPort() + " as " + binddn);
+ super.connect(connInfo.getVersion(),
+ connInfo.getHost(), connInfo.getPort(), binddn, bindpw);
+ CMS.debug(
+ "Established LDAP connection using basic authentication to" +
+ " host " + connInfo.getHost() +
+ " port " + connInfo.getPort() +
+ " as " + binddn);
}
}
@@ -97,23 +102,26 @@ public class LdapBoundConnection extends LDAPConnection {
* Instantiates a connection to a ldap server, secure or non-secure
* connection with Ldap basic bind dn & pw authentication.
*/
- public LdapBoundConnection(String host, int port, int version,
- LDAPSocketFactory fac, String bindDN, String bindPW)
- throws LDAPException {
+ public LdapBoundConnection(String host, int port, int version,
+ LDAPSocketFactory fac,
+ String bindDN, String bindPW)
+ throws LDAPException {
super(fac);
if (bindDN != null) {
- super.connect(version, host, port, bindDN, bindPW);
- CMS.debug("Established LDAP connection using basic authentication "
- + " as " + bindDN + " to " + host + ":" + port);
+ super.connect(version, host, port, bindDN, bindPW);
+ CMS.debug(
+ "Established LDAP connection using basic authentication " +
+ " as " + bindDN + " to " + host + ":" + port);
} else {
if (fac == null && bindDN == null) {
throw new IllegalArgumentException(
"Ldap bound connection must have authentication info.");
}
// automatically authenticated if it's ssl client auth.
- super.connect(version, host, port, null, null);
- CMS.debug("Established LDAP connection using SSL client authentication "
- + "to " + host + ":" + port);
+ super.connect(version, host, port, null, null);
+ CMS.debug(
+ "Established LDAP connection using SSL client authentication " +
+ "to " + host + ":" + port);
}
}
@@ -121,11 +129,13 @@ public class LdapBoundConnection extends LDAPConnection {
* Overrides same method in LDAPConnection to do prevent re-authentication.
*/
public void authenticate(int version, String dn, String pw)
- throws LDAPException {
+ throws LDAPException {
/**
- * if (mAuthenticated) { throw new RuntimeException(
- * "this LdapBoundConnection already authenticated: auth(v,dn,pw)"); }
+ if (mAuthenticated) {
+ throw new RuntimeException(
+ "this LdapBoundConnection already authenticated: auth(v,dn,pw)");
+ }
**/
super.authenticate(version, dn, pw);
mAuthenticated = true;
@@ -134,11 +144,14 @@ public class LdapBoundConnection extends LDAPConnection {
/**
* Overrides same method in LDAPConnection to do prevent re-authentication.
*/
- public void authenticate(String dn, String pw) throws LDAPException {
+ public void authenticate(String dn, String pw)
+ throws LDAPException {
/**
- * if (mAuthenticated) { throw new RuntimeException(
- * "this LdapBoundConnection already authenticated: auth(dn,pw)"); }
+ if (mAuthenticated) {
+ throw new RuntimeException(
+ "this LdapBoundConnection already authenticated: auth(dn,pw)");
+ }
**/
super.authenticate(3, dn, pw);
mAuthenticated = true;
@@ -147,12 +160,15 @@ public class LdapBoundConnection extends LDAPConnection {
/**
* Overrides same method in LDAPConnection to do prevent re-authentication.
*/
- public void authenticate(String dn, String mech, String packageName,
- Properties props, Object getter) throws LDAPException {
+ public void authenticate(String dn, String mech, String packageName,
+ Properties props, Object getter)
+ throws LDAPException {
/**
- * if (mAuthenticated) { throw new RuntimeException(
- * "this LdapBoundConnection already authenticated: auth(mech)"); }
+ if (mAuthenticated) {
+ throw new RuntimeException(
+ "this LdapBoundConnection already authenticated: auth(mech)");
+ }
**/
super.authenticate(dn, mech, packageName, props, getter);
mAuthenticated = true;
@@ -161,12 +177,15 @@ public class LdapBoundConnection extends LDAPConnection {
/**
* Overrides same method in LDAPConnection to do prevent re-authentication.
*/
- public void authenticate(String dn, String mechs[], String packageName,
- Properties props, Object getter) throws LDAPException {
+ public void authenticate(String dn, String mechs[], String packageName,
+ Properties props, Object getter)
+ throws LDAPException {
/**
- * if (mAuthenticated) { throw new RuntimeException(
- * "this LdapBoundConnection is already authenticated: auth(mechs)"); }
+ if (mAuthenticated) {
+ throw new RuntimeException(
+ "this LdapBoundConnection is already authenticated: auth(mechs)");
+ }
**/
super.authenticate(dn, mechs, packageName, props, getter);
mAuthenticated = true;
@@ -183,13 +202,14 @@ public class LdapBoundConnection extends LDAPConnection {
/**
* overrides parent's connect to prevent re-connect.
*/
- public void connect(int version, String host, int port, String dn, String pw)
- throws LDAPException {
+ public void connect(int version, String host, int port,
+ String dn, String pw) throws LDAPException {
throw new RuntimeException(
"this LdapBoundConnection is already connected: conn(version,h,p)");
}
}
+
class ARebindInfo implements LDAPRebind {
private LDAPRebindAuth mRebindAuthInfo = null;