summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lookup/AgentPath.java
diff options
context:
space:
mode:
authorogattaz <olivier@gattaz.com>2014-06-05 16:51:07 +0200
committerogattaz <olivier@gattaz.com>2014-06-05 16:51:07 +0200
commit2fd193d7936084de91eae46e8c2763914d87ab71 (patch)
treeb136ed97e535f11d4b3433d16c26570c89430ce4 /src/main/java/com/c2kernel/lookup/AgentPath.java
parent1225792532f77e6e8f4a9addfc0c0a6cf56e89b8 (diff)
parente73468fd08cc27aa31f76a27c916e45d5987c628 (diff)
Merge branch 'master' of ssh://dev.cccs.uwe.ac.uk:22/var/git/cristal-kernel
Diffstat (limited to 'src/main/java/com/c2kernel/lookup/AgentPath.java')
-rw-r--r--src/main/java/com/c2kernel/lookup/AgentPath.java52
1 files changed, 10 insertions, 42 deletions
diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java
index 5ff6988..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;
/**
@@ -29,14 +25,14 @@ import com.novell.ldap.LDAPEntry;
* @version $Revision: 1.12 $ $Date: 2005/10/13 08:15:00 $
* @author $Author: abranson $
**/
-public class AgentPath extends EntityPath
+public class AgentPath extends ItemPath
{
private String mAgentName=null;
private String mPassword=null;
public AgentPath(int syskey, String agentName)
- throws InvalidAgentPathException,InvalidEntityPathException
+ throws InvalidAgentPathException,InvalidItemPathException
{
super(syskey);
if (agentName!=null && agentName.length()>0)
@@ -46,16 +42,16 @@ public class AgentPath extends EntityPath
}
public AgentPath(int syskey)
- throws InvalidEntityPathException
+ throws InvalidItemPathException
{
super(syskey);
}
- public AgentPath(EntityPath entity) {
+ public AgentPath(ItemPath entity) {
super();
try {
setSysKey(entity.getSysKey());
- } catch (InvalidEntityPathException ex) {
+ } catch (InvalidItemPathException ex) {
//won't happen as the entity path was valid
}
}
@@ -70,8 +66,7 @@ public class AgentPath extends EntityPath
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 EntityPath
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 EntityPath
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 EntityPath
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;
- }
-
}