diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-06-05 15:02:07 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-06-05 15:02:07 +0200 |
| commit | d4fa3bd9dd48f4d5e26850a23f5ba48a9c10ad64 (patch) | |
| tree | 5ad7bfbce8ba9df9aad53ef33a8b908ca0680fc4 /src/main/java/com/c2kernel/lookup/AgentPath.java | |
| parent | 8bb86312d4f07dcb343ca2d212f4020906dbdb52 (diff) | |
LDAP refactored behind interfaces. All functions of LDAP now hidden
behind interfaces: Authenticator, Lookup and NextKeyManager (LDAP
property storage was already a ClusterStorage). Gateway holds additional
objects, and
Fixes #26 #191. Refs #27 (needs additional work for read perms and auth
tokens)
Diffstat (limited to 'src/main/java/com/c2kernel/lookup/AgentPath.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lookup/AgentPath.java | 42 |
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;
- }
-
}
|
