Author: alessio.soldano(a)jboss.com
Date: 2011-02-22 07:52:09 -0500 (Tue, 22 Feb 2011)
New Revision: 13783
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SecurityActions.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SpringUtils.java
Log:
Adding missing security action class
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SecurityActions.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SecurityActions.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SecurityActions.java 2011-02-22
12:52:09 UTC (rev 13783)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.stack.cxf.client.util;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 22-Feb-2011
+ *
+ */
+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;
+ }
+ });
+ }
+ }
+
+}
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SpringUtils.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SpringUtils.java 2011-02-22
11:56:06 UTC (rev 13782)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SpringUtils.java 2011-02-22
12:52:09 UTC (rev 13783)
@@ -35,7 +35,7 @@
{
SPRING_AVAILABLE =
isSpringAvailable(SpringUtils.class.getClassLoader(),
- Thread.currentThread().getContextClassLoader());
+ SecurityActions.getContextClassLoader());
}
/**
* Check if Spring is available using the provided classloader
@@ -47,7 +47,7 @@
{
if (loaders == null || loaders.length == 0)
{
- loaders = new ClassLoader[]{Thread.currentThread().getContextClassLoader()};
+ loaders = new ClassLoader[]{SecurityActions.getContextClassLoader()};
}
for (ClassLoader cl : loaders)
{