From 6e35118970c7af70eb0ac938859d794f7348d367 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 22 Feb 2013 14:04:33 +0100 Subject: Extracted LDAP specifics into subpackage --- .../com/c2kernel/entity/transfer/TransferSet.java | 2 +- src/main/java/com/c2kernel/lookup/AgentPath.java | 36 +- src/main/java/com/c2kernel/lookup/EntityPath.java | 36 +- src/main/java/com/c2kernel/lookup/LDAPLookup.java | 485 -------------------- .../java/com/c2kernel/lookup/LDAPLookupUtils.java | 318 ------------- src/main/java/com/c2kernel/lookup/LDAPPathSet.java | 72 --- .../java/com/c2kernel/lookup/LDAPProperties.java | 55 --- .../com/c2kernel/lookup/LDAPPropertyManager.java | 118 ----- .../java/com/c2kernel/lookup/LDAPRoleManager.java | 205 --------- .../c2kernel/lookup/LegacyLDAPPropertyManager.java | 75 ---- src/main/java/com/c2kernel/lookup/Lookup.java | 74 +-- .../java/com/c2kernel/lookup/NextKeyManager.java | 71 --- src/main/java/com/c2kernel/lookup/Path.java | 29 +- .../com/c2kernel/lookup/ldap/LDAPAgentPath.java | 90 ++++ .../com/c2kernel/lookup/ldap/LDAPEntityPath.java | 87 ++++ .../java/com/c2kernel/lookup/ldap/LDAPLookup.java | 494 +++++++++++++++++++++ .../com/c2kernel/lookup/ldap/LDAPLookupUtils.java | 318 +++++++++++++ .../java/com/c2kernel/lookup/ldap/LDAPPathSet.java | 78 ++++ .../com/c2kernel/lookup/ldap/LDAPProperties.java | 55 +++ .../c2kernel/lookup/ldap/LDAPPropertyManager.java | 119 +++++ .../com/c2kernel/lookup/ldap/LDAPRoleManager.java | 210 +++++++++ .../lookup/ldap/LegacyLDAPPropertyManager.java | 76 ++++ .../com/c2kernel/lookup/ldap/NextKeyManager.java | 74 +++ .../c2kernel/persistency/LDAPClusterStorage.java | 4 +- src/main/java/com/c2kernel/process/Gateway.java | 4 +- 25 files changed, 1650 insertions(+), 1535 deletions(-) delete mode 100644 src/main/java/com/c2kernel/lookup/LDAPLookup.java delete mode 100644 src/main/java/com/c2kernel/lookup/LDAPLookupUtils.java delete mode 100644 src/main/java/com/c2kernel/lookup/LDAPPathSet.java delete mode 100644 src/main/java/com/c2kernel/lookup/LDAPProperties.java delete mode 100644 src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java delete mode 100644 src/main/java/com/c2kernel/lookup/LDAPRoleManager.java delete mode 100644 src/main/java/com/c2kernel/lookup/LegacyLDAPPropertyManager.java delete mode 100644 src/main/java/com/c2kernel/lookup/NextKeyManager.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LDAPAgentPath.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LDAPEntityPath.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LDAPLookupUtils.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LDAPPathSet.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LDAPProperties.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LDAPPropertyManager.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LDAPRoleManager.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/LegacyLDAPPropertyManager.java create mode 100644 src/main/java/com/c2kernel/lookup/ldap/NextKeyManager.java (limited to 'src/main/java/com') diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferSet.java b/src/main/java/com/c2kernel/entity/transfer/TransferSet.java index 5a8fd07..4291b21 100644 --- a/src/main/java/com/c2kernel/entity/transfer/TransferSet.java +++ b/src/main/java/com/c2kernel/entity/transfer/TransferSet.java @@ -4,7 +4,7 @@ import java.io.File; import java.util.ArrayList; import com.c2kernel.lookup.EntityPath; -import com.c2kernel.lookup.NextKeyManager; +import com.c2kernel.lookup.ldap.NextKeyManager; import com.c2kernel.process.Gateway; import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Logger; diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java index 8c83251..c200d75 100644 --- a/src/main/java/com/c2kernel/lookup/AgentPath.java +++ b/src/main/java/com/c2kernel/lookup/AgentPath.java @@ -15,11 +15,9 @@ import java.security.NoSuchAlgorithmException; import org.apache.xerces.impl.dv.util.Base64; -import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.lookup.ldap.LDAPLookupUtils; import com.c2kernel.process.Gateway; -import com.novell.ldap.LDAPAttribute; -import com.novell.ldap.LDAPAttributeSet; import com.novell.ldap.LDAPEntry; @@ -32,8 +30,8 @@ import com.novell.ldap.LDAPEntry; public class AgentPath extends EntityPath { - private String mAgentName=null; - private String mPassword=null; + protected String mAgentName=null; + protected String mPassword=null; public AgentPath(int syskey, String agentName) throws InvalidAgentPathException,InvalidEntityPathException @@ -122,33 +120,5 @@ public class AgentPath extends EntityPath digest.append(Base64.encode(hash)); return digest.toString(); } - - @Override - public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated - { - LDAPAttributeSet attrs = new LDAPAttributeSet(); - attrs.add(new LDAPAttribute("objectclass","cristalagent")); - attrs.add(new LDAPAttribute("intsyskey",Integer.toString(mSysKey))); - attrs.add(new LDAPAttribute("cn", getPath()[getPath().length-1])); - if (mIOR != null) - attrs.add(new LDAPAttribute("ior", Gateway.getORB().object_to_string(mIOR))); - - if (mAgentName!=null && mAgentName.length()>0) - attrs.add(new LDAPAttribute("uid",mAgentName)); - else - throw new ObjectCannotBeUpdated("Cannot create agent. No userId specified", ""); - - if (mPassword!=null && mPassword.length()>0) - try { - attrs.add(new LDAPAttribute("userPassword",generateUserPassword(mPassword, "SHA"))); - } catch (NoSuchAlgorithmException ex) { - throw new ObjectCannotBeUpdated("Cryptographic libraries for password hashing not found.", ""); - } - else - throw new ObjectCannotBeUpdated("Cannot create agent. No password given", ""); - - return attrs; - } - } diff --git a/src/main/java/com/c2kernel/lookup/EntityPath.java b/src/main/java/com/c2kernel/lookup/EntityPath.java index 4f9b771..8e93f8f 100644 --- a/src/main/java/com/c2kernel/lookup/EntityPath.java +++ b/src/main/java/com/c2kernel/lookup/EntityPath.java @@ -12,11 +12,8 @@ package com.c2kernel.lookup; import java.util.ArrayList; -import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.process.Gateway; -import com.novell.ldap.LDAPAttribute; -import com.novell.ldap.LDAPAttributeSet; /** @@ -34,6 +31,8 @@ public class EntityPath extends Path // maximum possible int syskey public static final int maxSysKey = (int)Math.pow(10, elementNo*elementLen)-1; protected static String mTypeRoot; + // ior is stored in here when it is resolved + protected org.omg.CORBA.Object mIOR = null; /* * From syskey int * Note no EntityPath constructors allow setting of CONTEXT or ENTITY: @@ -160,16 +159,27 @@ public class EntityPath extends Path else mType = Path.CONTEXT; } - - @Override - public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated { - LDAPAttributeSet attrs = new LDAPAttributeSet(); - attrs.add(new LDAPAttribute("objectclass","cristalentity")); - attrs.add(new LDAPAttribute("intsyskey",Integer.toString(mSysKey))); - attrs.add(new LDAPAttribute("cn", getPath()[getPath().length-1])); - if (mIOR != null) - attrs.add(new LDAPAttribute("ior", Gateway.getORB().object_to_string(mIOR))); - return attrs; + + // lookup sets the IOR + public void setIOR(org.omg.CORBA.Object IOR) { + mIOR = IOR; + if (IOR == null) mType = Path.CONTEXT; + else mType = Path.ENTITY; + } + + /** Queries the lookup for the IOR + */ + public org.omg.CORBA.Object getIOR() { + org.omg.CORBA.Object newIOR = null; + if (mIOR==null) { // if not cached try to resolve + Lookup myLookup = Gateway.getLookup(); + try { + newIOR = myLookup.resolve(this); + } catch (ObjectNotFoundException ex) { + } + setIOR(newIOR); + } + return mIOR; } } diff --git a/src/main/java/com/c2kernel/lookup/LDAPLookup.java b/src/main/java/com/c2kernel/lookup/LDAPLookup.java deleted file mode 100644 index ab5992c..0000000 --- a/src/main/java/com/c2kernel/lookup/LDAPLookup.java +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Directory Lookup Service * - * author: Florida Estrella -*/ - -package com.c2kernel.lookup; - -import java.util.StringTokenizer; - -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.TraceableEntity; -import com.c2kernel.entity.agent.ActiveEntity; -import com.c2kernel.entity.proxy.EntityProxyManager; -import com.c2kernel.entity.proxy.ProxyMessage; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; -import com.c2kernel.utils.Resource; -import com.novell.ldap.LDAPAttributeSet; -import com.novell.ldap.LDAPConnection; -import com.novell.ldap.LDAPDN; -import com.novell.ldap.LDAPEntry; -import com.novell.ldap.LDAPException; -import com.novell.ldap.LDAPSearchConstraints; -import com.novell.ldap.LDAPSearchResults; - -/** - * The LDAPLookup object, statically accessible through the Gateway, manages - * the LDAP connection for the cristal process. It provides: - *