[jboss-cvs] JBossAS SVN: r112682 - branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 23 06:38:06 EST 2012


Author: pskopek at redhat.com
Date: 2012-02-23 06:38:06 -0500 (Thu, 23 Feb 2012)
New Revision: 112682

Added:
   branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server/NamingServerGuard.java
Modified:
   branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server/Main.java
Log:
[JBPAPP-7791] - fix for non HA JNDI server

Modified: branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server/Main.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server/Main.java	2012-02-23 00:18:00 UTC (rev 112681)
+++ branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server/Main.java	2012-02-23 11:38:06 UTC (rev 112682)
@@ -97,6 +97,9 @@
    /** The thread pool used to handle jnp stub lookup requests */
    protected ThreadPool lookupPool;
 
+   /** Naming server guard to receive RMIs and decide what will come through to NamingServer */
+   private NamingServerGuard namingServerGuard;
+   
    // Static --------------------------------------------------------
    public static void main(String[] args)
       throws Exception
@@ -351,8 +354,19 @@
          +",rmiPort="+rmiPort
          +",clientSocketFactory="+clientSocketFactory
          +",serverSocketFactory="+serverSocketFactory);
-      Remote stub = UnicastRemoteObject.exportObject(getNamingInstance(),
-            rmiPort, clientSocketFactory, serverSocketFactory);
+      
+      log.debug("Creating NamingServerGuard");
+      Remote stub;
+      if (getUseGlobalService()) {
+         namingServerGuard = new NamingServerGuard(getNamingInstance());
+         stub = UnicastRemoteObject.exportObject(namingServerGuard,
+               rmiPort, clientSocketFactory, serverSocketFactory);
+      }   
+      else {
+         stub = UnicastRemoteObject.exportObject(getNamingInstance(),
+               rmiPort, clientSocketFactory, serverSocketFactory);
+      }
+      
       log.debug("NamingServer stub: "+stub);
       serverStub = new MarshalledObject(stub);      
    }

Added: branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server/NamingServerGuard.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server/NamingServerGuard.java	                        (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/naming/src/main/org/jnp/server/NamingServerGuard.java	2012-02-23 11:38:06 UTC (rev 112682)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jnp.server;
+
+import java.rmi.RemoteException;
+import java.util.Collection;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.NoPermissionException;
+
+import org.jnp.interfaces.Naming;
+
+/**
+ * NamingServerGuard will be registered instead of NamingServer to receive all RMIs and decide what 
+ * will come through to NamingServer.
+ *  
+ * @author Peter Skopek <pskopek at redhat.com>
+ *
+ */
+public class NamingServerGuard
+   implements Naming, java.io.Serializable
+{
+   
+   private static final long serialVersionUID = 1875763972368932742L;
+   
+   private final Naming securedNaming;
+   
+   public static final String GUARDED_JNDI_METHOD_NAMES = "bind,rebind,unbind,createSubcontext";
+
+
+   
+   public NamingServerGuard(Naming securedNaming) {
+
+      this.securedNaming = securedNaming;
+   }
+   
+   public void bind(Name name, Object obj, String className)
+         throws NamingException, RemoteException {
+      
+      throw new NoPermissionException("bind JNDI operation not allowed when calling from outside NamingServer's VM.");
+   }
+
+   public void rebind(Name name, Object obj, String className)
+         throws NamingException, RemoteException {
+
+      throw new NoPermissionException("rebind JNDI operation not allowed when calling from outside NamingServer's VM.");
+   }
+
+   public void unbind(Name name) throws NamingException, RemoteException {
+
+      throw new NoPermissionException("unbind JNDI operation not allowed when calling from outside NamingServer's VM.");
+   }
+
+   public Object lookup(Name name) throws NamingException, RemoteException {
+      return securedNaming.lookup(name);
+   }
+
+   public Collection list(Name name) throws NamingException, RemoteException {
+      return securedNaming.list(name);
+   }
+
+   public Collection listBindings(Name name) throws NamingException,
+         RemoteException {
+      
+      return securedNaming.listBindings(name);
+   }
+
+   public Context createSubcontext(Name name) throws NamingException,
+         RemoteException {
+   
+      throw new NoPermissionException("createSubcontext JNDI operation not allowed when calling from outside NamingServer's VM.");
+   }
+
+}



More information about the jboss-cvs-commits mailing list