From 2495be9ecfa8aea47e285f63b5bb27b0c133b1f8 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 30 Jun 2014 23:03:03 +0200 Subject: 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. --- src/main/java/com/c2kernel/process/Gateway.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/c2kernel/process/Gateway.java') diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 2499bf7..09700d6 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -9,6 +9,7 @@ import java.net.MalformedURLException; import java.util.Enumeration; import java.util.Properties; +import com.c2kernel.common.CannotManageException; import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.CorbaServer; @@ -17,6 +18,7 @@ import com.c2kernel.entity.proxy.ProxyManager; import com.c2kernel.entity.proxy.ProxyServer; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.Lookup; +import com.c2kernel.lookup.LookupManager; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.NextKeyManager; import com.c2kernel.persistency.TransactionManager; @@ -58,6 +60,7 @@ public class Gateway static private org.omg.CORBA.ORB mORB; static private boolean orbDestroyed = false; static private Lookup mLookup; + static private LookupManager mLookupManager = null; static private NextKeyManager mNextKeyManager; static private TransactionManager mStorage; static private ProxyManager mProxyManager; @@ -145,10 +148,16 @@ public class Gateway * * @throws InvalidDataException - error initialising */ - static public void startServer(Authenticator auth) throws InvalidDataException { + static public void startServer(Authenticator auth) throws InvalidDataException, CannotManageException { try { // check top level directory contexts - mLookup.initializeDirectory(); + if (mLookup instanceof LookupManager) { + mLookupManager = (LookupManager)mLookup; + mLookupManager.initializeDirectory(); + } + else { + throw new CannotManageException("Lookup implementation is not a LookupManager. Cannot write to directory"); + } // init next key manager mNextKeyManager = (NextKeyManager)mC2KProps.getInstance("NextKeyManager"); @@ -322,6 +331,14 @@ public class Gateway return mLookup; } + static public LookupManager getLookupManager() throws CannotManageException + { + if (mLookupManager == null) + throw new CannotManageException("No Lookup Manager created. Not a server process.", ""); + else + return mLookupManager; + } + static public CorbaServer getCorbaServer() { return mCorbaServer; -- cgit v1.2.3