From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: More code cleanup: Refactored Entity Proxy Subscription to handle generics better Rewrote RemoteMap to use TreeMap instead of the internal array for order. It now sorts its keys by number if they parse, else as strings. Removed a no-longer-in-progress outcome form class --- source/com/c2kernel/lookup/AgentPath.java | 48 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) mode change 100755 => 100644 source/com/c2kernel/lookup/AgentPath.java (limited to 'source/com/c2kernel/lookup/AgentPath.java') diff --git a/source/com/c2kernel/lookup/AgentPath.java b/source/com/c2kernel/lookup/AgentPath.java old mode 100755 new mode 100644 index 01c764f..5ff6988 --- a/source/com/c2kernel/lookup/AgentPath.java +++ b/source/com/c2kernel/lookup/AgentPath.java @@ -31,26 +31,26 @@ import com.novell.ldap.LDAPEntry; **/ public class AgentPath extends EntityPath { - + private String mAgentName=null; private String mPassword=null; - - public AgentPath(int syskey, String agentName) - throws InvalidAgentPathException,InvalidEntityPathException + + public AgentPath(int syskey, String agentName) + throws InvalidAgentPathException,InvalidEntityPathException { super(syskey); if (agentName!=null && agentName.length()>0) setAgentName(agentName); - else + else throw new InvalidAgentPathException(); } - + public AgentPath(int syskey) - throws InvalidEntityPathException + throws InvalidEntityPathException { super(syskey); } - + public AgentPath(EntityPath entity) { super(); try { @@ -59,7 +59,7 @@ public class AgentPath extends EntityPath //won't happen as the entity path was valid } } - + public void setAgentName(String agentID) { mAgentName = agentID; @@ -75,19 +75,19 @@ public class AgentPath extends EntityPath } catch (ObjectNotFoundException e) { mAgentName = ""; } - } + } return mAgentName; } public RolePath[] getRoles() { - return Gateway.getLDAPLookup().getRoleManager().getRoles(this); + return Gateway.getLDAPLookup().getRoleManager().getRoles(this); } - + public boolean hasRole(RolePath role) { return Gateway.getLDAPLookup().getRoleManager().hasRole(this, role); } - + public boolean hasRole(String role) { try { return hasRole(Gateway.getLDAPLookup().getRoleManager().getRolePath(role)); @@ -106,12 +106,13 @@ public class AgentPath extends EntityPath return mPassword; } - public String dump() { + @Override + public String dump() { return super.dump()+ "\n agentID="+ mAgentName; - } - + } + static String generateUserPassword(String pass, String algo) throws NoSuchAlgorithmException { MessageDigest sha = MessageDigest.getInstance(algo); sha.reset(); @@ -121,21 +122,22 @@ public class AgentPath extends EntityPath digest.append(Base64.encode(hash)); return digest.toString(); } - - public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated + + @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("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"))); @@ -144,9 +146,9 @@ public class AgentPath extends EntityPath } else throw new ObjectCannotBeUpdated("Cannot create agent. No password given", ""); - + return attrs; } - + } -- cgit v1.2.3