Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2173611E9E for ; Thu, 21 Aug 2014 11:56:02 +0000 (UTC) Received: (qmail 67800 invoked by uid 500); 21 Aug 2014 11:56:02 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 67762 invoked by uid 500); 21 Aug 2014 11:56:01 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 67753 invoked by uid 99); 21 Aug 2014 11:56:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Aug 2014 11:56:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Aug 2014 11:55:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8FE7C23889EC; Thu, 21 Aug 2014 11:55:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@felix.apache.org From: vvalchev@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140821115537.8FE7C23889EC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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}