[jboss-svn-commits] JBossWS SVN: r1043 - branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/spi

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 25 12:54:28 EDT 2006


Author: thomas.diesler at jboss.com
Date: 2006-09-25 12:54:26 -0400 (Mon, 25 Sep 2006)
New Revision: 1043

Modified:
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/spi/EndpointImpl.java
Log:
Checking publishEndpoint Permission

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/spi/EndpointImpl.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/spi/EndpointImpl.java	2006-09-25 16:24:52 UTC (rev 1042)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/spi/EndpointImpl.java	2006-09-25 16:54:26 UTC (rev 1043)
@@ -36,6 +36,7 @@
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServicePermission;
 
 import org.jboss.logging.Logger;
 import org.jboss.util.NotImplementedException;
@@ -53,19 +54,22 @@
 {
    // provide logging
    private final Logger log = Logger.getLogger(EndpointImpl.class);
-   
+
+   // The permission to publish an endpoint
+   private static final WebServicePermission ENDPOINT_PUBLISH_PERMISSION = new WebServicePermission("publishEndpoint");
+
    private Object implementor;
    private BindingProvider bindingProvider;
    private Map<String, Object> properties = new HashMap<String, Object>();
    private HttpContext serverContext;
    private boolean isPublished;
    private boolean isDestroyed;
-   
+
    public EndpointImpl(String bindingId, Object implementor)
    {
       this.implementor = implementor;
       this.bindingProvider = new BindingProviderImpl(bindingId);
-      
+
       if (implementor == null)
          throw new WebServiceException("Implementor cannot be null");
    }
@@ -95,22 +99,25 @@
       URI addrURI;
       try
       {
-         addrURI = new URI (address);
+         addrURI = new URI(address);
       }
       catch (URISyntaxException e)
       {
          throw new IllegalArgumentException("Invalid address: " + address);
       }
 
+      // Check with the security manger
+      checkPublishEndpointPermission();
+      
       // Create and start the HTTP server
       HttpServer httpServer = HttpServer.create();
       httpServer.setProperties(properties);
       httpServer.start();
-      
+
       String path = addrURI.getPath();
       String contextRoot = "/" + new StringTokenizer(path, "/").nextToken();
       HttpContext context = httpServer.createContext(contextRoot);
-      
+
       publish(context);
    }
 
@@ -126,6 +133,9 @@
    {
       if (isDestroyed)
          throw new IllegalStateException("Endpoint already destroyed");
+
+      // Check with the security manger
+      checkPublishEndpointPermission();
       
       if (context instanceof HttpContext)
       {
@@ -141,7 +151,7 @@
    {
       if (serverContext == null || isPublished == false)
          log.error("Endpoint not published");
-      
+
       try
       {
          if (serverContext != null)
@@ -153,8 +163,8 @@
       catch (Exception ex)
       {
          log.error("Cannot stop endpoint", ex);
-      }      
-      
+      }
+
       isPublished = false;
       isDestroyed = true;
    }
@@ -200,4 +210,20 @@
    {
       properties = map;
    }
+
+   
+   private void checkPublishEndpointPermission()
+   {
+      // 5.10 Conformance (Checking publishEndpoint Permission): When any of the publish methods defined
+      // by the Endpoint class are invoked, an implementation MUST check whether a SecurityManager is
+      // installed with the application. If it is, implementations MUST verify that the application has the 
+      // WebServicePermission identified by the target name publishEndpoint before proceeding. If the permission
+      // is not granted, implementations MUST NOT publish the endpoint and they MUST throw a 
+      // java.lang.SecurityException.
+      SecurityManager sm = System.getSecurityManager();
+      if (sm != null)
+      {
+         sm.checkPermission(ENDPOINT_PUBLISH_PERMISSION);
+      }
+   }
 }
\ No newline at end of file




More information about the jboss-svn-commits mailing list