Author: alessio.soldano(a)jboss.com
Date: 2010-02-17 12:00:39 -0500 (Wed, 17 Feb 2010)
New Revision: 11607
Added:
common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/SecurityActions.java
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java
Modified:
common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/JBossWSEntityResolver.java
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java
Log:
[JBWS-2895] Adding proper security actions classes
Modified:
common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/JBossWSEntityResolver.java
===================================================================
---
common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/JBossWSEntityResolver.java 2010-02-17
12:43:29 UTC (rev 11606)
+++
common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/JBossWSEntityResolver.java 2010-02-17
17:00:39 UTC (rev 11607)
@@ -66,7 +66,7 @@
super();
Properties props = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader(); //TODO Use
SecurityAction!!
+ ClassLoader loader = SecurityActions.getContextClassLoader();
Map<String, Properties> map = propertiesMap.get(loader);
if (map != null && map.containsKey(entitiesResource))
{
Added:
common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/SecurityActions.java
===================================================================
--- common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/SecurityActions.java
(rev 0)
+++
common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/SecurityActions.java 2010-02-17
17:00:39 UTC (rev 11607)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jboss.ws.core.utils;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 17-Feb-2010
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param classLoader the classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+}
Property changes on:
common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java
===================================================================
---
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java 2010-02-17
12:43:29 UTC (rev 11606)
+++
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java 2010-02-17
17:00:39 UTC (rev 11607)
@@ -52,8 +52,7 @@
public AbstractDeploymentAspect()
{
- //TODO!!! Use security action
- this.loader = new
WeakReference<ClassLoader>(Thread.currentThread().getContextClassLoader());
+ this.loader = new
WeakReference<ClassLoader>(SecurityActions.getContextClassLoader());
}
public ClassLoader getLoader()
Added:
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java
===================================================================
---
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java
(rev 0)
+++
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java 2010-02-17
17:00:39 UTC (rev 11607)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jboss.wsf.common.integration;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 17-Feb-2010
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param classLoader the classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+}
Property changes on:
common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF