From b96dd998d6c442be19c342399839896d00d4b6f5 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 2 Jun 2014 11:31:08 +0200 Subject: Initial commit --- src/main/java/com/c2kernel/lookup/AgentPath.java | 42 +++--------------------- 1 file changed, 5 insertions(+), 37 deletions(-) (limited to 'src/main/java/com/c2kernel/lookup/AgentPath.java') 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; - } - } -- cgit v1.2.3