[jboss-cvs] JBossAS SVN: r112708 - in projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788: jnpserver and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 28 13:01:31 EST 2012


Author: pskopek at redhat.com
Date: 2012-02-28 13:01:27 -0500 (Tue, 28 Feb 2012)
New Revision: 112708

Added:
   projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java
Modified:
   projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpclient/pom.xml
   projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/pom.xml
   projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/src/main/java/org/jnp/server/Main.java
Log:
[JBPAPP-7788] suppress use of JNDI operations other then lookup over RMI

Modified: projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpclient/pom.xml
===================================================================
--- projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpclient/pom.xml	2012-02-28 17:57:18 UTC (rev 112707)
+++ projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpclient/pom.xml	2012-02-28 18:01:27 UTC (rev 112708)
@@ -9,8 +9,8 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.jboss.naming</groupId>
   <artifactId>jnp-client</artifactId>
+  <version>5.0.3.GA_CP02</version>
   <name>JBoss Naming Client</name>
-  <version>5.0.3.GA_CP01</version>
   <description>The JBoss Naming Client</description>
   <url>http://www.jboss.org</url>
   <build>

Modified: projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/pom.xml
===================================================================
--- projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/pom.xml	2012-02-28 17:57:18 UTC (rev 112707)
+++ projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/pom.xml	2012-02-28 18:01:27 UTC (rev 112708)
@@ -6,10 +6,10 @@
     <version>4-beta-2</version>
   </parent>
   
-  <version>5.0.3.GA_CP01</version>   
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.jboss.naming</groupId>
   <artifactId>jnpserver</artifactId>
+  <version>5.0.3.GA_CP02</version>
   <packaging>jar</packaging>
   <name>JBoss Naming Server</name>
   <url>http://www.jboss.org</url>

Modified: projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/src/main/java/org/jnp/server/Main.java
===================================================================
--- projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/src/main/java/org/jnp/server/Main.java	2012-02-28 17:57:18 UTC (rev 112707)
+++ projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/src/main/java/org/jnp/server/Main.java	2012-02-28 18:01:27 UTC (rev 112708)
@@ -105,6 +105,8 @@
    private Executor lookupExector;
    /** The exception seen when creating the lookup listening port */
    private Exception lookupListenerException;
+   /** Naming server guard to receive RMIs and decide what will come through to NamingServer */
+   private NamingServerGuard namingServerGuard;
 
    // Static --------------------------------------------------------
    public static void main(String[] args)
@@ -440,8 +442,14 @@
             serverSocket = null;
             s.close();
          }
-         if( isStubExported == true )
-            UnicastRemoteObject.unexportObject(theServer.getNamingInstance(), false);
+         if( isStubExported == true ) 
+         {
+            if (namingServerGuard != null) 
+               UnicastRemoteObject.unexportObject(namingServerGuard, false);
+            else   
+               UnicastRemoteObject.unexportObject(theServer.getNamingInstance(), false);
+         }   
+         
       }
       catch (Exception e)
       {
@@ -458,9 +466,18 @@
          +",rmiPort="+rmiPort
          +",clientSocketFactory="+clientSocketFactory
          +",serverSocketFactory="+serverSocketFactory);
+      
       Naming instance = getNamingInstance();
-      Remote stub = UnicastRemoteObject.exportObject(instance,
-            rmiPort, clientSocketFactory, serverSocketFactory);
+      Remote stub;
+      if (getUseGlobalService()) {
+         namingServerGuard = new NamingServerGuard(instance);
+         stub = UnicastRemoteObject.exportObject(namingServerGuard,
+               rmiPort, clientSocketFactory, serverSocketFactory);
+      }   
+      else {
+         stub = UnicastRemoteObject.exportObject(instance,
+    	            rmiPort, clientSocketFactory, serverSocketFactory);    	  
+      }      
       log.debug("NamingServer stub: "+stub);
       serverStub = new MarshalledObject(stub);
       isStubExported = true;

Added: projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java
===================================================================
--- projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java	                        (rev 0)
+++ projects/naming/branches/5.0.3.GA_CP01_JBPAPP_7788/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java	2012-02-28 18:01:27 UTC (rev 112708)
@@ -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