summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java')
-rw-r--r--src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java72
1 files changed, 38 insertions, 34 deletions
diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java
index 372a91c..96fe82b 100644
--- a/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java
+++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java
@@ -9,6 +9,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
+import java.util.UUID;
import org.omg.CORBA.Object;
@@ -166,21 +167,25 @@ public class LDAPLookup implements LookupManager
@Override
public ItemPath resolvePath(DomainPath domPath)
throws InvalidItemPathException, ObjectNotFoundException {
- ItemPath referencedPath = null;
+
LDAPEntry domEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(),
getFullDN(domPath), LDAPSearchConstraints.DEREF_ALWAYS);
String entityKey = LDAPLookupUtils.getFirstAttributeValue(domEntry,
- "intsyskey");
+ "cn");
Logger.msg(7, "DomainPath " + domPath + " is a reference to "
+ entityKey);
String objClass = LDAPLookupUtils.getFirstAttributeValue(domEntry,
"objectClass");
- if (objClass.equals("cristalagent"))
- referencedPath = new AgentPath(Integer.parseInt(entityKey));
- else
- referencedPath = new ItemPath(Integer.parseInt(entityKey));
+ try {
+ ItemPath referencedPath = new ItemPath(UUID.fromString(entityKey));
+ if (objClass.equals("cristalagent"))
+ return new AgentPath(referencedPath);
+
+ return referencedPath;
+ } catch (IllegalArgumentException ex) {
+ throw new InvalidItemPathException(entityKey);
+ }
- return referencedPath;
}
@@ -194,7 +199,7 @@ public class LDAPLookup implements LookupManager
LDAPEntry newEntry = new LDAPEntry(getFullDN(path),attrSet);
LDAPLookupUtils.addEntry(mLDAPAuth.getAuthObject(),newEntry);
if (path instanceof DomainPath)
- Gateway.getProxyServer().sendProxyEvent(new ProxyMessage(ProxyMessage.NA, path.toString(), ProxyMessage.ADDED));
+ Gateway.getProxyServer().sendProxyEvent(new ProxyMessage(null, path.toString(), ProxyMessage.ADDED));
} catch (LDAPException ex) {
if (ex.getResultCode() == LDAPException.ENTRY_ALREADY_EXISTS)
throw new ObjectAlreadyExistsException(ex.getLDAPErrorMessage(), "");
@@ -214,7 +219,7 @@ public class LDAPLookup implements LookupManager
throw new ObjectCannotBeUpdated(ex.getLDAPErrorMessage(), "");
}
if (path instanceof DomainPath) {
- Gateway.getProxyServer().sendProxyEvent(new ProxyMessage(ProxyMessage.NA, path.toString(), ProxyMessage.DELETED));
+ Gateway.getProxyServer().sendProxyEvent(new ProxyMessage(null, path.toString(), ProxyMessage.DELETED));
}
}
@@ -364,16 +369,16 @@ public class LDAPLookup implements LookupManager
}
@Override
- public ItemPath getItemPath(int sysKey) throws ObjectNotFoundException, InvalidItemPathException {
+ public ItemPath getItemPath(UUID uuid) throws ObjectNotFoundException, InvalidItemPathException {
String[] attr = { LDAPConnection.ALL_USER_ATTRS };
try {
- ItemPath item = new ItemPath(sysKey);
+ ItemPath item = new ItemPath(uuid);
LDAPEntry anEntry=mLDAPAuth.getAuthObject().read(getDN(item)+mLocalPath,attr);
String type = LDAPLookupUtils.getFirstAttributeValue(anEntry, "objectClass");
if (type.equals("cristalentity"))
return item;
else if (type.equals("cristalagent"))
- return new AgentPath(sysKey);
+ return new AgentPath(item);
else
throw new ObjectNotFoundException("Not an entity", "");
@@ -394,29 +399,35 @@ public class LDAPLookup implements LookupManager
protected Path nodeToPath(LDAPEntry entry) throws InvalidItemPathException, ObjectNotFoundException
{
String dn = entry.getDN();
+ UUID entityKey;
+ org.omg.CORBA.Object ior;
// extract syskey
- int entityKey = -1;
try {
- String entityKeyStr = LDAPLookupUtils.getFirstAttributeValue(entry,"intsyskey");
- entityKey = Integer.parseInt(entityKeyStr);
- } catch (Exception e) { }
+ String entityKeyStr = LDAPLookupUtils.getFirstAttributeValue(entry,"cn");
+ entityKey = UUID.fromString(entityKeyStr);
+ } catch (ObjectNotFoundException ex) {
+ entityKey = null;
+ } catch (IllegalArgumentException ex) {
+ entityKey = null;
+ }
+
// extract IOR
- org.omg.CORBA.Object ior = null;
try {
- String stringIOR = LDAPLookupUtils.getFirstAttributeValue(entry,"ior");
- ior = Gateway.getORB().string_to_object(stringIOR);
- } catch (ObjectNotFoundException e2) { }
-
+ String stringIOR = LDAPLookupUtils.getFirstAttributeValue(entry,"ior");
+ ior = Gateway.getORB().string_to_object(stringIOR);
+ } catch (ObjectNotFoundException ex) {
+ ior = null;
+ }
+
/* Find the right path class */
Path thisPath;
if (LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalagent"))
{ //cristalagent
String agentID = LDAPLookupUtils.getFirstAttributeValue(entry,"uid");
- thisPath = new AgentPath(entityKey, agentID);
+ thisPath = new AgentPath(new ItemPath(entityKey), agentID);
}
-
else if (LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalrole"))
{ //cristalrole
thisPath = new RolePath(LDAPDN.explodeDN(dn,true)[0],
@@ -433,14 +444,8 @@ public class LDAPLookup implements LookupManager
(LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalcontext") && dn.endsWith(mItemTypeRoot)))
{
if(dn.endsWith(mItemTypeRoot)) {
- ItemPath entityPath;
- if (entityKey != -1)
- entityPath = new ItemPath(entityKey);
- else {
- entityPath = new ItemPath();
- entityPath.setPath(getPathComponents(dn.substring(0, dn.lastIndexOf(mItemTypeRoot))));
- }
- thisPath = entityPath;
+ ItemPath entityPath = new ItemPath(entityKey);
+ thisPath = entityPath;
}
else
throw new ObjectNotFoundException("Entity found outside entity tree");
@@ -511,7 +516,7 @@ public class LDAPLookup implements LookupManager
DomainPath domPath = (DomainPath)path;
attrs.add(new LDAPAttribute("cn",domPath.getName()));
try {
- attrs.add(new LDAPAttribute("aliasedObjectName",getFullDN(domPath.getEntity())));
+ attrs.add(new LDAPAttribute("aliasedObjectName",getFullDN(domPath.getItemPath())));
String objectclass_values[] = { "alias", "aliasObject" };
attrs.add(new LDAPAttribute("objectclass",objectclass_values));
} catch (ObjectNotFoundException e) { // no entity - is a context
@@ -521,8 +526,7 @@ public class LDAPLookup implements LookupManager
else if (path instanceof ItemPath) {
ItemPath itemPath = (ItemPath)path;
- attrs.add(new LDAPAttribute("intsyskey",Integer.toString(itemPath.getSysKey())));
- attrs.add(new LDAPAttribute("cn", itemPath.getPath()[itemPath.getPath().length-1]));
+ attrs.add(new LDAPAttribute("cn", itemPath.getUUID().toString()));
if (itemPath.getIOR() != null)
attrs.add(new LDAPAttribute("ior", Gateway.getORB().object_to_string(itemPath.getIOR())));