diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-09-18 10:39:05 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-09-18 10:39:05 +0200 |
| commit | 3743d182d99dbed9d2be84dc357f6839ffe4d2ec (patch) | |
| tree | 7fe88768469f34601c494f5b027bd9c3a6d622e7 /src/main/java/com/c2kernel/process/Bootstrap.java | |
| parent | 1537f39761e11669335f6499474f23b11cf2cf38 (diff) | |
Hierarchical Roles. Fixes #199
Diffstat (limited to 'src/main/java/com/c2kernel/process/Bootstrap.java')
| -rw-r--r-- | src/main/java/com/c2kernel/process/Bootstrap.java | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index 0f06616..e269e09 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -281,7 +281,7 @@ public class Bootstrap /**************************************************************************
* Checks for the existence of the admin users so you can use Cristal
**************************************************************************/
- private static void checkAgent(String name, String pass, String role, UUID uuid, boolean joblist) throws Exception {
+ private static void checkAgent(String name, String pass, RolePath rolePath, UUID uuid) throws Exception {
Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '"+name+"' user.");
LookupManager lookup = Gateway.getLookupManager();
@@ -293,13 +293,6 @@ public class Bootstrap Logger.msg("Bootstrap.checkAgent() - User '"+name+"' not found. Creating.");
- RolePath rolePath;
- try {
- rolePath = lookup.getRolePath(role);
- } catch (ObjectNotFoundException ex) {
- rolePath = lookup.createRole(role, joblist);
- }
-
try {
AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
agentPath.setPassword(pass);
@@ -307,8 +300,8 @@ public class Bootstrap lookup.add(agentPath);
// assign admin role
- Logger.msg("Bootstrap.checkAgent() - Assigning role '"+role+"'");
- rolePath.addAgent(agentPath);
+ Logger.msg("Bootstrap.checkAgent() - Assigning role '"+rolePath.getName()+"'");
+ Gateway.getLookupManager().addRole(agentPath, rolePath);
Gateway.getStorage().put(agentPath, new Property("Name", name, true), null);
Gateway.getStorage().put(agentPath, new Property("Type", "Agent", false), null);
systemAgents.put(name, Gateway.getProxyManager().getAgentProxy(agentPath));
@@ -322,16 +315,23 @@ public class Bootstrap *
*/
public static void checkAdminAgents() throws Exception {
- // check for administrative user
+
+ // check for administrative user & admin role
String adminPassword = Gateway.getProperties().getString("AdminPassword", "admin12345");
-
+ RolePath rootRole = new RolePath();
+ if (!rootRole.exists()) Gateway.getLookupManager().createRole(rootRole);
+ RolePath adminRole = new RolePath(rootRole, "Admin", false);
+ if (!adminRole.exists()) Gateway.getLookupManager().createRole(adminRole);
+
// check for import user
- checkAgent("system", adminPassword, "Admin", new UUID(0, 0), false);
+ checkAgent("system", adminPassword, adminRole, new UUID(0, 0));
- checkAgent("admin", adminPassword, "Admin", new UUID(0, 1), false);
+ checkAgent("admin", adminPassword, adminRole, new UUID(0, 1));
- // check for local usercode user
- checkAgent(InetAddress.getLocalHost().getHostName(), "uc", "UserCode", UUID.randomUUID(), true);
+ // check for local usercode user & role
+ RolePath usercodeRole = new RolePath(rootRole, "UserCode", true);
+ if (!usercodeRole.exists()) Gateway.getLookupManager().createRole(usercodeRole);
+ checkAgent(InetAddress.getLocalHost().getHostName(), "uc", usercodeRole, UUID.randomUUID());
}
public static void createServerItem() throws Exception {
|
