summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lookup/AgentPath.java
diff options
context:
space:
mode:
authorabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
committerabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
commit0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch)
tree5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/lookup/AgentPath.java
parent036cbdba66f804743c4c838ed598d6972c4b3e17 (diff)
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
Diffstat (limited to 'source/com/c2kernel/lookup/AgentPath.java')
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/lookup/AgentPath.java48
1 files changed, 25 insertions, 23 deletions
diff --git a/source/com/c2kernel/lookup/AgentPath.java b/source/com/c2kernel/lookup/AgentPath.java
index 01c764f..5ff6988 100755..100644
--- 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;
}
-
+
}