summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lookup
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-06-30 23:03:03 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-06-30 23:03:03 +0200
commit2495be9ecfa8aea47e285f63b5bb27b0c133b1f8 (patch)
treed85f6df165386a86683de6ccee4c1767723573dd /src/main/java/com/c2kernel/lookup
parentdc2bbfdda8ee4f32937c3e91f77e52dc4501f0f1 (diff)
Separated modifying Lookup methods into LookupManager, which is only
present in a server process. This stops clients trying to write to the directory without relying on their permissions.
Diffstat (limited to 'src/main/java/com/c2kernel/lookup')
-rw-r--r--src/main/java/com/c2kernel/lookup/Lookup.java71
-rw-r--r--src/main/java/com/c2kernel/lookup/LookupManager.java85
-rw-r--r--src/main/java/com/c2kernel/lookup/RolePath.java14
3 files changed, 93 insertions, 77 deletions
diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java
index 039c368..5384e7c 100644
--- a/src/main/java/com/c2kernel/lookup/Lookup.java
+++ b/src/main/java/com/c2kernel/lookup/Lookup.java
@@ -1,10 +1,7 @@
package com.c2kernel.lookup;
-import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.process.auth.Authenticator;
import com.c2kernel.property.Property;
@@ -17,13 +14,6 @@ import com.c2kernel.property.PropertyDescriptionList;
public interface Lookup {
/**
- * Called when a server starts up. The Lookup implementation should ensure that the initial structure of its directory is valid, and create it on first boot.
- *
- * @throws ObjectNotFoundException When initialization data is not found
- */
- public void initializeDirectory() throws ObjectNotFoundException;
-
- /**
* Connect to the directory using the credentials supplied in the Authenticator.
*
* @param user The connected Authenticator. The Lookup implementation may use the AuthObject in this to communicate with the database.
@@ -66,24 +56,6 @@ public interface Lookup {
*/
public org.omg.CORBA.Object resolve(Path path) throws ObjectNotFoundException;
- // Path management
-
- /**
- * Register a new a Path in the directory.
- *
- * @param newPath The path to add
- * @throws ObjectCannotBeUpdated When there is an error writing to the directory
- * @throws ObjectAlreadyExistsException When the Path has already been registered
- */
- public void add(Path newPath) throws ObjectCannotBeUpdated, ObjectAlreadyExistsException;
-
- /**
- * Remove a Path from the directory
- * @param path The path to remove
- * @throws ObjectCannotBeUpdated When an error occurs writing to the directory
- */
- public void delete(Path path) throws ObjectCannotBeUpdated;
-
// Path finding and searching
/**
@@ -151,23 +123,6 @@ public interface Lookup {
public RolePath getRolePath(String roleName) throws ObjectNotFoundException;
/**
- * @param role
- * @param hasJobList
- * @return
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- */
- public RolePath createRole(String role, boolean hasJobList) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated;
-
- /**
- * @param agent
- * @param rolePath
- * @throws ObjectCannotBeUpdated
- * @throws ObjectNotFoundException
- */
- public void addRole(AgentPath agent, RolePath rolePath) throws ObjectCannotBeUpdated, ObjectNotFoundException;
-
- /**
* @param rolePath
* @return
* @throws ObjectNotFoundException
@@ -188,36 +143,10 @@ public interface Lookup {
public boolean hasRole(AgentPath agentPath, RolePath role);
/**
- * @param agent
- * @param role
- * @throws ObjectCannotBeUpdated
- * @throws ObjectNotFoundException
- */
- public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException;
-
- /**
* @param agentPath
* @return
* @throws ObjectNotFoundException
*/
public String getAgentName(AgentPath agentPath) throws ObjectNotFoundException;
- /**
- * @param agent
- * @param newPassword
- * @throws ObjectNotFoundException
- * @throws ObjectCannotBeUpdated
- * @throws NoSuchAlgorithmException
- */
- public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException;
-
- /**
- * @param role
- * @param hasJobList
- * @throws ObjectNotFoundException
- * @throws ObjectCannotBeUpdated
- */
- public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated;
-
-
}
diff --git a/src/main/java/com/c2kernel/lookup/LookupManager.java b/src/main/java/com/c2kernel/lookup/LookupManager.java
new file mode 100644
index 0000000..ce1268e
--- /dev/null
+++ b/src/main/java/com/c2kernel/lookup/LookupManager.java
@@ -0,0 +1,85 @@
+package com.c2kernel.lookup;
+
+import java.security.NoSuchAlgorithmException;
+
+import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFoundException;
+
+/**
+ * @author abranson
+ *
+ */
+public interface LookupManager extends Lookup {
+
+ /**
+ * Called when a server starts up. The Lookup implementation should ensure that the initial structure of its directory is valid, and create it on first boot.
+ *
+ * @throws ObjectNotFoundException When initialization data is not found
+ */
+ public void initializeDirectory() throws ObjectNotFoundException;
+
+ // Path management
+
+ /**
+ * Register a new a Path in the directory.
+ *
+ * @param newPath The path to add
+ * @throws ObjectCannotBeUpdated When there is an error writing to the directory
+ * @throws ObjectAlreadyExistsException When the Path has already been registered
+ */
+ public void add(Path newPath) throws ObjectCannotBeUpdated, ObjectAlreadyExistsException;
+
+ /**
+ * Remove a Path from the directory
+ * @param path The path to remove
+ * @throws ObjectCannotBeUpdated When an error occurs writing to the directory
+ */
+ public void delete(Path path) throws ObjectCannotBeUpdated;
+
+ // Role and agent management
+
+ /**
+ * @param role
+ * @param hasJobList
+ * @return
+ * @throws ObjectAlreadyExistsException
+ * @throws ObjectCannotBeUpdated
+ */
+ public RolePath createRole(String role, boolean hasJobList) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated;
+
+ /**
+ * @param agent
+ * @param rolePath
+ * @throws ObjectCannotBeUpdated
+ * @throws ObjectNotFoundException
+ */
+ public void addRole(AgentPath agent, RolePath rolePath) throws ObjectCannotBeUpdated, ObjectNotFoundException;
+
+ /**
+ * @param agent
+ * @param role
+ * @throws ObjectCannotBeUpdated
+ * @throws ObjectNotFoundException
+ */
+ public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException;
+
+ /**
+ * @param agent
+ * @param newPassword
+ * @throws ObjectNotFoundException
+ * @throws ObjectCannotBeUpdated
+ * @throws NoSuchAlgorithmException
+ */
+ public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException;
+
+ /**
+ * @param role
+ * @param hasJobList
+ * @throws ObjectNotFoundException
+ * @throws ObjectCannotBeUpdated
+ */
+ public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated;
+
+
+}
diff --git a/src/main/java/com/c2kernel/lookup/RolePath.java b/src/main/java/com/c2kernel/lookup/RolePath.java
index bd23991..fa37fb3 100644
--- a/src/main/java/com/c2kernel/lookup/RolePath.java
+++ b/src/main/java/com/c2kernel/lookup/RolePath.java
@@ -13,6 +13,7 @@ package com.c2kernel.lookup;
import java.util.ArrayList;
import java.util.Iterator;
+import com.c2kernel.common.CannotManageException;
import com.c2kernel.common.ObjectCannotBeUpdated;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.process.Gateway;
@@ -51,10 +52,11 @@ public class RolePath extends DomainPath
* @param hasJobList The hasJobList to set.
* @throws ObjectCannotBeUpdated
* @throws ObjectNotFoundException
+ * @throws CannotManageException
*/
- public void setHasJobList(boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated {
+ public void setHasJobList(boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
this.hasJobList = hasJobList;
- Gateway.getLookup().setHasJobList(this, hasJobList);
+ Gateway.getLookupManager().setHasJobList(this, hasJobList);
}
@@ -80,12 +82,12 @@ public class RolePath extends DomainPath
}
}
- public void addAgent(AgentPath agent) throws ObjectCannotBeUpdated, ObjectNotFoundException {
- Gateway.getLookup().addRole(agent, this);
+ public void addAgent(AgentPath agent) throws ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException {
+ Gateway.getLookupManager().addRole(agent, this);
}
- public void removeAgent(AgentPath agent) throws ObjectCannotBeUpdated, ObjectNotFoundException {
- Gateway.getLookup().removeRole(agent, this);
+ public void removeAgent(AgentPath agent) throws ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException {
+ Gateway.getLookupManager().removeRole(agent, this);
}
@Override