From 7ed322e896143cc687e0f3ada8a659473aea0567 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 24 Jul 2014 09:31:20 +0200 Subject: Don't depend on gateway properties in the constructor of LDAPLookup, as it may be instantiated before the Gateway is initialized. --- .../com/c2kernel/lookup/ldap/LDAPAuthManager.java | 3 ++- .../java/com/c2kernel/lookup/ldap/LDAPLookup.java | 31 +++++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'src/main/java/com/c2kernel/lookup') 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); } -- cgit v1.2.3