summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lookup/AgentPath.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-06-02 11:31:08 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-06-02 11:31:08 +0200
commitb96dd998d6c442be19c342399839896d00d4b6f5 (patch)
tree51a0a07647e1d439d0adefdb57e6818a15d179ec /src/main/java/com/c2kernel/lookup/AgentPath.java
parent42adf60503b73c5106b30ba57fdeba13b3091169 (diff)
Initial commit
Diffstat (limited to 'src/main/java/com/c2kernel/lookup/AgentPath.java')
-rw-r--r--src/main/java/com/c2kernel/lookup/AgentPath.java42
1 files changed, 5 insertions, 37 deletions
diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java
index a560795..a0bb7fd 100644
--- a/src/main/java/com/c2kernel/lookup/AgentPath.java
+++ b/src/main/java/com/c2kernel/lookup/AgentPath.java
@@ -15,12 +15,8 @@ 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.process.Gateway;
-import com.novell.ldap.LDAPAttribute;
-import com.novell.ldap.LDAPAttributeSet;
-import com.novell.ldap.LDAPEntry;
/**
@@ -70,8 +66,7 @@ public class AgentPath extends ItemPath
if (mAgentName==null)
{
try {
- LDAPEntry agentEntry = LDAPLookupUtils.getEntry(Gateway.getLDAPLookup().getConnection(), this.getDN() + mLocalPath);
- mAgentName = LDAPLookupUtils.getFirstAttributeValue(agentEntry,"uid");
+ mAgentName = Gateway.getLookup().getAgentName(this);
} catch (ObjectNotFoundException e) {
mAgentName = "";
}
@@ -81,16 +76,16 @@ public class AgentPath extends ItemPath
public RolePath[] getRoles()
{
- return Gateway.getLDAPLookup().getRoleManager().getRoles(this);
+ return Gateway.getLookup().getRoles(this);
}
public boolean hasRole(RolePath role) {
- return Gateway.getLDAPLookup().getRoleManager().hasRole(this, role);
+ return Gateway.getLookup().hasRole(this, role);
}
public boolean hasRole(String role) {
try {
- return hasRole(Gateway.getLDAPLookup().getRoleManager().getRolePath(role));
+ return hasRole(Gateway.getLookup().getRolePath(role));
} catch (ObjectNotFoundException ex) {
return false;
}
@@ -113,7 +108,7 @@ public class AgentPath extends ItemPath
mAgentName;
}
- static String generateUserPassword(String pass, String algo) throws NoSuchAlgorithmException {
+ public static String generateUserPassword(String pass, String algo) throws NoSuchAlgorithmException {
MessageDigest sha = MessageDigest.getInstance(algo);
sha.reset();
sha.update(pass.getBytes());
@@ -123,32 +118,5 @@ public class AgentPath extends ItemPath
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;
- }
-
}