felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vvalc...@apache.org
Subject svn commit: r1619371 - in /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet: ConfigurationSupport.java OsgiManager.java
Date Thu, 21 Aug 2014 11:55:37 GMT
Author: vvalchev
Date: Thu Aug 21 11:55:37 2014
New Revision: 1619371

URL: http://svn.apache.org/r1619371
Log:
Fixed FELIX-4610 : WebConsole doesn't start with Java Security enabled
https://issues.apache.org/jira/browse/FELIX-4610

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationSupport.java
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationSupport.java?rev=1619371&r1=1619370&r2=1619371&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationSupport.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationSupport.java
Thu Aug 21 11:55:37 2014
@@ -19,6 +19,10 @@
 package org.apache.felix.webconsole.internal.servlet;
 
 
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Dictionary;
 
 import org.osgi.framework.BundleContext;
@@ -42,8 +46,41 @@ class ConfigurationSupport implements Ma
 
 
     //---------- ManagedService
+    public void updated( final Dictionary config ) throws ConfigurationException
+    {
+        if (null != System.getSecurityManager())
+        {
+            try
+            {
+                AccessController.doPrivileged(new PrivilegedExceptionAction()
+                {
+                    public Object run() throws Exception
+                    {
+                        updated0(config);
+                        return null;
+                    }
+                });
+            }
+            catch (PrivilegedActionException e)
+            {
+                final Exception x = e.getException();
+                if (x instanceof ConfigurationException)
+                {
+                    throw (ConfigurationException) x;
+                }
+                else
+                {
+                    throw new ConfigurationException("?", "Update failed", x);
+                }
+            }
+        }
+        else
+        {
+            updated0(config);
+        }
+    }
 
-    public void updated( Dictionary config ) throws ConfigurationException
+    void updated0( Dictionary config ) throws ConfigurationException
     {
         // validate hashed password
         if ( isPasswordHashed( config ) )

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java?rev=1619371&r1=1619370&r2=1619371&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
Thu Aug 21 11:55:37 2014
@@ -18,6 +18,9 @@ package org.apache.felix.webconsole.inte
 
 import java.io.IOException;
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -447,7 +450,33 @@ public class OsgiManager extends Generic
         throws ServletException, IOException
     {
         // don't really expect to be called within a non-HTTP environment
-        service((HttpServletRequest) req, (HttpServletResponse) res);
+        try
+        {
+            AccessController.doPrivileged(new PrivilegedExceptionAction()
+            {
+                public Object run() throws Exception
+                {
+                    service((HttpServletRequest) req, (HttpServletResponse) res);
+                    return null;
+                }
+            });
+        }
+        catch (PrivilegedActionException e)
+        {
+            Exception x = e.getException();
+            if (x instanceof IOException)
+            {
+                throw (IOException) x;
+            }
+            else if (x instanceof ServletException)
+            {
+                throw (ServletException) x;
+            }
+            else
+            {
+                throw new IOException(x.toString());
+            }
+        }
 
         // ensure response has been sent back and response is committed
         // (we are authorative for our URL space and no other servlet should interfere)
@@ -471,7 +500,7 @@ public class OsgiManager extends Generic
         }
     }
 
-    private void service(HttpServletRequest request, HttpServletResponse response)
+    void service(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
     {
         // check whether we are not at .../{webManagerRoot}



Mime
View raw message