summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lookup
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/lookup')
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/lookup/AgentPath.java48
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/lookup/DomainPath.java43
-rw-r--r--source/com/c2kernel/lookup/EntityPath.java51
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/lookup/LDAPLookup.java119
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/lookup/LDAPLookupUtils.java56
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/lookup/LDAPPathSet.java20
-rw-r--r--source/com/c2kernel/lookup/LDAPPropertyManager.java10
-rw-r--r--source/com/c2kernel/lookup/LDAPRoleManager.java75
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/lookup/LegacyLDAPPropertyManager.java9
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/lookup/NextKeyManager.java17
-rw-r--r--source/com/c2kernel/lookup/Path.java58
-rw-r--r--source/com/c2kernel/lookup/RolePath.java38
12 files changed, 285 insertions, 259 deletions
diff --git a/source/com/c2kernel/lookup/AgentPath.java b/source/com/c2kernel/lookup/AgentPath.java
index 01c764f..5ff6988 100755..100644
--- a/source/com/c2kernel/lookup/AgentPath.java
+++ b/source/com/c2kernel/lookup/AgentPath.java
@@ -31,26 +31,26 @@ import com.novell.ldap.LDAPEntry;
**/
public class AgentPath extends EntityPath
{
-
+
private String mAgentName=null;
private String mPassword=null;
-
- public AgentPath(int syskey, String agentName)
- throws InvalidAgentPathException,InvalidEntityPathException
+
+ public AgentPath(int syskey, String agentName)
+ throws InvalidAgentPathException,InvalidEntityPathException
{
super(syskey);
if (agentName!=null && agentName.length()>0)
setAgentName(agentName);
- else
+ else
throw new InvalidAgentPathException();
}
-
+
public AgentPath(int syskey)
- throws InvalidEntityPathException
+ throws InvalidEntityPathException
{
super(syskey);
}
-
+
public AgentPath(EntityPath entity) {
super();
try {
@@ -59,7 +59,7 @@ public class AgentPath extends EntityPath
//won't happen as the entity path was valid
}
}
-
+
public void setAgentName(String agentID)
{
mAgentName = agentID;
@@ -75,19 +75,19 @@ public class AgentPath extends EntityPath
} catch (ObjectNotFoundException e) {
mAgentName = "";
}
- }
+ }
return mAgentName;
}
public RolePath[] getRoles()
{
- return Gateway.getLDAPLookup().getRoleManager().getRoles(this);
+ return Gateway.getLDAPLookup().getRoleManager().getRoles(this);
}
-
+
public boolean hasRole(RolePath role) {
return Gateway.getLDAPLookup().getRoleManager().hasRole(this, role);
}
-
+
public boolean hasRole(String role) {
try {
return hasRole(Gateway.getLDAPLookup().getRoleManager().getRolePath(role));
@@ -106,12 +106,13 @@ public class AgentPath extends EntityPath
return mPassword;
}
- public String dump() {
+ @Override
+ public String dump() {
return super.dump()+
"\n agentID="+
mAgentName;
- }
-
+ }
+
static String generateUserPassword(String pass, String algo) throws NoSuchAlgorithmException {
MessageDigest sha = MessageDigest.getInstance(algo);
sha.reset();
@@ -121,21 +122,22 @@ public class AgentPath extends EntityPath
digest.append(Base64.encode(hash));
return digest.toString();
}
-
- public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated
+
+ @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("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")));
@@ -144,9 +146,9 @@ public class AgentPath extends EntityPath
}
else
throw new ObjectCannotBeUpdated("Cannot create agent. No password given", "");
-
+
return attrs;
}
-
+
}
diff --git a/source/com/c2kernel/lookup/DomainPath.java b/source/com/c2kernel/lookup/DomainPath.java
index ad314ee..ce849ce 100755..100644
--- a/source/com/c2kernel/lookup/DomainPath.java
+++ b/source/com/c2kernel/lookup/DomainPath.java
@@ -30,15 +30,15 @@ public class DomainPath extends Path
public DomainPath()
{
- super(Path.UNKNOWN);
+ super(Path.UNKNOWN);
}
public DomainPath(short type)
{
- super();
+ super();
mType = type;
}
-
+
public DomainPath(String[] path)
{
super(path, Path.UNKNOWN);
@@ -54,7 +54,7 @@ public class DomainPath extends Path
super(path, Path.UNKNOWN);
setEntity(entity);
}
-
+
public DomainPath(DomainPath parent, String child) {
super(parent, child);
}
@@ -62,47 +62,50 @@ public class DomainPath extends Path
/* the root of domain paths is /domain
* clearly
*/
- public String getRoot() {
+ @Override
+ public String getRoot() {
return "domain";
}
-
+
public DomainPath getParent() {
if (mPath.length == 0)
return null;
-
+
String[] parentPath = new String[mPath.length-1];
System.arraycopy(mPath, 0, parentPath, 0, parentPath.length);
return new DomainPath(parentPath);
}
-
+
public void setEntity(EntityPath newTarget) {
if (newTarget == null) { // clear
target = null;
mType = Path.CONTEXT;
return;
}
-
+
target = newTarget;
mType = Path.ENTITY;
}
-
- public EntityPath getEntity() throws ObjectNotFoundException {
+
+ @Override
+ public EntityPath getEntity() throws ObjectNotFoundException {
if (mType == UNKNOWN) { // must decide
checkType();
}
-
+
if (target == null)
throw new ObjectNotFoundException("Path is a context", "");
return target;
}
-
- public short getType() {
+
+ @Override
+ public short getType() {
if (mType == UNKNOWN) { // must decide
checkType();
}
return mType;
}
-
+
public void checkType() {
try {
setEntity(Gateway.getLDAPLookup().resolvePath(this));
@@ -114,7 +117,7 @@ public class DomainPath extends Path
}
}
-
+
/**
* Retrieves the domkey of the path
* @return the last path component;
@@ -123,18 +126,20 @@ public class DomainPath extends Path
return mPath[mPath.length-1];
}
- public int getSysKey() {
+ @Override
+ public int getSysKey() {
if (mType == UNKNOWN) { // must decide
checkType();
}
-
+
if (mType == ENTITY) {
return target.getSysKey();
}
else return INVALID;
}
- public LDAPAttributeSet createAttributeSet() {
+ @Override
+ public LDAPAttributeSet createAttributeSet() {
LDAPAttributeSet attrs = new LDAPAttributeSet();
attrs.add(new LDAPAttribute("cn",getName()));
if (getType() == ENTITY) {
diff --git a/source/com/c2kernel/lookup/EntityPath.java b/source/com/c2kernel/lookup/EntityPath.java
index 3a24228..4f9b771 100644
--- a/source/com/c2kernel/lookup/EntityPath.java
+++ b/source/com/c2kernel/lookup/EntityPath.java
@@ -39,12 +39,12 @@ public class EntityPath extends Path
* Note no EntityPath constructors allow setting of CONTEXT or ENTITY:
* The object decides that for itself from the number of components
*/
-
+
public EntityPath(int syskey) throws InvalidEntityPathException {
super();
setSysKey(syskey);
}
-
+
/*
*/
public EntityPath()
@@ -55,15 +55,15 @@ public class EntityPath extends Path
/*
*/
- public EntityPath(String[] path) throws InvalidEntityPathException
+ public EntityPath(String[] path) throws InvalidEntityPathException
{
- super(path, Path.CONTEXT); // dummy - it will get replaced in checkSysPath()
+ super(path, Path.CONTEXT); // dummy - it will get replaced in checkSysPath()
checkSysPath();
}
/*
*/
- public EntityPath(String path) throws InvalidEntityPathException
+ public EntityPath(String path) throws InvalidEntityPathException
{
super(path, Path.CONTEXT);
checkSysPath();
@@ -75,33 +75,35 @@ public class EntityPath extends Path
super(parent, child);
checkSysPath();
}
-
+
// EntityPaths root in /entity
- public String getRoot() {
+ @Override
+ public String getRoot() {
return "entity";
}
-
- public EntityPath getEntity() throws ObjectNotFoundException {
+
+ @Override
+ public EntityPath getEntity() throws ObjectNotFoundException {
return this;
}
-
+
public byte[] getOID() {
if (mSysKey == Path.INVALID) return null;
return String.valueOf(mSysKey).getBytes();
}
/*************************************************************************/
-
+
/** Returns int form of syskey (if possible)
*/
- public int getSysKey() {
- if (mSysKey == Path.INVALID && mType == Path.ENTITY)
+ @Override
+ public int getSysKey() {
+ if (mSysKey == Path.INVALID && mType == Path.ENTITY)
try {
if (mPath.length != elementNo)
throw new InvalidEntityPathException("Incorrect number of components for a system key");
mSysKey = 0;
- for (int i=0; i<mPath.length;i++) {
- String keypart = mPath[i];
+ for (String keypart : mPath) {
if (keypart.length()!=elementLen+1)
throw new InvalidEntityPathException("Component '"+keypart+"' is not the correct size for a system key");
for(int j=1; j<elementLen+1; j++) // skip the 'd' prefix
@@ -119,12 +121,12 @@ public class EntityPath extends Path
}
return mSysKey;
}
-
+
/** Sets path from int syskey
*/
public void setSysKey(int sysKey) throws InvalidEntityPathException
{
- if (sysKey < 0 || sysKey > maxSysKey)
+ if (sysKey < 0 || sysKey > maxSysKey)
throw new InvalidEntityPathException("System key "+sysKey+" out of range");
String stringPath = Integer.toString(sysKey);
ArrayList<String> newKey = new ArrayList<String>();
@@ -142,31 +144,32 @@ public class EntityPath extends Path
newKey.add(0, nextComponent.toString());
}
- mPath = (String[])(newKey.toArray(mPath));
+ mPath = (newKey.toArray(mPath));
mSysKey = sysKey;
mStringPath = null;
- mDN = null;
+ mDN = null;
mType = Path.ENTITY;
checkSysPath();
- }
+ }
public void checkSysPath() throws InvalidEntityPathException {
if (mPath.length > elementNo)
throw new InvalidEntityPathException("EntityPath cannot have more than "+elementNo+" components: "+toString());
- if (mPath.length == elementNo)
+ if (mPath.length == elementNo)
mType = Path.ENTITY;
else
mType = Path.CONTEXT;
}
- public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated {
- LDAPAttributeSet attrs = new LDAPAttributeSet();
+ @Override
+ public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated {
+ LDAPAttributeSet attrs = new LDAPAttributeSet();
attrs.add(new LDAPAttribute("objectclass","cristalentity"));
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)));
return attrs;
- }
+ }
}
diff --git a/source/com/c2kernel/lookup/LDAPLookup.java b/source/com/c2kernel/lookup/LDAPLookup.java
index 04d99f0..9bae873 100755..100644
--- a/source/com/c2kernel/lookup/LDAPLookup.java
+++ b/source/com/c2kernel/lookup/LDAPLookup.java
@@ -5,7 +5,6 @@
package com.c2kernel.lookup;
-import java.util.Enumeration;
import java.util.StringTokenizer;
import com.c2kernel.common.ObjectAlreadyExistsException;
@@ -18,10 +17,16 @@ import com.c2kernel.entity.proxy.ProxyMessage;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
import com.c2kernel.utils.Resource;
-import com.novell.ldap.*;
+import com.novell.ldap.LDAPAttributeSet;
+import com.novell.ldap.LDAPConnection;
+import com.novell.ldap.LDAPDN;
+import com.novell.ldap.LDAPEntry;
+import com.novell.ldap.LDAPException;
+import com.novell.ldap.LDAPSearchConstraints;
+import com.novell.ldap.LDAPSearchResults;
/**
- * The LDAPLookup object, statically accessible through the Gateway, manages
+ * The LDAPLookup object, statically accessible through the Gateway, manages
* the LDAP connection for the cristal process. It provides:
* <ul>
* <li>Authentication - returning an AgentProxy object if a user has logged in
@@ -32,7 +37,7 @@ import com.novell.ldap.*;
* @author $Author: abranson $
*/
-public class LDAPLookup
+public class LDAPLookup
{
private LDAPConnection mLDAPConn;
@@ -40,30 +45,30 @@ public class LDAPLookup
private NextKeyManager mNextKeyManager;
private LDAPPropertyManager mPropManager;
private LDAPRoleManager mRoleManager;
-
-
+
+
/**
- * Creates a new LDAPLookup manager with the properties supplied.
+ * Creates a new LDAPLookup manager with the properties supplied.
* This should be only done by the Gateway during initialisation.
- *
+ *
* @param props The LDAP properties object that extracts LDAP connection properties from the global c2kprops
*/
public LDAPLookup(LDAPProperties props) throws LDAPException
{
Logger.msg(8,"LDAPLookup - initialising.");
-
+
mLDAPProps = props;
-
+
mLDAPConn = createConnection(mLDAPProps);
-
+
Path.mGlobalPath=props.mGlobalPath;
Path.mRootPath=props.mRootPath;
Path.mLocalPath=props.mLocalPath;
-
+
EntityPath.mTypeRoot = "cn=entity,"+props.mLocalPath;
DomainPath.mTypeRoot = "cn=domain,"+props.mLocalPath;
-
+
mNextKeyManager = new NextKeyManager(this, "cn=last,"+EntityPath.mTypeRoot);
Logger.debug("LDAP.useOldProps="+Gateway.getProperty("LDAP.useOldProps", "false"));
if (Gateway.getProperty("LDAP.useOldProps", "false").equals("true")) {
@@ -77,9 +82,9 @@ public class LDAPLookup
mRoleManager = new LDAPRoleManager(this, "cn=agent,"+DomainPath.mTypeRoot, EntityPath.mTypeRoot);
}
-
+
/**
- * Utility method to connect to an LDAP server
+ * Utility method to connect to an LDAP server
* @param lp LDAP properties to connect with
* @return a novell LDAPConnection object
* @throws LDAPException when the connection was unsuccessful
@@ -92,13 +97,13 @@ public class LDAPLookup
Logger.msg(3, "LDAPLookup - authenticating user:" + lp.mUser);
ld.bind( LDAPConnection.LDAP_V3, lp.mUser,
- String.valueOf(lp.mPassword).getBytes());
+ String.valueOf(lp.mPassword).getBytes());
Logger.msg(3, "LDAPLookup - authentication successful");
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setMaxResults(0);
ld.setConstraints(searchCons);
-
+
return ld;
}
@@ -110,7 +115,7 @@ public class LDAPLookup
{
return mNextKeyManager;
}
-
+
/**
* Gets the property manager, that is used to read and write cristal properties to the LDAP store.
* @return Returns the global LDAPPropertyManager.
@@ -124,23 +129,23 @@ public class LDAPLookup
*/
public LDAPRoleManager getRoleManager() {
return mRoleManager;
- }
+ }
/**
* Returns the current LDAP connection, and attempts to reconnect if it has been closed.
* @return
*/
- protected LDAPConnection getConnection()
- {
+ protected LDAPConnection getConnection()
+ {
if (!mLDAPConn.isConnected()) {
Logger.warning("LDAPLookup - lost connection to LDAP server. Attempting to reconnect.");
try {
mLDAPConn = createConnection(mLDAPProps);
} catch (LDAPException ex) { }
}
- return mLDAPConn;
+ return mLDAPConn;
}
-
+
/**
* Disconnects the connection with the LDAP server during shutdown
*/
@@ -156,7 +161,7 @@ public class LDAPLookup
}
}
- /**
+ /**
* Attempts to resolve the CORBA object for a Path, either directly or through an alias.
* @param path the path to resolve
* @return the CORBA object
@@ -197,13 +202,13 @@ public class LDAPLookup
}
/**
- *
+ *
* @param domPath
* @return
* @throws InvalidEntityPathException
* @throws ObjectNotFoundException
*/
- protected EntityPath resolvePath(DomainPath domPath)
+ protected EntityPath resolvePath(DomainPath domPath)
throws InvalidEntityPathException, ObjectNotFoundException {
EntityPath referencedPath = null;
LDAPEntry domEntry = LDAPLookupUtils.getEntry(getConnection(), domPath
@@ -221,12 +226,11 @@ public class LDAPLookup
return referencedPath;
}
-
+
public LDAPEntry add(Path path)
throws ObjectCannotBeUpdated, ObjectAlreadyExistsException
{
- String root = path.getRoot();
try {
checkLDAPContext(path);
LDAPAttributeSet attrSet = path.createAttributeSet();
@@ -256,10 +260,9 @@ public class LDAPLookup
EntityProxyManager.sendProxyEvent(new ProxyMessage(ProxyMessage.NA, path.toString(), ProxyMessage.DELETED));
}
}
-
+
//change specs, add boolean alias leaf context
protected void checkLDAPContext(Path path)
- throws LDAPException
{
String dn = path.getFullDN();
if (!LDAPLookupUtils.exists(getConnection(),dn))
@@ -290,7 +293,7 @@ public class LDAPLookup
public void createBootTree()
{
Logger.msg(8,"Initializing LDAP Boot tree");
-
+
//create org
LDAPLookupUtils.createOrganizationContext(getConnection(), Path.mGlobalPath);
//create root
@@ -298,13 +301,13 @@ public class LDAPLookup
//create local
LDAPLookupUtils.createCristalContext(getConnection(), Path.mLocalPath);
}
-
- public void install() throws LDAPException
+
+ public void install()
{
createBootTree();
initTree( Resource.getTextResource("boot/LDAPboot.txt"));
}
-
+
public void initTree(String bootFile)
{
Logger.msg(8,"Verifying Cristal LDAP roots");
@@ -315,21 +318,21 @@ public class LDAPLookup
Logger.msg(8,"Checking " + line+Path.mLocalPath);
LDAPLookupUtils.createCristalContext(getConnection(), line+Path.mLocalPath);
}
-
- }
-
+
+ }
+
//typically search for cn=barcode
- public Enumeration search(Path start, String filter)
+ public LDAPPathSet search(Path start, String filter)
{
Logger.msg(8,"LDAPLookup::search() From " + start.getDN() + " for cn=" + filter );
return search(start.getFullDN(),"cn="+LDAPLookupUtils.escapeSearchFilter(filter));
}
-
- protected Enumeration search(String startDN, int scope, String filter, LDAPSearchConstraints searchCons)
- {
+
+ protected LDAPPathSet search(String startDN, int scope, String filter, LDAPSearchConstraints searchCons)
+ {
Logger.msg(8,"Searching for "+filter+" in "+startDN);
searchCons.setMaxResults(0);
- String[] attr = { LDAPConnection.ALL_USER_ATTRS };
+ String[] attr = { LDAPConnection.ALL_USER_ATTRS };
try
{
LDAPSearchResults res = getConnection().search(LDAPLookupUtils.escapeDN(startDN),scope,
@@ -341,9 +344,9 @@ public class LDAPLookup
Logger.error("LDAPException::LDAPLookup::search() " + ex.toString());
return new LDAPPathSet();
}
- }
+ }
//typically search for (any filter combination)
- public Enumeration search(String startDN,String filter)
+ public LDAPPathSet search(String startDN,String filter)
{
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
@@ -351,14 +354,14 @@ public class LDAPLookup
return search(startDN,LDAPConnection.SCOPE_SUB,filter,searchCons);
}
- public Enumeration searchEntities(Path start) {
+ public LDAPPathSet searchEntities(Path start) {
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
searchCons.setDereference(LDAPSearchConstraints.DEREF_SEARCHING);
return search(start.getFullDN(), LDAPConnection.SCOPE_SUB, "objectClass=cristalentity", searchCons);
}
-
- public Enumeration searchAliases(DomainPath start) {
+
+ public LDAPPathSet searchAliases(DomainPath start) {
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
searchCons.setDereference(LDAPSearchConstraints.DEREF_NEVER);
@@ -368,8 +371,8 @@ public class LDAPLookup
public boolean exists(Path path) {
return LDAPLookupUtils.exists(getConnection(), path.getFullDN());
}
-
- public Class getEntityClass(Path path) throws ObjectNotFoundException {
+
+ public Class<?> getEntityClass(Path path) throws ObjectNotFoundException {
String[] attr = { LDAPConnection.ALL_USER_ATTRS };
try {
LDAPEntry anEntry=getConnection().read(path.getDN()+Path.mLocalPath,attr);
@@ -380,7 +383,7 @@ public class LDAPLookup
return ActiveEntity.class;
else
throw new ObjectNotFoundException("Not an entity", "");
-
+
} catch (LDAPException ex) {
if (ex.getResultCode() == LDAPException.NO_SUCH_OBJECT)
throw new ObjectNotFoundException("Entity does not exist", "");
@@ -388,7 +391,7 @@ public class LDAPLookup
throw new ObjectNotFoundException("Error getting entity class", "");
}
}
-
+
/** converts an LDAPentry to a Path object
* Note that the search producing the entry should have retrieved the attrs
* 'ior' and 'uniquemember'
@@ -398,14 +401,14 @@ public class LDAPLookup
protected Path nodeToPath(LDAPEntry entry) throws InvalidEntityPathException, ObjectNotFoundException
{
String dn = entry.getDN();
-
+
// extract syskey
int entityKey = -1;
try {
String entityKeyStr = LDAPLookupUtils.getFirstAttributeValue(entry,"intsyskey");
entityKey = Integer.parseInt(entityKeyStr);
} catch (Exception e) { }
-
+
// extract IOR
org.omg.CORBA.Object ior = null;
try {
@@ -420,10 +423,10 @@ public class LDAPLookup
String agentID = LDAPLookupUtils.getFirstAttributeValue(entry,"uid");
thisPath = new AgentPath(entityKey, agentID);
}
-
+
else if (LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalrole"))
{ //cristalrole
- thisPath = new RolePath(LDAPDN.explodeDN(dn,true)[0],
+ thisPath = new RolePath(LDAPDN.explodeDN(dn,true)[0],
LDAPLookupUtils.getFirstAttributeValue(entry, "jobList").equals("TRUE"));
}
else if (LDAPLookupUtils.existsAttributeValue(entry,"objectclass","aliasObject") ||
@@ -431,7 +434,7 @@ public class LDAPLookup
{
DomainPath domainPath = new DomainPath();
domainPath.setDN(dn);
- thisPath = domainPath;
+ thisPath = domainPath;
}
else if (LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalentity") ||
(LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalcontext") && dn.endsWith(EntityPath.mTypeRoot)))
@@ -452,8 +455,8 @@ public class LDAPLookup
else
{
throw new ObjectNotFoundException("Unrecognised LDAP entry. Not a cristal entry");
- }
-
+ }
+
//set IOR if we have one
if (ior!=null) thisPath.setIOR(ior);
return thisPath;
diff --git a/source/com/c2kernel/lookup/LDAPLookupUtils.java b/source/com/c2kernel/lookup/LDAPLookupUtils.java
index 6516374..8df365b 100755..100644
--- a/source/com/c2kernel/lookup/LDAPLookupUtils.java
+++ b/source/com/c2kernel/lookup/LDAPLookupUtils.java
@@ -49,7 +49,7 @@ final public class LDAPLookupUtils
{
return getEntry(ld, dn, LDAPSearchConstraints.DEREF_NEVER);
}
-
+
static public String getFirstAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFoundException
{
LDAPAttribute attr = anEntry.getAttribute(attribute);
@@ -61,11 +61,11 @@ final public class LDAPLookupUtils
static public String[] getAllAttributeValues(LDAPEntry anEntry, String attribute) throws ObjectNotFoundException
{
LDAPAttribute attr = anEntry.getAttribute(attribute);
- if (attr!=null)
+ if (attr!=null)
return attr.getStringValueArray();
-
+
throw new ObjectNotFoundException("No attributes named '"+attribute+"'", "");
-
+
}
static public boolean existsAttributeValue(LDAPEntry anEntry, String attribute, String value)
@@ -94,7 +94,7 @@ final public class LDAPLookupUtils
//this is for a single-valued attribute
static public void setAttributeValue(LDAPConnection ld, LDAPEntry anEntry, String attribute, String newValue)
throws ObjectNotFoundException, ObjectCannotBeUpdated
- {
+ {
try {
if (!hasOneAttributeValue(anEntry, attribute))
throw new ObjectCannotBeUpdated("Attribute "+attribute + " of entry " + anEntry.getDN()+" has more than one value", "");
@@ -102,26 +102,26 @@ final public class LDAPLookupUtils
addAttributeValue(ld, anEntry, attribute, newValue);
}
try
- {
+ {
ld.modify(anEntry.getDN(),new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute(attribute,newValue)));
- }
- catch (LDAPException ex)
+ }
+ catch (LDAPException ex)
{
Logger.error(ex);
throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be modified", "");
}
}
-
+
//this is for a multi-valued attribute eg uniqueMember
static public void addAttributeValue(LDAPConnection ld, LDAPEntry anEntry, String attribute, String value)
throws ObjectCannotBeUpdated
{
- try
+ try
{
- ld.modify(anEntry.getDN(),new LDAPModification(LDAPModification.ADD, new LDAPAttribute(attribute,value)));
- }
- catch (LDAPException ex)
+ ld.modify(anEntry.getDN(),new LDAPModification(LDAPModification.ADD, new LDAPAttribute(attribute,value)));
+ }
+ catch (LDAPException ex)
{
Logger.error(ex);
throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be added.", "");
@@ -131,18 +131,18 @@ final public class LDAPLookupUtils
//this is for a multi-valued attribute eg uniqueMember
static public void removeAttributeValue(LDAPConnection ld, LDAPEntry anEntry, String attribute, String value)
throws ObjectCannotBeUpdated
- {
+ {
try
{
ld.modify(anEntry.getDN(),new LDAPModification(LDAPModification.DELETE,new LDAPAttribute(attribute,value)));
- }
- catch (LDAPException ex)
+ }
+ catch (LDAPException ex)
{
Logger.error(ex);
throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be deleted", "");
}
}
-
+
static public boolean exists(LDAPConnection ld, String name)
{
try {
@@ -178,7 +178,7 @@ final public class LDAPLookupUtils
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
searchCons.setDereference(LDAPSearchConstraints.DEREF_NEVER);
-
+
try
{
LDAPSearchResults res = ld.search(dn,LDAPConnection.SCOPE_ONE,filter,attr,false,searchCons);
@@ -200,7 +200,7 @@ final public class LDAPLookupUtils
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
searchCons.setDereference(LDAPSearchConstraints.DEREF_NEVER);
-
+
try
{
LDAPSearchResults res = ld.search(dn,LDAPConnection.SCOPE_ONE,filter,attr,false,searchCons);
@@ -209,7 +209,7 @@ final public class LDAPLookupUtils
while (res.hasMore())
{
LDAPEntry findEntry=res.next();
- if (findEntry!=null)
+ if (findEntry!=null)
{
result[i++] = new String(findEntry.getDN());
}
@@ -254,9 +254,9 @@ final public class LDAPLookupUtils
objectclass_values[0] = "cristalcontext";
if (name.equals("last"))
attrs.add(new LDAPAttribute("intsyskey", "0"));
-
- attrs.add(new LDAPAttribute("objectclass",objectclass_values));
-
+
+ attrs.add(new LDAPAttribute("objectclass",objectclass_values));
+
LDAPLookupUtils.addEntry(ld,new LDAPEntry(dn,attrs));
}
catch (Exception ex)
@@ -269,7 +269,7 @@ final public class LDAPLookupUtils
{
if (LDAPLookupUtils.exists(ld,dn))
return;
-
+
try
{
String name = LDAPDN.explodeDN(dn,true)[0];
@@ -283,7 +283,7 @@ final public class LDAPLookupUtils
{
Logger.msg(ex.toString());
}
- }
+ }
public static String escapeDN (String name) {
//From RFC 2253 and the / character for JNDI
final char[] META_CHARS = {'+', '"', '<', '>', ';', '/'};
@@ -296,8 +296,8 @@ final public class LDAPLookupUtils
escapedStr = escapedStr.replaceAll("^#","\\\\#");
escapedStr = escapedStr.replaceAll("^ | $","\\\\ ");
- for (int i=0;i < META_CHARS.length;i++) {
- escapedStr = escapedStr.replaceAll("\\"+META_CHARS[i],"\\\\" + META_CHARS[i]);
+ for (char element : META_CHARS) {
+ escapedStr = escapedStr.replaceAll("\\"+element,"\\\\" + element);
}
Logger.msg(6, "LDAP DN "+name+" escaped to "+escapedStr);
return escapedStr;
@@ -313,5 +313,5 @@ final public class LDAPLookupUtils
escapedStr = escapedStr.replaceAll("\\)","\\\\29");
Logger.msg(6, "LDAP Search Filter "+filter+" escaped to "+escapedStr);
return escapedStr;
- }
+ }
}
diff --git a/source/com/c2kernel/lookup/LDAPPathSet.java b/source/com/c2kernel/lookup/LDAPPathSet.java
index 9c68c5c..d3cf7d9 100755..100644
--- a/source/com/c2kernel/lookup/LDAPPathSet.java
+++ b/source/com/c2kernel/lookup/LDAPPathSet.java
@@ -19,35 +19,37 @@ import com.novell.ldap.LDAPSearchResults;
-public class LDAPPathSet implements Enumeration {
+public class LDAPPathSet implements Enumeration<Path> {
LDAPSearchResults results;
LDAPEntry nextEntry;
-
+
public LDAPPathSet() { // empty
results = null;
}
-
+
public LDAPPathSet(LDAPSearchResults results) {
this.results = results;
}
-
- public boolean hasMoreElements() {
+
+ @Override
+ public boolean hasMoreElements() {
if (results == null) return false;
if (nextEntry != null) return true;
if (results.hasMore())
try {
nextEntry = results.next();
return true;
- } catch (LDAPException ex) {
+ } catch (LDAPException ex) {
if (ex.getResultCode()!=32) {// no results
Logger.error(ex);
Logger.error("Error loading LDAP result set: "+ex.getMessage());
}
- }
+ }
return false;
}
-
- public Object nextElement() {
+
+ @Override
+ public Path nextElement() {
if (results == null) return null;
try {
if (nextEntry == null)
diff --git a/source/com/c2kernel/lookup/LDAPPropertyManager.java b/source/com/c2kernel/lookup/LDAPPropertyManager.java
index a1fd6af..57ed17d 100644
--- a/source/com/c2kernel/lookup/LDAPPropertyManager.java
+++ b/source/com/c2kernel/lookup/LDAPPropertyManager.java
@@ -49,13 +49,13 @@ public class LDAPPropertyManager {
LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN());
ArrayList<String> propbag = new ArrayList<String>();
LDAPAttribute props = entityEntry.getAttribute("cristalprop");
- for (Enumeration e = props.getStringValues(); e.hasMoreElements();) {
+ for (Enumeration<?> e = props.getStringValues(); e.hasMoreElements();) {
String thisProp = (String)e.nextElement();
propbag.add(thisProp.substring(0, thisProp.indexOf(':')));
}
-
+
String[] retArr = new String[props.size()];
- return (String[])propbag.toArray(retArr);
+ return propbag.toArray(retArr);
}
/**
@@ -101,13 +101,13 @@ public class LDAPPropertyManager {
LDAPLookupUtils.addAttributeValue(ldap.getConnection(), entityEntry, "cristalprop", prop.getName()+":"+prop.getValue());
}
- private String getPropertyAttr(LDAPEntry myEntry, String propName) throws ObjectNotFoundException {
+ private static String getPropertyAttr(LDAPEntry myEntry, String propName) throws ObjectNotFoundException {
// delete existing props
LDAPAttribute props = myEntry.getAttribute("cristalprop");
if (props == null)
throw new ObjectNotFoundException("Property "+propName+" does not exist", "");
String propPrefix = propName+":";
- for (Enumeration e = props.getStringValues(); e.hasMoreElements();) {
+ for (Enumeration<?> e = props.getStringValues(); e.hasMoreElements();) {
String val = (String)e.nextElement();
if (val.toLowerCase().startsWith(propPrefix.toLowerCase()))
return val.substring(propPrefix.length());
diff --git a/source/com/c2kernel/lookup/LDAPRoleManager.java b/source/com/c2kernel/lookup/LDAPRoleManager.java
index a45da13..1df2f29 100644
--- a/source/com/c2kernel/lookup/LDAPRoleManager.java
+++ b/source/com/c2kernel/lookup/LDAPRoleManager.java
@@ -7,7 +7,10 @@ import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectCannotBeUpdated;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.utils.Logger;
-import com.novell.ldap.*;
+import com.novell.ldap.LDAPConnection;
+import com.novell.ldap.LDAPEntry;
+import com.novell.ldap.LDAPException;
+import com.novell.ldap.LDAPSearchConstraints;
/**************************************************************************
*
@@ -27,7 +30,7 @@ public class LDAPRoleManager {
LDAPLookup mLdap;
private String mRolePath;
private String mEntityPath;
-
+
public LDAPRoleManager(LDAPLookup ldap, String rolePath, String entityPath) {
super();
this.mLdap = ldap;
@@ -44,14 +47,14 @@ public class LDAPRoleManager {
// create the role
RolePath rolePath = new RolePath(roleName, jobList);
- String roleDN = rolePath.getFullDN();
+ String roleDN = rolePath.getFullDN();
LDAPEntry roleNode;
try
- {
+ {
roleNode = LDAPLookupUtils.getEntry(mLdap.getConnection(), rolePath.getFullDN());
throw new ObjectAlreadyExistsException();
} catch (ObjectNotFoundException ex) { }
-
+
//create CristalRole if it does not exist
roleNode = new LDAPEntry(roleDN, rolePath.createAttributeSet());
try {
@@ -60,7 +63,7 @@ public class LDAPRoleManager {
throw new ObjectCannotBeUpdated(e.getLDAPErrorMessage(), "");
}
return rolePath;
-
+
}
public void deleteRole(RolePath role) throws ObjectNotFoundException, ObjectCannotBeUpdated {
@@ -72,7 +75,7 @@ public class LDAPRoleManager {
}
protected void addRole(AgentPath agent, RolePath role)
- throws ObjectCannotBeUpdated, ObjectNotFoundException
+ throws ObjectCannotBeUpdated, ObjectNotFoundException
{
LDAPEntry roleEntry = LDAPLookupUtils.getEntry(mLdap.getConnection(), role.getFullDN());
//add memberDN to uniqueMember if it is not yet a member
@@ -82,7 +85,7 @@ public class LDAPRoleManager {
throw new ObjectCannotBeUpdated("Agent " + agent.getAgentName() + " already has role " + role.getName());
}
- protected void removeRole(AgentPath agent, RolePath role)
+ protected void removeRole(AgentPath agent, RolePath role)
throws ObjectCannotBeUpdated, ObjectNotFoundException
{
LDAPEntry roleEntry = LDAPLookupUtils.getEntry(mLdap.getConnection(), role.getFullDN());
@@ -91,44 +94,42 @@ public class LDAPRoleManager {
else
throw new ObjectCannotBeUpdated("Agent did not have that role");
}
-
+
protected boolean hasRole(AgentPath agent, RolePath role) {
- String filter = "(&(objectclass=cristalrole)(uniqueMember="+agent.getFullDN()+")(cn="+role.getName()+"))";
+ String filter = "(&(objectclass=cristalrole)(uniqueMember="+agent.getFullDN()+")(cn="+role.getName()+"))";
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
searchCons.setDereference(LDAPSearchConstraints.DEREF_NEVER );
- Enumeration roles = mLdap.search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons);
+ Enumeration<?> roles = mLdap.search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons);
return roles.hasMoreElements();
}
protected AgentPath[] getAgents(RolePath role)
throws ObjectNotFoundException
{
- //get the roleDN entry, and its uniqueMember entry pointing to
+ //get the roleDN entry, and its uniqueMember entry pointing to
LDAPEntry roleEntry;
try {
roleEntry = LDAPLookupUtils.getEntry(mLdap.getConnection(), role.getFullDN());
} catch (ObjectNotFoundException e) {
throw new ObjectNotFoundException("Role does not exist", "");
}
-
+
String[] res = LDAPLookupUtils.getAllAttributeValues(roleEntry,"uniqueMember");
ArrayList<AgentPath> agents = new ArrayList<AgentPath>();
- for (int i=0; i<res.length; i++)
- {
- String userDN = res[i];
- try {
- LDAPEntry userEntry = LDAPLookupUtils.getEntry(mLdap.getConnection(), userDN);
+ for (String userDN : res) {
+ try {
+ LDAPEntry userEntry = LDAPLookupUtils.getEntry(mLdap.getConnection(), userDN);
AgentPath path = (AgentPath)mLdap.nodeToPath(userEntry);
agents.add(path);
} catch (ObjectNotFoundException ex) {
- Logger.error("Agent "+res[i]+" does not exist");
+ Logger.error("Agent "+userDN+" does not exist");
} catch (InvalidEntityPathException ex) {
- Logger.error("Agent "+res[i]+" is not a valid entity");
+ Logger.error("Agent "+userDN+" is not a valid entity");
}
- }
+ }
AgentPath[] usersList = new AgentPath[0];
- usersList = (AgentPath[])agents.toArray(usersList);
+ usersList = agents.toArray(usersList);
return usersList;
}
@@ -137,26 +138,26 @@ public class LDAPRoleManager {
{
//search the mDomainPath tree uniqueMember=userDN
//filter = objectclass=cristalrole AND uniqueMember=userDN
- String filter = "(&(objectclass=cristalrole)(uniqueMember="+agentPath.getFullDN()+"))";
+ String filter = "(&(objectclass=cristalrole)(uniqueMember="+agentPath.getFullDN()+"))";
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
searchCons.setDereference(LDAPSearchConstraints.DEREF_NEVER );
- Enumeration roles = mLdap.search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons);
+ Enumeration<?> roles = mLdap.search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons);
ArrayList<RolePath> roleList = new ArrayList<RolePath>();
-
+
while(roles.hasMoreElements())
{
RolePath path = (RolePath) roles.nextElement();
- roleList.add(path);
- }
+ roleList.add(path);
+ }
RolePath[] roleArr = new RolePath[roleList.size()];
- roleArr = (RolePath[])roleList.toArray(roleArr);
+ roleArr = roleList.toArray(roleArr);
return roleArr;
}
/**
* Utility for looking up a login name
- *
+ *
* @param ld
* @param agentName
* @param baseDN
@@ -164,15 +165,15 @@ public class LDAPRoleManager {
* @throws ObjectNotFoundException
*/
public AgentPath getAgentPath(String agentName) throws ObjectNotFoundException
- {
+ {
//search to get the userDN equivalent of the userID
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
searchCons.setDereference(LDAPSearchConstraints.DEREF_NEVER );
- String filter = "(&(objectclass=cristalagent)(uid="+agentName+"))";
- Enumeration res = mLdap.search(mEntityPath,LDAPConnection.SCOPE_SUB,filter,searchCons);
+ String filter = "(&(objectclass=cristalagent)(uid="+agentName+"))";
+ Enumeration<?> res = mLdap.search(mEntityPath,LDAPConnection.SCOPE_SUB,filter,searchCons);
if (!res.hasMoreElements())
- throw new ObjectNotFoundException("Agent not found");
+ throw new ObjectNotFoundException("Agent not found");
Path result = (Path)res.nextElement();
if (result instanceof AgentPath)
return (AgentPath)result;
@@ -185,15 +186,15 @@ public class LDAPRoleManager {
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
searchCons.setDereference(LDAPSearchConstraints.DEREF_NEVER );
- String filter = "(&(objectclass=cristalrole)(cn="+roleName+"))";
- Enumeration res = mLdap.search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons);
+ String filter = "(&(objectclass=cristalrole)(cn="+roleName+"))";
+ Enumeration<?> res = mLdap.search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons);
if (!res.hasMoreElements())
- throw new ObjectNotFoundException("Role not found");
+ throw new ObjectNotFoundException("Role not found");
Path result = (Path)res.nextElement();
if (result instanceof RolePath)
return (RolePath)result;
else
- throw new ObjectNotFoundException("Entry was not a Role");
+ throw new ObjectNotFoundException("Entry was not a Role");
}
}
diff --git a/source/com/c2kernel/lookup/LegacyLDAPPropertyManager.java b/source/com/c2kernel/lookup/LegacyLDAPPropertyManager.java
index 62653fb..638c694 100755..100644
--- a/source/com/c2kernel/lookup/LegacyLDAPPropertyManager.java
+++ b/source/com/c2kernel/lookup/LegacyLDAPPropertyManager.java
@@ -15,7 +15,8 @@ public class LegacyLDAPPropertyManager extends LDAPPropertyManager {
public LegacyLDAPPropertyManager(LDAPLookup ldap) {
super(ldap);
}
-
+
+ @Override
public void deleteProperty(EntityPath thisEntity, String name) throws ObjectNotFoundException, ObjectCannotBeUpdated {
try {
LDAPLookupUtils.delete(ldap.getConnection(), "cn="+name+","+thisEntity.getFullDN());
@@ -25,6 +26,7 @@ public class LegacyLDAPPropertyManager extends LDAPPropertyManager {
}
}
+ @Override
public String[] getPropertyNames(EntityPath thisEntity) throws ObjectNotFoundException {
String props[]= LDAPLookupUtils.getChildrenDNs(ldap.getConnection(), thisEntity.getFullDN(), "objectclass=cristalproperty");
String names[] = new String[props.length];
@@ -33,6 +35,7 @@ public class LegacyLDAPPropertyManager extends LDAPPropertyManager {
return names;
}
+ @Override
public String getPropertyValue(EntityPath thisEntity, String name) throws ObjectNotFoundException {
LDAPEntry anEntry = LDAPLookupUtils.getEntry(ldap.getConnection(),"cn="+name+","+thisEntity.getFullDN());
if (anEntry==null)
@@ -40,10 +43,12 @@ public class LegacyLDAPPropertyManager extends LDAPPropertyManager {
return LDAPLookupUtils.getFirstAttributeValue(anEntry,"propval");
}
+ @Override
public boolean hasProperties(EntityPath thisEntity) throws ObjectNotFoundException {
return LDAPLookupUtils.hasChildren(ldap.getConnection(), thisEntity.getFullDN(), "objectclass=cristalproperty" );
}
+ @Override
public void setProperty(EntityPath thisEntity, Property prop) throws ObjectNotFoundException, ObjectCannotBeUpdated {
try {
LDAPEntry anEntry = LDAPLookupUtils.getEntry(ldap.getConnection(),"cn="+prop.getName()+","+thisEntity.getFullDN());
@@ -64,7 +69,7 @@ public class LegacyLDAPPropertyManager extends LDAPPropertyManager {
} catch (Exception e) {
Logger.error(e);
throw new ObjectCannotBeUpdated(e.getMessage(), "");
- }
+ }
}
}
}
diff --git a/source/com/c2kernel/lookup/NextKeyManager.java b/source/com/c2kernel/lookup/NextKeyManager.java
index 04581c0..fd873fd 100755..100644
--- a/source/com/c2kernel/lookup/NextKeyManager.java
+++ b/source/com/c2kernel/lookup/NextKeyManager.java
@@ -18,7 +18,7 @@ public class NextKeyManager {
LDAPLookup ldap;
String lastKeyPath;
-
+
public NextKeyManager(LDAPLookup ldap, String lastKeyPath) {
super();
this.ldap = ldap;
@@ -28,9 +28,8 @@ public class NextKeyManager {
public synchronized EntityPath generateNextEntityKey()
throws ObjectCannotBeUpdated, ObjectNotFoundException
{
- LDAPEntry lastKeyEntry = LDAPLookupUtils.getEntry(ldap.getConnection(),lastKeyPath);
EntityPath lastKey = getLastEntityPath();
-
+
try {
lastKey.setSysKey(lastKey.getSysKey()+1);
} catch (InvalidEntityPathException ex) {
@@ -38,21 +37,21 @@ public class NextKeyManager {
}
//set the last key
writeLastEntityKey(lastKey.getSysKey());
-
+
return lastKey;
}
-
+
public synchronized AgentPath generateNextAgentKey()
throws ObjectCannotBeUpdated, ObjectNotFoundException {
EntityPath newEntity = generateNextEntityKey();
return new AgentPath(newEntity);
}
-
+
public void writeLastEntityKey(int sysKey) throws ObjectCannotBeUpdated, ObjectNotFoundException {
LDAPEntry lastKeyEntry = LDAPLookupUtils.getEntry(ldap.getConnection(),lastKeyPath);
LDAPLookupUtils.setAttributeValue(ldap.getConnection(), lastKeyEntry,"intsyskey",Integer.toString(sysKey));
}
-
+
public EntityPath getLastEntityPath() throws ObjectNotFoundException
{
LDAPEntry lastKeyEntry = LDAPLookupUtils.getEntry(ldap.getConnection(),lastKeyPath);
@@ -66,7 +65,7 @@ public class NextKeyManager {
} catch (NumberFormatException ex) {
throw new ObjectNotFoundException("Invalid syskey in lastkey.");
}
-
+
}
-
+
}
diff --git a/source/com/c2kernel/lookup/Path.java b/source/com/c2kernel/lookup/Path.java
index b713493..4966d1e 100644
--- a/source/com/c2kernel/lookup/Path.java
+++ b/source/com/c2kernel/lookup/Path.java
@@ -32,10 +32,10 @@ public abstract class Path implements Serializable
public static final String delim = "/";
// types
- public static final short UNKNOWN = 0;
+ public static final short UNKNOWN = 0;
public static final short CONTEXT = 1;
public static final short ENTITY = 2;
-
+
// invalid int key
public static final int INVALID = -1;
@@ -54,11 +54,11 @@ public abstract class Path implements Serializable
protected org.omg.CORBA.Object mIOR = null;
//
// needed for unusual subclass constructors
-
+
protected static String mGlobalPath; //cern.ch
protected static String mRootPath; //cristal2
protected static String mLocalPath; //lab27
-
+
public Path() {
}
@@ -115,7 +115,7 @@ public abstract class Path implements Serializable
{
mStringPath = null;
mDN = null;
- mPath = (String[])path.clone();
+ mPath = path.clone();
mSysKey = INVALID;
}
@@ -134,7 +134,7 @@ public abstract class Path implements Serializable
newPath.add(tok.nextToken());
}
- mPath = (String[])(newPath.toArray(mPath));
+ mPath = (newPath.toArray(mPath));
mStringPath = null;
mDN = null;
mSysKey = INVALID;
@@ -153,7 +153,7 @@ public abstract class Path implements Serializable
{
mStringPath = null;
mDN = null;
- mPath = (String[])(path.getPath().clone());
+ mPath = (path.getPath().clone());
mSysKey = INVALID;
}
@@ -167,7 +167,7 @@ public abstract class Path implements Serializable
String root = "cn="+getRoot()+",";
if (dn.endsWith(mLocalPath))
dn = dn.substring(0, dn.lastIndexOf(mLocalPath));
-
+
if (dn.endsWith(root))
dn = dn.substring(0, dn.lastIndexOf(root));
@@ -180,7 +180,7 @@ public abstract class Path implements Serializable
else
break;
}
- mPath = (String[])(newPath.toArray(mPath));
+ mPath = (newPath.toArray(mPath));
mSysKey = INVALID;
mStringPath = null;
mDN = dn+root;
@@ -204,8 +204,8 @@ public abstract class Path implements Serializable
{
if (mStringPath == null) {
StringBuffer stringPathBuffer = new StringBuffer("/").append(getRoot());
- for (int i=0; i<mPath.length; i++)
- stringPathBuffer.append(delim).append(mPath[i]);
+ for (String element : mPath)
+ stringPathBuffer.append(delim).append(element);
mStringPath = stringPathBuffer.toString();
}
return mStringPath;
@@ -221,15 +221,15 @@ public abstract class Path implements Serializable
}
return mDN;
}
-
+
public String getFullDN() {
return getDN()+mLocalPath;
}
-
+
public boolean exists() {
return Gateway.getLDAPLookup().exists(this);
}
-
+
/** Queries the lookup for the IOR
*/
@@ -240,14 +240,14 @@ public abstract class Path implements Serializable
try {
newIOR = myLookup.getIOR(this);
} catch (ObjectNotFoundException ex) {
- newIOR = null;
}
setIOR(newIOR);
}
return mIOR;
}
- public String toString() {
+ @Override
+ public String toString() {
return getString();
}
@@ -258,17 +258,17 @@ public abstract class Path implements Serializable
public int getSysKey() {
return mSysKey;
}
-
- public Enumeration getChildren() {
+
+ public Enumeration<?> getChildren() {
String filter = "objectclass=*";
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(10);
searchCons.setDereference(LDAPSearchConstraints.DEREF_FINDING );
return Gateway.getLDAPLookup().search(getFullDN(), LDAPConnection.SCOPE_ONE,filter,searchCons);
}
-
+
public Path find(String name) throws ObjectNotFoundException {
- Enumeration e = Gateway.getLDAPLookup().search(this, name);
+ Enumeration<?> e = Gateway.getLDAPLookup().search(this, name);
if (e.hasMoreElements()) {
Path thisPath =(Path)e.nextElement();
if (e.hasMoreElements())
@@ -277,24 +277,26 @@ public abstract class Path implements Serializable
}
throw new ObjectNotFoundException("No match for "+name, "");
}
-
+
public abstract EntityPath getEntity() throws ObjectNotFoundException;
public abstract LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated;
-
- public boolean equals( Object path )
- {
+
+ @Override
+ public boolean equals( Object path )
+ {
return toString().equals(path.toString());
}
-
- public int hashCode() {
+
+ @Override
+ public int hashCode() {
return toString().hashCode();
}
public String dump() {
StringBuffer comp = new StringBuffer("Components: { ");
- for (int i=0; i<mPath.length; i++)
- comp.append("'").append(mPath[i]).append("' ");
+ for (String element : mPath)
+ comp.append("'").append(element).append("' ");
return "Path - dump(): "+comp.toString()+"}\n dn="+getDN()+"\n string="+toString()+"\n int="+getSysKey()+"\n type="+mType;
}
}
diff --git a/source/com/c2kernel/lookup/RolePath.java b/source/com/c2kernel/lookup/RolePath.java
index 672bdbf..e6593ea 100644
--- a/source/com/c2kernel/lookup/RolePath.java
+++ b/source/com/c2kernel/lookup/RolePath.java
@@ -33,10 +33,10 @@ public class RolePath extends DomainPath
*/
private boolean hasJobList = false;
-
+
public RolePath(String roleName) {
super(new DomainPath("agent"), roleName);
- }
+ }
public RolePath(String roleName, boolean jobList) {
this(roleName);
@@ -56,19 +56,21 @@ public class RolePath extends DomainPath
this.hasJobList = hasJobList;
}
-
- public void checkType() {
+
+ @Override
+ public void checkType() {
mType = CONTEXT;
}
-
- public Enumeration getChildren() {
+
+ @Override
+ public Enumeration<AgentPath> getChildren() {
AgentPath[] agents = getAgentsWithRole();
Vector<AgentPath> children = new Vector<AgentPath>(agents.length);
for (int i = 0; i < agents.length; i++)
children.add(i, agents[i]);
return children.elements();
}
-
+
public AgentPath[] getAgentsWithRole() {
try {
return Gateway.getLDAPLookup().getRoleManager().getAgents(this);
@@ -77,20 +79,21 @@ public class RolePath extends DomainPath
return new AgentPath[0];
}
}
-
+
public void addAgent(AgentPath agent) throws ObjectCannotBeUpdated, ObjectNotFoundException {
Gateway.getLDAPLookup().getRoleManager().addRole(agent, this);
}
-
+
public void removeAgent(AgentPath agent) throws ObjectCannotBeUpdated, ObjectNotFoundException {
Gateway.getLDAPLookup().getRoleManager().removeRole(agent, this);
}
-
- public String dump() {
+
+ @Override
+ public String dump() {
StringBuffer comp = new StringBuffer("Components: { ");
- for (int i=0; i<mPath.length; i++)
- comp.append("'").append(mPath[i]).append("' ");
-
+ for (String element : mPath)
+ comp.append("'").append(element).append("' ");
+
return "Path - dump(): "+
comp.toString()+
"}\n dn="+
@@ -102,9 +105,10 @@ public class RolePath extends DomainPath
"\n name="+
getName()+
"\n ";
- }
-
- public LDAPAttributeSet createAttributeSet()
+ }
+
+ @Override
+ public LDAPAttributeSet createAttributeSet()
{
LDAPAttributeSet attrs = new LDAPAttributeSet();
attrs.add(new LDAPAttribute("objectclass","cristalrole"));