diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-07-24 09:31:20 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-07-24 09:31:20 +0200 |
| commit | 7ed322e896143cc687e0f3ada8a659473aea0567 (patch) | |
| tree | a85a0bfd807ac23e0a4a63eb37b5e84b1227f4a7 | |
| parent | fdaf02db3616b7b36168e97462b7d55adc47fee2 (diff) | |
Don't depend on gateway properties in the constructor of LDAPLookup, as
it may be instantiated before the Gateway is initialized.
| -rw-r--r-- | src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java | 3 | ||||
| -rw-r--r-- | src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java | 31 |
2 files changed, 21 insertions, 13 deletions
diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java index 6737192..1ddb452 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java @@ -26,7 +26,8 @@ public class LDAPAuthManager implements Authenticator { ldapProps.mUser = "";
ldapProps.mPassword = "";
mLDAPConn = LDAPLookupUtils.createConnection(ldapProps);
- LDAPLookup anonLookup = new LDAPLookup(ldapProps);
+ LDAPLookup anonLookup = new LDAPLookup();
+ anonLookup.initPaths(ldapProps);
anonLookup.open(this);
String agentDN = anonLookup.getFullDN(anonLookup.getAgentPath(agentName));
diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java index 0a27a0d..372a91c 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java @@ -56,17 +56,21 @@ public class LDAPLookup implements LookupManager protected LDAPAuthManager mLDAPAuth;
protected LDAPPropertyManager mPropManager;
- final String mItemTypeRoot, mDomainTypeRoot, mGlobalPath, mRootPath, mLocalPath, mRolePath;
+ private String mGlobalPath, mRootPath, mLocalPath, mRolePath, mItemTypeRoot, mDomainTypeRoot;
+ LDAPProperties ldapProps;
+ public LDAPLookup() {
+ }
+
+
/**
- * Creates a new LDAPLookup manager with the properties supplied.
- * This should be only done by the Gateway during initialisation.
- *
- * @param props The LDAP properties object that extracts LDAP connection properties from the global c2kprops
+ * Initializes the DN paths from the Root, global and local paths supplied by the LDAP properties.
+ * @param props
*/
- public LDAPLookup(LDAPProperties props)
+ protected void initPaths(LDAPProperties props)
{
Logger.msg(8,"LDAPLookup - initialising.");
+ ldapProps = props;
mGlobalPath=props.mGlobalPath;
mRootPath=props.mRootPath;
@@ -75,17 +79,20 @@ public class LDAPLookup implements LookupManager mItemTypeRoot = "cn=entity,"+props.mLocalPath;
mDomainTypeRoot = "cn=domain,"+props.mLocalPath;
mRolePath = "cn=agent,"+mDomainTypeRoot;
-
- }
-
- public LDAPLookup() {
- this(new LDAPProperties(Gateway.getProperties()));
}
+ /**
+ * Initializes the LDAPLookup manager with the Gateway properties.
+ * This should be only done by the Gateway during initialisation.
+ *
+ * @param auth A LDAPAuthManager authenticator
+ */
@Override
public void open(Authenticator auth) {
+ if (ldapProps == null)
+ initPaths(new LDAPProperties(Gateway.getProperties()));
+
mLDAPAuth = (LDAPAuthManager)auth;
- Logger.msg(7, "LDAP.useOldProps="+Gateway.getProperties().getBoolean("LDAP.useOldProps", false));
mPropManager = new LDAPPropertyManager(this, mLDAPAuth);
}
|
