JBossWS SVN: r10209 - in stack/native/trunk/modules: core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb and 18 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-06-20 20:56:24 -0400 (Sat, 20 Jun 2009)
New Revision: 10209
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/SecurityActions.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/SecurityActions.java
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/JBossXBMarshallerImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceFactoryImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactoryJAXRPC.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/CustomizableJAXBContextFactory.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/DispatcherFactory.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/Util.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/ReceiveX509Certificate.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaToXSD.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSTools.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/wstools.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/ToolsSchemaConfigReader.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/JavaToXSDFactory.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
stack/native/trunk/modules/jaxrpc/src/main/java/javax/xml/rpc/ServiceFactory.java
stack/native/trunk/modules/jaxws-ext/src/main/java/javax/xml/ws/addressing/AddressingBuilder.java
stack/native/trunk/modules/jaxws/src/main/java/javax/xml/ws/spi/ProviderLoader.java
stack/native/trunk/modules/saaj/src/main/java/javax/xml/soap/SAAJFactoryLoader.java
stack/native/trunk/modules/saaj/src/main/java/javax/xml/soap/SOAPConnectionFactory.java
Log:
[JBWS-2668] Adding required privileged blocks
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -208,7 +208,7 @@
{
if (epMetaData == null)
{
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader ctxLoader = SecurityActions.getContextClassLoader();
UnifiedVirtualFile vfsRoot = new ResourceLoaderAdapter();
UnifiedMetaData wsMetaData = new UnifiedMetaData(vfsRoot);
wsMetaData.setClassLoader(ctxLoader);
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/JBossXBMarshallerImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/JBossXBMarshallerImpl.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/JBossXBMarshallerImpl.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -113,7 +113,7 @@
if (variableMappings != null)
{
String clsName = javaXmlMapping.getJavaType();
- Class cls = JavaUtils.loadJavaType(clsName, Thread.currentThread().getContextClassLoader());
+ Class cls = JavaUtils.loadJavaType(clsName, SecurityActions.getContextClassLoader());
QName clsQName = javaXmlMapping.getRootTypeQName();
if (clsQName != null)
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.jaxrpc.binding.jbossxb;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.jaxrpc.client;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ static URL getResource(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResource(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run()
+ {
+ return cl.getResource(filename);
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceFactoryImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceFactoryImpl.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceFactoryImpl.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -117,9 +117,9 @@
*/
public Service createService(URL wsdlURL, QName serviceName) throws ServiceException
{
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ ClassLoader cl = SecurityActions.getContextClassLoader();
- URL mappingURL = cl.getResource("META-INF/jaxrpc-mapping.xml");
+ URL mappingURL = SecurityActions.getResource(cl, "META-INF/jaxrpc-mapping.xml");
if (mappingURL != null)
log.info("Use jaxrpc-mapping from: " + mappingURL);
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -104,7 +104,7 @@
this.wsdlLocation = wsdlURL;
JAXRPCClientMetaDataBuilder builder = new JAXRPCClientMetaDataBuilder();
- ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader ctxClassLoader = SecurityActions.getContextClassLoader();
serviceMetaData = builder.buildMetaData(serviceName, wsdlURL, mappingURL, securityURL, null, ctxClassLoader);
handlerRegistry = new HandlerRegistryImpl(serviceMetaData);
@@ -119,7 +119,7 @@
this.usrMetaData = usrMetaData;
JAXRPCClientMetaDataBuilder builder = new JAXRPCClientMetaDataBuilder();
- ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader ctxClassLoader = SecurityActions.getContextClassLoader();
serviceMetaData = builder.buildMetaData(serviceName, wsdlURL, mappingURL, securityConfig, usrMetaData, ctxClassLoader);
handlerRegistry = new HandlerRegistryImpl(serviceMetaData);
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactoryJAXRPC.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactoryJAXRPC.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactoryJAXRPC.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -228,8 +228,8 @@
********************************************************/
// load the service interface class
- ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
- Class siClass = contextCL.loadClass(serviceRef.getServiceInterface());
+ ClassLoader contextCL = SecurityActions.getContextClassLoader();
+ Class<?> siClass = SecurityActions.loadClass(contextCL, serviceRef.getServiceInterface());
if (Service.class.isAssignableFrom(siClass) == false)
throw new JAXRPCException("The service interface does not implement javax.xml.rpc.Service: " + siClass.getName());
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/CustomizableJAXBContextFactory.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/CustomizableJAXBContextFactory.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/CustomizableJAXBContextFactory.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -21,6 +21,9 @@
*/
package org.jboss.ws.core.jaxws;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Collection;
import javax.xml.bind.JAXBContext;
@@ -83,15 +86,27 @@
}
}
- public JAXBContext createContext(Class[] clazzes, BindingCustomization bcust) throws WSException
+ public JAXBContext createContext(final Class[] clazzes, final BindingCustomization bcust) throws WSException
{
try
{
- JAXBContext jaxbCtx = JAXBContext.newInstance(clazzes, bcust);
+ JAXBContext jaxbCtx = AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
+ public JAXBContext run() throws PrivilegedActionException
+ {
+ try
+ {
+ return JAXBContext.newInstance(clazzes, bcust);
+ }
+ catch (JAXBException e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
incrementContextCount();
return jaxbCtx;
}
- catch (JAXBException e)
+ catch (Exception e)
{
throw new WSException("Failed to create JAXBContext", e);
}
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.jaxws.client;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ static URL getResource(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResource(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run()
+ {
+ return cl.getResource(filename);
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -99,8 +99,8 @@
log.debug("[name=" + serviceRefName + ",service=" + serviceImplClass + ",target=" + targetClassName + "]");
// Load the service class
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- Class serviceClass = ctxLoader.loadClass(serviceImplClass);
+ ClassLoader ctxLoader = SecurityActions.getContextClassLoader();
+ Class serviceClass = SecurityActions.loadClass(ctxLoader, serviceImplClass);
Class targetClass = (targetClassName != null ? ctxLoader.loadClass(targetClassName) : null);
if (Service.class.isAssignableFrom(serviceClass) == false)
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/DispatcherFactory.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/DispatcherFactory.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/DispatcherFactory.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -43,7 +43,8 @@
Reference ref = (Reference)object;
String hostname = (String)ref.get(DispatcherDelegate.MANAGER_HOSTNAME).getContent();
- Class cls = Thread.currentThread().getContextClassLoader().loadClass(ref.getClassName());
+ ClassLoader loader = SecurityActions.getContextClassLoader();
+ Class<?> cls = SecurityActions.loadClass(loader, ref.getClassName());
DispatcherDelegate delegate = (DispatcherDelegate)cls.newInstance();
delegate.setHostname(hostname);
return delegate;
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.extensions.eventing.mgmt;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.extensions.security;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Get a system property
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ static String getSystemProperty(final String name)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return System.getProperty(name);
+ }
+ else
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>() {
+ public String run()
+ {
+ return System.getProperty(name);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -97,7 +97,7 @@
private void loadKeyStore(URL keyStoreURL, String keyStoreType, String keyStorePassword) throws WSSecurityException
{
if (keyStorePassword == null)
- keyStorePassword = System.getProperty("org.jboss.ws.wsse.keyStorePassword");
+ keyStorePassword = SecurityActions.getSystemProperty("org.jboss.ws.wsse.keyStorePassword");
keyStore = loadStore("org.jboss.ws.wsse.keyStore", "Keystore", keyStoreURL, keyStoreType, keyStorePassword);
this.keyStorePassword = keyStorePassword;
@@ -106,7 +106,7 @@
private void loadTrustStore(URL trustStoreURL, String trustStoreType, String trustStorePassword) throws WSSecurityException
{
if (trustStorePassword == null)
- trustStorePassword = System.getProperty("org.jboss.ws.wsse.trustStorePassword");
+ trustStorePassword = SecurityActions.getSystemProperty("org.jboss.ws.wsse.trustStorePassword");
trustStore = loadStore("org.jboss.ws.wsse.trustStore", "Truststore", trustStoreURL, trustStoreType, trustStorePassword);
this.trustStorePassword = trustStorePassword;
@@ -116,7 +116,7 @@
{
if (storeURL == null)
{
- String defaultStore = System.getProperty(property);
+ String defaultStore = SecurityActions.getSystemProperty(property);
if (defaultStore == null)
{
return null;
@@ -134,7 +134,7 @@
}
if (storeType == null)
- storeType = System.getProperty(property + "Type");
+ storeType = SecurityActions.getSystemProperty(property + "Type");
if (storeType == null)
storeType = "jks";
@@ -275,7 +275,7 @@
log.debug("Loading class: " + classname + ", ctorArg=" + ctorArg);
try
{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
Class c = loader.loadClass(classname);
Object instance = null;
if (ctorArg != null)
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/Util.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/Util.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/Util.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -218,13 +218,13 @@
@SuppressWarnings("unchecked")
public static <T> T loadFactory(Class<T> factoryType, String factoryClassName, Class<? extends T> defaultFactoryClassName)
{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String name = factoryClassName != null ? factoryClassName : System.getProperty(factoryType.getName());
+ ClassLoader loader = SecurityActions.getContextClassLoader();
+ String name = factoryClassName != null ? factoryClassName : SecurityActions.getSystemProperty(factoryType.getName());
if (name == null)
name = defaultFactoryClassName.getName();
try
{
- Class<T> cl = (Class<T>)loader.loadClass(name);
+ Class<T> cl = (Class<T>)SecurityActions.loadClass(loader, name);
return cl.newInstance();
}
catch (Exception e)
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/ReceiveX509Certificate.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/ReceiveX509Certificate.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/ReceiveX509Certificate.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -56,7 +56,7 @@
{
try
{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
Class<?> cpClass = loader.loadClass(certificatePrincipal);
certMapping = (CertificatePrincipal) cpClass.newInstance();
}
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.extensions.security.operation;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/operation/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -119,7 +119,7 @@
private ClassLoader getClassLoader()
{
// The EndpointMetaData classloader is not availabel for a handler associaated with a JAXWS Service.handlerResolver
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader ctxLoader = SecurityActions.getContextClassLoader();
return (epMetaData != null ? epMetaData.getClassLoader() : ctxLoader);
}
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.metadata.umdm;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -82,7 +82,7 @@
throw new IllegalArgumentException("VFS root cannot be null");
this.vfsRoot = vfsRoot;
- this.classLoader = Thread.currentThread().getContextClassLoader();
+ this.classLoader = SecurityActions.getContextClassLoader();
}
public ClassLoader getClassLoader()
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaToXSD.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaToXSD.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaToXSD.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -224,15 +224,15 @@
String resource = (String)resolver.getEntityMap().get(nsURI);
if (resource != null)
{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- url = loader.getResource(resource);
+ ClassLoader loader = SecurityActions.getContextClassLoader();
+ url = SecurityActions.getResource(loader, resource);
if (url == null)
{
if (resource.endsWith(".dtd"))
resource = "dtd/" + resource;
else if (resource.endsWith(".xsd"))
resource = "schema/" + resource;
- url = loader.getResource(resource);
+ url = SecurityActions.getResource(loader, resource);
}
}
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tools;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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 cl the classloader
+ * @return previous context classloader
+ * @throws Throwable for any error
+ */
+ static ClassLoader setContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Error setting context classloader", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("Error running privileged action", e.getCause());
+ }
+ }
+ }
+
+ static URL getResource(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResource(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run()
+ {
+ return cl.getResource(filename);
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSTools.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSTools.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSTools.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -119,9 +119,9 @@
urls[j] = new File(token).toURL();
}
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader ctxLoader = SecurityActions.getContextClassLoader();
URLClassLoader urlLoader = new URLClassLoader(urls, ctxLoader);
- Thread.currentThread().setContextClassLoader(urlLoader);
+ SecurityActions.setContextClassLoader(urlLoader);
i++;
}
else
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tools.ant;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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 cl the classloader
+ * @return previous context classloader
+ * @throws Throwable for any error
+ */
+ static ClassLoader setContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Error setting context classloader", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("Error running privileged action", e.getCause());
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/wstools.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/wstools.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/wstools.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -95,8 +95,8 @@
public void execute() throws BuildException
{
- ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ ClassLoader prevCL = SecurityActions.getContextClassLoader();
+ SecurityActions.setContextClassLoader(this.getClass().getClassLoader());
try
{
String[] args = new String[] { "-dest", dest, "-config", config };
@@ -116,7 +116,7 @@
}
finally
{
- Thread.currentThread().setContextClassLoader(prevCL);
+ SecurityActions.setContextClassLoader(prevCL);
}
}
}
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tools.config;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ static URL getResource(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResource(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run()
+ {
+ return cl.getResource(filename);
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/ToolsSchemaConfigReader.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/ToolsSchemaConfigReader.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/config/ToolsSchemaConfigReader.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -118,8 +118,8 @@
if (configURL == null)
{
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- configURL = ctxLoader.getResource(configLocation);
+ ClassLoader ctxLoader = SecurityActions.getContextClassLoader();
+ configURL = SecurityActions.getResource(ctxLoader, configLocation);
}
if (configURL == null)
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/JavaToXSDFactory.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/JavaToXSDFactory.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/JavaToXSDFactory.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -47,8 +47,8 @@
{
String defaultName = "org.jboss.ws.tools.factories.JavaToXSDFactory";
factoryName = System.getProperty("org.jboss.ws.tools.JavaToXSDFactory", defaultName);
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class factoryClass = loader.loadClass(factoryName);
+ ClassLoader loader = SecurityActions.getContextClassLoader();
+ Class factoryClass = SecurityActions.loadClass(loader, factoryName);
factory = (JavaToXSDFactory) factoryClass.newInstance();
}
catch(Throwable e)
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tools.factories;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/factories/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tools.helpers;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ static URL getResource(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResource(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run()
+ {
+ return cl.getResource(filename);
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -288,8 +288,8 @@
if (wsdlURL == null)
{
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- wsdlURL = ctxLoader.getResource(w2jc.wsdlLocation);
+ ClassLoader ctxLoader = SecurityActions.getContextClassLoader();
+ wsdlURL = SecurityActions.getResource(ctxLoader, w2jc.wsdlLocation);
}
if (wsdlURL == null)
@@ -378,9 +378,9 @@
Class clazz = null;
try
{
- clazz = Thread.currentThread().getContextClassLoader().loadClass(cls);
+ clazz = SecurityActions.loadClass(SecurityActions.getContextClassLoader(), cls);
}
- catch (ClassNotFoundException e)
+ catch (Exception e)
{
log.error("Cannot load endpoint:" + e.getLocalizedMessage());
}
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tools.metadata;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/metadata/ToolsUnifiedMetaDataBuilder.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -82,7 +82,7 @@
if (!Remote.class.isAssignableFrom(seiClass))
throw new WSException("A service endpoint interface should extend Remote");
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader contextClassLoader = SecurityActions.getContextClassLoader();
ResourceLoaderAdapter vfsRoot = new ResourceLoaderAdapter();
um = new UnifiedMetaData(vfsRoot);
um.setClassLoader(contextClassLoader);
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -86,7 +86,6 @@
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
import org.jboss.ws.metadata.umdm.EndpointMetaData.Type;
-import org.jboss.wsf.common.DOMUtils;
import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.common.IOUtils;
import org.jboss.wsf.spi.SPIProvider;
@@ -197,8 +196,8 @@
throw new IllegalStateException("Deployment has no classloader associated");
// Set the thread context class loader
- ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
+ ClassLoader ctxClassLoader = SecurityActions.getContextClassLoader();
+ SecurityActions.setContextClassLoader(classLoader);
try
{
ServletRequestContext reqContext = new ServletRequestContext(context, req, res);
@@ -211,7 +210,7 @@
finally
{
// Reset the thread context class loader
- Thread.currentThread().setContextClassLoader(ctxClassLoader);
+ SecurityActions.setContextClassLoader(ctxClassLoader);
try
{
@@ -415,7 +414,7 @@
throw new IllegalStateException("Cannot obtain endpoint meta data");
long beginProcessing = 0;
- ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader ctxClassLoader = SecurityActions.getContextClassLoader();
try
{
EndpointState state = ep.getState();
@@ -463,7 +462,7 @@
// Set the thread context class loader
ClassLoader classLoader = sepMetaData.getClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
+ SecurityActions.setContextClassLoader(classLoader);
// Get the Invoker
ServiceEndpointInvoker epInvoker = ep.getAttachment(ServiceEndpointInvoker.class);
@@ -524,7 +523,7 @@
}
// Reset the thread context class loader
- Thread.currentThread().setContextClassLoader(ctxClassLoader);
+ SecurityActions.setContextClassLoader(ctxClassLoader);
log.debug("END handleRequest: " + ep.getName());
}
}
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/SecurityActions.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/SecurityActions.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.jbws;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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 cl the classloader
+ * @return previous context classloader
+ * @throws Throwable for any error
+ */
+ static ClassLoader setContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Error setting context classloader", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("Error running privileged action", e.getCause());
+ }
+ }
+ }
+}
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/jaxrpc/src/main/java/javax/xml/rpc/ServiceFactory.java
===================================================================
--- stack/native/trunk/modules/jaxrpc/src/main/java/javax/xml/rpc/ServiceFactory.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/jaxrpc/src/main/java/javax/xml/rpc/ServiceFactory.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -21,9 +21,12 @@
*/
package javax.xml.rpc;
+import java.io.InputStream;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Properties;
import java.util.logging.Logger;
@@ -76,12 +79,12 @@
PrivilegedAction action = new PropertyAccessAction(SERVICEFACTORY_PROPERTY, DEFAULT_SERVICE_FACTORY);
String factoryName = (String)AccessController.doPrivileged(action);
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
try
{
try
{
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
factory = (ServiceFactory)factoryClass.newInstance();
}
catch (ClassNotFoundException e)
@@ -95,7 +98,7 @@
factoryName = alternativeFactories[i];
try
{
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
return (ServiceFactory)factoryClass.newInstance();
}
catch (ClassNotFoundException e1)
@@ -189,4 +192,53 @@
return System.getProperty(name, defaultValue);
}
}
+
+ private static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ private 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();
+ }
+ });
+ }
+ }
+
}
Modified: stack/native/trunk/modules/jaxws/src/main/java/javax/xml/ws/spi/ProviderLoader.java
===================================================================
--- stack/native/trunk/modules/jaxws/src/main/java/javax/xml/ws/spi/ProviderLoader.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/jaxws/src/main/java/javax/xml/ws/spi/ProviderLoader.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -29,6 +29,8 @@
import java.io.InputStreamReader;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Properties;
/**
@@ -70,12 +72,12 @@
{
Object factory = null;
String factoryName = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
// Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
String propertyName = Provider.JAXWSPROVIDER_PROPERTY;
String filename = "META-INF/services/" + propertyName;
- InputStream inStream = loader.getResourceAsStream(filename);
+ InputStream inStream = getResourceAsStream(loader, filename);
if (inStream != null)
{
try
@@ -85,7 +87,7 @@
br.close();
if (factoryName != null)
{
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
}
@@ -102,7 +104,7 @@
PrivilegedAction action = new PropertyAccessAction("java.home");
String javaHome = (String)AccessController.doPrivileged(action);
File jaxmFile = new File(javaHome + "/lib/jaxws.properties");
- if (jaxmFile.exists())
+ if ((Boolean)AccessController.doPrivileged(new PropertyFileExistAction(jaxmFile)))
{
try
{
@@ -112,7 +114,7 @@
if (factoryName != null)
{
//if(log.isDebugEnabled()) log.debug("Load from " + jaxmFile + ": " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
}
@@ -133,7 +135,7 @@
try
{
//if(log.isDebugEnabled()) log.debug("Load from system property: " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
catch (Throwable t)
@@ -149,7 +151,7 @@
try
{
//if(log.isDebugEnabled()) log.debug("Load from default: " + factoryName);
- Class factoryClass = loader.loadClass(defaultFactory);
+ Class factoryClass = loadClass(loader, defaultFactory);
factory = factoryClass.newInstance();
}
catch (Throwable t)
@@ -200,4 +202,85 @@
}
}
}
+
+ private static class PropertyFileExistAction implements PrivilegedAction
+ {
+ private File file;
+
+ PropertyFileExistAction(File file)
+ {
+ this.file = file;
+ }
+
+ public Object run()
+ {
+ return file.exists();
+ }
+ }
+
+ private static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ private static InputStream getResourceAsStream(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+ public InputStream run()
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ });
+ }
+ }
+
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ private 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();
+ }
+ });
+ }
+ }
}
Modified: stack/native/trunk/modules/jaxws-ext/src/main/java/javax/xml/ws/addressing/AddressingBuilder.java
===================================================================
--- stack/native/trunk/modules/jaxws-ext/src/main/java/javax/xml/ws/addressing/AddressingBuilder.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/jaxws-ext/src/main/java/javax/xml/ws/addressing/AddressingBuilder.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -26,6 +26,10 @@
import java.net.URI;
import java.net.URISyntaxException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
@@ -44,7 +48,7 @@
ClassLoader classLoader;
try
{
- classLoader = Thread.currentThread().getContextClassLoader();
+ classLoader = getContextClassLoader();
}
catch (Exception x)
{
@@ -56,7 +60,7 @@
// Use the system property first
try
{
- name = System.getProperty(ADDRESSING_BUILDER_PROPERTY);
+ name = getSystemProperty(ADDRESSING_BUILDER_PROPERTY);
if (name != null)
{
return newInstance(name, classLoader);
@@ -82,7 +86,7 @@
}
else
{
- cls = classLoader.loadClass(className);
+ cls = loadClass(classLoader, className);
}
return (AddressingBuilder)cls.newInstance();
}
@@ -109,4 +113,78 @@
public abstract AddressingProperties newAddressingProperties();
public abstract AddressingConstants newAddressingConstants();
+
+ /**
+ * Get a system property
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ private static String getSystemProperty(final String name)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return System.getProperty(name);
+ }
+ else
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>() {
+ public String run()
+ {
+ return System.getProperty(name);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+ }
+
+ private static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ private 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();
+ }
+ });
+ }
+ }
}
Modified: stack/native/trunk/modules/saaj/src/main/java/javax/xml/soap/SAAJFactoryLoader.java
===================================================================
--- stack/native/trunk/modules/saaj/src/main/java/javax/xml/soap/SAAJFactoryLoader.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/saaj/src/main/java/javax/xml/soap/SAAJFactoryLoader.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -29,6 +29,8 @@
import java.io.InputStreamReader;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Properties;
/**
@@ -42,6 +44,7 @@
* </ol>
*
* @author Thomas.Diesler(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
* @since 14-Dec-2006
*/
class SAAJFactoryLoader
@@ -49,7 +52,7 @@
private SAAJFactoryLoader()
{
}
-
+
/**
*
* @return the factory impl, or null
@@ -57,7 +60,7 @@
public static Object loadFactory(String propertyName, String defaultFactory)
{
Object factory = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
// Use the system property
PrivilegedAction action = new PropertyAccessAction(propertyName);
@@ -67,7 +70,7 @@
try
{
//if(log.isDebugEnabled()) log.debug("Load from system property: " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
catch (Throwable t)
@@ -83,7 +86,7 @@
action = new PropertyAccessAction("java.home");
String javaHome = (String)AccessController.doPrivileged(action);
File jaxmFile = new File(javaHome + "/lib/jaxm.properties");
- if (jaxmFile.exists())
+ if ((Boolean)AccessController.doPrivileged(new PropertyFileExistAction(jaxmFile)))
{
try
{
@@ -93,7 +96,7 @@
if (factoryName != null)
{
//if(log.isDebugEnabled()) log.debug("Load from " + jaxmFile + ": " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
}
@@ -108,7 +111,7 @@
if (factory == null)
{
String filename = "META-INF/services/" + propertyName;
- InputStream inStream = loader.getResourceAsStream(filename);
+ InputStream inStream = getResourceAsStream(loader, filename);
if (inStream != null)
{
try
@@ -119,7 +122,7 @@
if (factoryName != null)
{
//if(log.isTraceEnabled()) log.trace("Load from Service API " + filename + ": " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
}
@@ -137,7 +140,7 @@
{
factoryName = defaultFactory;
//if(log.isDebugEnabled()) log.debug("Load from default: " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
catch (Throwable t)
@@ -188,4 +191,81 @@
}
}
}
+
+ private static class PropertyFileExistAction implements PrivilegedAction
+ {
+ private File file;
+
+ PropertyFileExistAction(File file)
+ {
+ this.file = file;
+ }
+
+ public Object run()
+ {
+ return file.exists();
+ }
+ }
+
+ private 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();
+ }
+ });
+ }
+ }
+
+ private static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ private static InputStream getResourceAsStream(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+ public InputStream run()
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ });
+ }
+ }
+
}
Modified: stack/native/trunk/modules/saaj/src/main/java/javax/xml/soap/SOAPConnectionFactory.java
===================================================================
--- stack/native/trunk/modules/saaj/src/main/java/javax/xml/soap/SOAPConnectionFactory.java 2009-06-21 00:54:45 UTC (rev 10208)
+++ stack/native/trunk/modules/saaj/src/main/java/javax/xml/soap/SOAPConnectionFactory.java 2009-06-21 00:56:24 UTC (rev 10209)
@@ -23,6 +23,8 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.logging.Logger;
/** A factory for creating SOAPConnection objects. Implementation of this class
@@ -55,12 +57,12 @@
PrivilegedAction action = new PropertyAccessAction(SOAPConnectionFactory.class.getName(), DEFAULT_SOAP_CONNECTION_FACTORY);
String factoryName = (String)AccessController.doPrivileged(action);
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
try
{
try
{
- Class factoryClass = loader.loadClass(factoryName);
+ Class<?> factoryClass = loadClass(loader, factoryName);
return (SOAPConnectionFactory)factoryClass.newInstance();
}
catch (ClassNotFoundException e)
@@ -110,4 +112,47 @@
return System.getProperty(name, defaultValue);
}
}
+
+ private 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();
+ }
+ });
+ }
+ }
+
+ private static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
}
14 years, 10 months
JBossWS SVN: r10208 - in common/trunk/src/main/java/org/jboss/wsf/common: servlet and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-06-20 20:54:45 -0400 (Sat, 20 Jun 2009)
New Revision: 10208
Added:
common/trunk/src/main/java/org/jboss/wsf/common/SecurityActions.java
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java
common/trunk/src/main/java/org/jboss/wsf/common/ResourceLoaderAdapter.java
common/trunk/src/main/java/org/jboss/wsf/common/servlet/AbstractEndpointServlet.java
Log:
[JBWS-2668] Adding required privileged blocks
Modified: common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java 2009-06-21 00:54:08 UTC (rev 10207)
+++ common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java 2009-06-21 00:54:45 UTC (rev 10208)
@@ -112,12 +112,12 @@
String[] resolvers = new String[] { "org.jboss.ws.core.utils.JBossWSEntityResolver", "org.jboss.util.xml.JBossEntityResolver" };
EntityResolver entityResolver = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
for (String resolver : resolvers)
{
try
{
- Class<?> resolverClass = loader.loadClass(resolver);
+ Class<?> resolverClass = SecurityActions.loadClass(loader, resolver);
entityResolver = (EntityResolver)resolverClass.newInstance();
}
catch (Exception ex)
Modified: common/trunk/src/main/java/org/jboss/wsf/common/ResourceLoaderAdapter.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/ResourceLoaderAdapter.java 2009-06-21 00:54:08 UTC (rev 10207)
+++ common/trunk/src/main/java/org/jboss/wsf/common/ResourceLoaderAdapter.java 2009-06-21 00:54:45 UTC (rev 10208)
@@ -53,7 +53,7 @@
public ResourceLoaderAdapter()
{
- this(Thread.currentThread().getContextClassLoader());
+ this(SecurityActions.getContextClassLoader());
}
public ResourceLoaderAdapter(ClassLoader loader)
Added: common/trunk/src/main/java/org/jboss/wsf/common/SecurityActions.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/SecurityActions.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/SecurityActions.java 2009-06-21 00:54:45 UTC (rev 10208)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Property changes on: common/trunk/src/main/java/org/jboss/wsf/common/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: common/trunk/src/main/java/org/jboss/wsf/common/servlet/AbstractEndpointServlet.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/servlet/AbstractEndpointServlet.java 2009-06-21 00:54:08 UTC (rev 10207)
+++ common/trunk/src/main/java/org/jboss/wsf/common/servlet/AbstractEndpointServlet.java 2009-06-21 00:54:45 UTC (rev 10208)
@@ -22,6 +22,8 @@
package org.jboss.wsf.common.servlet;
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import javax.management.ObjectName;
import javax.servlet.ServletConfig;
@@ -165,9 +167,27 @@
if (isJaxrpcJse || isJaxwsJse)
{
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader classLoader = getContextClassLoader();
dep.setRuntimeClassLoader(classLoader);
}
}
+ private 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();
+ }
+ });
+ }
+ }
+
}
14 years, 10 months
JBossWS SVN: r10207 - in spi/trunk/src/main/java/org/jboss/wsf/spi: tools/ant and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-06-20 20:54:08 -0400 (Sat, 20 Jun 2009)
New Revision: 10207
Added:
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java
spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java
spi/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java
Log:
[JBWS-2668] Adding required privileged blocks
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java (rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.spi.tools;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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 cl the classloader
+ * @return previous context classloader
+ * @throws Throwable for any error
+ */
+ static ClassLoader setContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Error setting context classloader", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("Error running privileged action", e.getCause());
+ }
+ }
+ }
+}
Property changes on: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java 2009-06-19 16:36:27 UTC (rev 10206)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -52,7 +52,7 @@
*/
public static WSContractConsumer newInstance()
{
- return newInstance(Thread.currentThread().getContextClassLoader());
+ return newInstance(SecurityActions.getContextClassLoader());
}
/**
@@ -64,16 +64,16 @@
*/
public static WSContractConsumer newInstance(ClassLoader loader)
{
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader oldLoader = SecurityActions.getContextClassLoader();
try
{
- Thread.currentThread().setContextClassLoader(loader);
+ SecurityActions.setContextClassLoader(loader);
WSContractConsumerFactory factory = (WSContractConsumerFactory) ServiceLoader.loadService(PROVIDER_PROPERTY, DEFAULT_PROVIDER);
return factory.createConsumer();
}
finally
{
- Thread.currentThread().setContextClassLoader(oldLoader);
+ SecurityActions.setContextClassLoader(oldLoader);
}
}
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java 2009-06-19 16:36:27 UTC (rev 10206)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -67,7 +67,7 @@
*/
public static WSContractProvider newInstance()
{
- return newInstance(Thread.currentThread().getContextClassLoader());
+ return newInstance(SecurityActions.getContextClassLoader());
}
/**
@@ -79,16 +79,16 @@
*/
public static WSContractProvider newInstance(ClassLoader loader)
{
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader oldLoader = SecurityActions.getContextClassLoader();
try
{
- Thread.currentThread().setContextClassLoader(loader);
+ SecurityActions.setContextClassLoader(loader);
WSContractProviderFactory factory = (WSContractProviderFactory) ServiceLoader.loadService(PROVIDER_PROPERTY, DEFAULT_PROVIDER);
return factory.createProvider(loader);
}
finally
{
- Thread.currentThread().setContextClassLoader(oldLoader);
+ SecurityActions.setContextClassLoader(oldLoader);
}
}
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java (rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.spi.tools.ant;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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 cl the classloader
+ * @return previous context classloader
+ * @throws Throwable for any error
+ */
+ static ClassLoader setContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Error setting context classloader", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("Error running privileged action", e.getCause());
+ }
+ }
+ }
+
+ /**
+ * Get classloader from class.
+ *
+ * @param clazz the class
+ * @return class's classloader
+ */
+ static ClassLoader getClassLoader(final Class<?> clazz)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return clazz.getClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return clazz.getClassLoader();
+ }
+ });
+ }
+ }
+
+}
Property changes on: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java 2009-06-19 16:36:27 UTC (rev 10206)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.PrintStream;
-import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
@@ -183,9 +182,9 @@
public void executeNonForked()
{
- ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
- ClassLoader antLoader = this.getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(antLoader);
+ ClassLoader prevCL = SecurityActions.getContextClassLoader();
+ ClassLoader antLoader = SecurityActions.getClassLoader(this.getClass());
+ SecurityActions.setContextClassLoader(antLoader);
try
{
WSContractConsumer consumer = WSContractConsumer.newInstance();
@@ -226,7 +225,7 @@
}
finally
{
- Thread.currentThread().setContextClassLoader(prevCL);
+ SecurityActions.setContextClassLoader(prevCL);
}
}
@@ -243,7 +242,7 @@
private Path getTaskClassPath()
{
// Why is everything in the Ant API a big hack???
- ClassLoader cl = this.getClass().getClassLoader();
+ ClassLoader cl = SecurityActions.getClassLoader(this.getClass());
if (cl instanceof AntClassLoader)
{
return new Path(getProject(), ((AntClassLoader)cl).getClasspath());
@@ -256,7 +255,7 @@
{
// Why is everything in the Ant API a big hack???
List<String> strings = new ArrayList<String>();
- ClassLoader cl = this.getClass().getClassLoader();
+ ClassLoader cl = SecurityActions.getClassLoader(this.getClass());
if (cl instanceof AntClassLoader)
{
for (String string : ((AntClassLoader)cl).getClasspath().split(File.pathSeparator))
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java 2009-06-19 16:36:27 UTC (rev 10206)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -196,9 +196,9 @@
public void executeNonForked()
{
- ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
- ClassLoader antLoader = this.getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(antLoader);
+ ClassLoader prevCL = SecurityActions.getContextClassLoader();
+ ClassLoader antLoader = SecurityActions.getClassLoader(this.getClass());
+ SecurityActions.setContextClassLoader(antLoader);
try
{
WSContractProvider gen = WSContractProvider.newInstance(
@@ -225,7 +225,7 @@
}
finally
{
- Thread.currentThread().setContextClassLoader(prevCL);
+ SecurityActions.setContextClassLoader(prevCL);
}
}
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java (rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.spi.tools.cmd;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Get a system property
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ static String getSystemProperty(final String name, final String defaultValue)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ else
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>() {
+ public String run()
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+ }
+}
Property changes on: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java 2009-06-19 16:36:27 UTC (rev 10206)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -71,7 +71,7 @@
private File sourceDir = null;
private String target = null;
- public static final String PROGRAM_NAME = System.getProperty("program.name", WSConsume.class.getName());
+ public static final String PROGRAM_NAME = SecurityActions.getSystemProperty("program.name", WSConsume.class.getName());
public static void main(String[] args)
{
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java 2009-06-19 16:36:27 UTC (rev 10206)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -62,12 +62,12 @@
private boolean quiet = false;
private boolean showTraces = false;
private boolean loadProvider = false;
- private ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ private ClassLoader loader = SecurityActions.getContextClassLoader();
private File outputDir = new File("output");
private File resourceDir = null;
private File sourceDir = null;
- public static final String PROGRAM_NAME = System.getProperty("program.name", WSProvide.class.getSimpleName());
+ public static final String PROGRAM_NAME = SecurityActions.getSystemProperty("program.name", WSProvide.class.getSimpleName());
public static void main(String[] args)
{
@@ -158,9 +158,9 @@
{
try
{
- loader.loadClass(endpoint);
+ SecurityActions.loadClass(loader, endpoint);
}
- catch (ClassNotFoundException e)
+ catch (Exception e)
{
System.err.println("Error: Could not load class [" + endpoint + "]. Did you specify a valid --classpath?");
return 1;
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java (rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.spi.util;
+
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Get resource as stream
+ *
+ * @param cl
+ * @param filename
+ * @return input stream
+ * @throws PrivilegedActionException
+ */
+ static InputStream getResourceAsStream(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+ public InputStream run()
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+}
Property changes on: spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java 2009-06-19 16:36:27 UTC (rev 10206)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java 2009-06-21 00:54:08 UTC (rev 10207)
@@ -35,6 +35,7 @@
* Load a service class using this ordered lookup procedure
*
* @author Thomas.Diesler(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
* @since 14-Dec-2006
*/
public abstract class ServiceLoader
@@ -74,11 +75,11 @@
{
Object factory = null;
String factoryName = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
// Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
String filename = "META-INF/services/" + propertyName;
- InputStream inStream = loader.getResourceAsStream(filename);
+ InputStream inStream = SecurityActions.getResourceAsStream(loader, filename);
if (inStream != null)
{
try
@@ -88,7 +89,7 @@
br.close();
if (factoryName != null)
{
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = SecurityActions.loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
}
@@ -112,7 +113,7 @@
public static Object loadFromSystemProperty(String propertyName, String defaultFactory)
{
Object factory = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
PrivilegedAction action = new PropertyAccessAction(propertyName);
String factoryName = (String)AccessController.doPrivileged(action);
@@ -121,7 +122,7 @@
try
{
//if(log.isDebugEnabled()) log.debug("Load from system property: " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class factoryClass = SecurityActions.loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
catch (Throwable t)
@@ -148,14 +149,14 @@
{
Object factory = null;
String factoryName = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
// Use the properties file "lib/jaxm.properties" in the JRE directory.
// This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above.
PrivilegedAction action = new PropertyAccessAction("java.home");
String javaHome = (String)AccessController.doPrivileged(action);
File jaxmFile = new File(javaHome + "/lib/jaxws.properties");
- if (jaxmFile.exists())
+ if ((Boolean)AccessController.doPrivileged(new PropertyFileExistAction(jaxmFile)))
{
try
{
@@ -165,7 +166,7 @@
if (factoryName != null)
{
//if(log.isDebugEnabled()) log.debug("Load from " + jaxmFile + ": " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class<?> factoryClass = SecurityActions.loadClass(loader, factoryName);
factory = factoryClass.newInstance();
}
}
@@ -187,7 +188,7 @@
private static Object loadDefault(String defaultFactory)
{
Object factory = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
// Use the default factory implementation class.
if (defaultFactory != null)
@@ -195,7 +196,7 @@
try
{
//if(log.isDebugEnabled()) log.debug("Load from default: " + factoryName);
- Class factoryClass = loader.loadClass(defaultFactory);
+ Class factoryClass = SecurityActions.loadClass(loader, defaultFactory);
factory = factoryClass.newInstance();
}
catch (Throwable t)
@@ -255,4 +256,19 @@
}
}
}
+
+ private static class PropertyFileExistAction implements PrivilegedAction
+ {
+ private File file;
+
+ PropertyFileExistAction(File file)
+ {
+ this.file = file;
+ }
+
+ public Object run()
+ {
+ return file.exists();
+ }
+ }
}
14 years, 10 months
JBossWS SVN: r10206 - in stack/native/branches/jbossws-native-2.0.1.SP2_CP/src: test/java/org/jboss/test/ws/common/soap and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-06-19 12:36:27 -0400 (Fri, 19 Jun 2009)
New Revision: 10206
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbpapp2127.xml
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/NodeImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
Log:
[JBPAPP-2127] Add support for Node.getTextContent.
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/NodeImpl.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/NodeImpl.java 2009-06-19 13:17:56 UTC (rev 10205)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/NodeImpl.java 2009-06-19 16:36:27 UTC (rev 10206)
@@ -607,8 +607,7 @@
public String getTextContent() throws DOMException
{
- // FIXME getTextContent
- throw new NotImplementedException("getTextContent");
+ return domNode.getTextContent();
}
public Object getUserData(String key)
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2009-06-19 13:17:56 UTC (rev 10205)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2009-06-19 16:36:27 UTC (rev 10206)
@@ -123,7 +123,39 @@
}
assertEquals("Strawberry Apple Banana Orange Raspberry ", sb.toString());
}
+
+ // JBPAPP-2127
+ public void testGetTextContent() throws Exception
+ {
+ InputStream is = new File("resources/common/soap/jbpapp2127.xml").toURL().openStream();
+ MessageFactory messageFactory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = messageFactory.createMessage(null, is);
+ NodeList nl = soapMessage.getSOAPBody().getChildNodes();
+ SOAPElement echo = null;
+ for (int i = 0; i < nl.getLength() && echo == null; i++)
+ {
+ Object current = nl.item(i);
+ if (current instanceof SOAPElement)
+ {
+ echo = (SOAPElement)current;
+ }
+ }
+ nl = echo.getChildNodes();
+ SOAPElement arg0 = null;
+ for (int i = 0; i < nl.getLength() && arg0 == null; i++)
+ {
+ Object current = nl.item(i);
+ if (current instanceof SOAPElement)
+ {
+ arg0 = (SOAPElement)current;
+ }
+ }
+ String value = arg0.getTextContent();
+
+ assertEquals("Expected value", "123", value);
+ }
+
// http://jira.jboss.com/jira/browse/JBWS-773
public void testGetNamespaceURI() throws Exception
{
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java 2009-06-19 13:17:56 UTC (rev 10205)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java 2009-06-19 16:36:27 UTC (rev 10206)
@@ -55,7 +55,8 @@
private String badMsgString =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:jbw='http://ws.jboss.org/jbws2682'>" +
- " <soapenv:Header/>" + " <soapenv:Body>" +
+ " <soapenv:Header/>" +
+ " <soapenv:Body>" +
" <jbw:echo>" +
" <arg0>1-1</arg0>" +
" </jbw:echo>" +
Added: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbpapp2127.xml
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbpapp2127.xml (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbpapp2127.xml 2009-06-19 16:36:27 UTC (rev 10206)
@@ -0,0 +1,8 @@
+<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:jbw='http://ws.jboss.org/jbpapp2127'>
+ <soapenv:Header/>
+ <soapenv:Body>
+ <jbw:echo>
+ <arg0>123</arg0>
+ </jbw:echo>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Property changes on: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbpapp2127.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
14 years, 10 months
JBossWS SVN: r10205 - in stack/native/branches/jbossws-native-2.0.1.SP2_CP: src/main/java/org/jboss/ws/core/soap and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-06-19 09:17:56 -0400 (Fri, 19 Jun 2009)
New Revision: 10205
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbws2346.xml
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/version.properties
Log:
[JBPAPP-2108] Issue with SAAJ API: SOAPBody.getElementsByTagNameNS() is non-recursive.
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-06-19 12:02:46 UTC (rev 10204)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-06-19 13:17:56 UTC (rev 10205)
@@ -740,7 +740,7 @@
public NodeList getElementsByTagName(String name)
{
- return new NodeListImpl(DOMUtils.getChildElements(this, name));
+ return new NodeListImpl(DOMUtils.getChildElements(this, name, true));
}
public String getAttributeNS(String namespaceURI, String localName)
@@ -766,7 +766,7 @@
public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
{
- return new NodeListImpl(DOMUtils.getChildElements(this, new QName(namespaceURI, localName)));
+ return new NodeListImpl(DOMUtils.getChildElements(this, new QName(namespaceURI, localName), true));
}
public TypeInfo getSchemaTypeInfo()
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2009-06-19 12:02:46 UTC (rev 10204)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2009-06-19 13:17:56 UTC (rev 10205)
@@ -22,8 +22,12 @@
package org.jboss.test.ws.common.soap;
import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
import java.util.Iterator;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
@@ -33,6 +37,9 @@
import javax.xml.soap.SOAPMessage;
import org.jboss.wsf.test.JBossWSTest;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* Test the SOAPElement
@@ -89,6 +96,33 @@
SOAPElement se2 = (SOAPElement)body.getChildElements().next();
assertEquals(se, se2);
}
+
+ //JBWS-2346
+ public void testGetElementByTagNameNS() throws Exception
+ {
+ InputStream is = new File("resources/common/soap/jbws2346.xml").toURL().openStream();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(is);
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage msg = factory.createMessage();
+ msg.getSOAPBody().addDocument(doc);
+ SOAPBody body = msg.getSOAPBody();
+ NodeList list = body.getElementsByTagNameNS("http://org.jboss.ws/testNS", "elementA");
+ assertEquals(1, list.getLength());
+ list = body.getElementsByTagNameNS("http://org.jboss.ws/testNS", "elementC");
+ assertEquals(2, list.getLength());
+ list = body.getElementsByTagNameNS("http://org.jboss.ws/testNS", "String_1");
+ StringBuilder sb = new StringBuilder();
+ for (int i=0; i<list.getLength(); i++)
+ {
+ Node n = list.item(i);
+ sb.append(n.getFirstChild().getNodeValue());
+ sb.append(" ");
+ }
+ assertEquals("Strawberry Apple Banana Orange Raspberry ", sb.toString());
+ }
// http://jira.jboss.com/jira/browse/JBWS-773
public void testGetNamespaceURI() throws Exception
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbws2346.xml (from rev 8575, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/soap/jbws2346.xml)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbws2346.xml (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbws2346.xml 2009-06-19 13:17:56 UTC (rev 10205)
@@ -0,0 +1,15 @@
+<ns1:elementA xmlns:ns1='http://org.jboss.ws/testNS'>
+ <ns1:String_1>Strawberry</ns1:String_1>
+ <ns1:elementB xmlns:ns1='http://org.jboss.ws/testNS'>
+ <ns1:String_1>Apple</ns1:String_1>
+ <ns1:elementC xmlns:ns1='http://org.jboss.ws/testNS'>
+ <ns1:String_1>Banana</ns1:String_1>
+ </ns1:elementC>
+ </ns1:elementB>
+ <ns1:elementC xmlns:ns1='http://org.jboss.ws/testNS'>
+ <ns1:String_1>Orange</ns1:String_1>
+ </ns1:elementC>
+ <ns2:elementA xmlns:ns1='http://org.jboss.ws/testNS' xmlns:ns2='http://org.jboss.ws/testNS2'>
+ <ns1:String_1>Raspberry</ns1:String_1>
+ </ns2:elementA>
+</ns1:elementA>
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/version.properties
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/version.properties 2009-06-19 12:02:46 UTC (rev 10204)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/version.properties 2009-06-19 13:17:56 UTC (rev 10205)
@@ -25,9 +25,9 @@
wscommons-policy=1.0
# Dependend integration projects
-jbossws-spi=1.0.0.GA_CP-SNAPSHOT
+jbossws-spi=1.0.0.GA_CP02-brew
jbossws-common=1.0.0.GA_CP-SNAPSHOT
-jbossws-framework=2.0.1.GA_CP-SNAPSHOT
+jbossws-framework=2.0.1.GA_CP04-brew
jbossws-jboss40=2.0.1.GA
jbossws-jboss42=2.0.1.GA_CP01
14 years, 10 months
JBossWS SVN: r10204 - common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-06-19 08:02:46 -0400 (Fri, 19 Jun 2009)
New Revision: 10204
Modified:
common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java
Log:
[JBPAPP-2108] Issue with SAAJ API: SOAPBody.getElementsByTagNameNS() is non-recursive.
Modified: common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java 2009-06-18 16:03:39 UTC (rev 10203)
+++ common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java 2009-06-19 12:02:46 UTC (rev 10204)
@@ -31,6 +31,8 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import javax.xml.XMLConstants;
@@ -64,6 +66,7 @@
* DOM2 utilites
*
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
*/
public final class DOMUtils
{
@@ -493,27 +496,48 @@
*/
public static Element getFirstChildElement(Node node)
{
- return getFirstChildElementIntern(node, null);
+ return getFirstChildElement(node, false);
}
+ /**Gets the first child element
+ */
+ public static Element getFirstChildElement(Node node, boolean recursive)
+ {
+ return getFirstChildElementIntern(node, null, recursive);
+ }
+
/** Gets the first child element for a given local name without namespace
*/
public static Element getFirstChildElement(Node node, String nodeName)
{
- return getFirstChildElementIntern(node, new QName(nodeName));
+ return getFirstChildElement(node, nodeName, false);
}
+ /** Gets the first child element for a given local name without namespace
+ */
+ public static Element getFirstChildElement(Node node, String nodeName, boolean recursive)
+ {
+ return getFirstChildElementIntern(node, new QName(nodeName), recursive);
+ }
+
/** Gets the first child element for a given qname
*/
public static Element getFirstChildElement(Node node, QName nodeName)
{
- return getFirstChildElementIntern(node, nodeName);
+ return getFirstChildElement(node, nodeName, false);
}
-
- private static Element getFirstChildElementIntern(Node node, QName nodeName)
+
+ /** Gets the first child element for a given qname
+ */
+ public static Element getFirstChildElement(Node node, QName nodeName, boolean recursive)
{
+ return getFirstChildElementIntern(node, nodeName, recursive);
+ }
+
+ private static Element getFirstChildElementIntern(Node node, QName nodeName, boolean recursive)
+ {
Element childElement = null;
- Iterator it = getChildElementsIntern(node, nodeName);
+ Iterator it = getChildElementsIntern(node, nodeName, recursive);
if (it.hasNext())
{
childElement = (Element)it.next();
@@ -525,16 +549,30 @@
*/
public static Iterator getChildElements(Node node, String nodeName)
{
- return getChildElementsIntern(node, new QName(nodeName));
+ return getChildElements(node, nodeName, false);
}
+ /** Gets the child elements for a given local name without namespace
+ */
+ public static Iterator getChildElements(Node node, String nodeName, boolean recursive)
+ {
+ return getChildElementsIntern(node, new QName(nodeName), recursive);
+ }
+
/** Gets the child element for a given qname
*/
public static Iterator getChildElements(Node node, QName nodeName)
{
- return getChildElementsIntern(node, nodeName);
+ return getChildElements(node, nodeName, false);
}
+ /** Gets the child element for a given qname
+ */
+ public static Iterator getChildElements(Node node, QName nodeName, boolean recursive)
+ {
+ return getChildElementsIntern(node, nodeName, recursive);
+ }
+
private static Iterator getChildElementsIntern(Node node, QName nodeName)
{
ArrayList list = new ArrayList();
@@ -569,6 +607,63 @@
return list.iterator();
}
+ private static Iterator getChildElementsIntern(Node node, QName nodeName, boolean recursive)
+ {
+ return getChildElementsAsListIntern(node, nodeName, recursive).iterator();
+ }
+
+ private static List<Element> getChildElementsAsListIntern(Node node, QName nodeName, boolean recursive)
+ {
+ List<Element> list = new LinkedList<Element>();
+
+ NodeList nlist = node.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++)
+ {
+ Node child = nlist.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ {
+ search(list, (Element)child, nodeName, recursive);
+ }
+ }
+ return list;
+ }
+
+ private static void search(List<Element> list, Element baseElement, QName nodeName, boolean recursive)
+ {
+ if (nodeName == null)
+ {
+ list.add(baseElement);
+ }
+ else
+ {
+ QName qname;
+ if (nodeName.getNamespaceURI().length() > 0)
+ {
+ qname = new QName(baseElement.getNamespaceURI(), baseElement.getLocalName());
+ }
+ else
+ {
+ qname = new QName(baseElement.getLocalName());
+ }
+ if (qname.equals(nodeName))
+ {
+ list.add(baseElement);
+ }
+ }
+ if (recursive)
+ {
+ NodeList nlist = baseElement.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++)
+ {
+ Node child = nlist.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ {
+ search(list, (Element)child, nodeName, recursive);
+ }
+ }
+ }
+ }
+
/** Gets parent element or null if there is none
*/
public static Element getParentElement(Node node)
14 years, 10 months
JBossWS SVN: r10203 - in stack/native/branches/jbossws-native-2.0.1.SP2_CP: src/test/java/org/jboss/test/ws/jaxws and 4 other directories.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-06-18 12:03:39 -0400 (Thu, 18 Jun 2009)
New Revision: 10203
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml
Removed:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/ant-import-tests/build-jars-jaxws.xml
Log:
[JBPAPP-2114] Incorrect Parsing of Badly Formed int - Test Case.
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/ant-import-tests/build-jars-jaxws.xml
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/ant-import-tests/build-jars-jaxws.xml 2009-06-17 17:06:56 UTC (rev 10202)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/ant-import-tests/build-jars-jaxws.xml 2009-06-18 16:03:39 UTC (rev 10203)
@@ -647,6 +647,14 @@
</fileset>
</jar>
+ <!-- jaxws-jbws2682 -->
+ <war warfile="${tests.output.dir}/libs/jaxws-jbws2682.war" webxml="${tests.output.dir}/resources/jaxws/jbws2682/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2682/Endpoint.class"/>
+ <include name="org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.class"/>
+ </classes>
+ </war>
+
<!-- jaxws namespace -->
<war warfile="${tests.output.dir}/libs/jaxws-namespace.war" webxml="${tests.output.dir}/resources/jaxws/namespace/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/classes">
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682 (from rev 10202, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682)
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java 2009-06-17 17:06:56 UTC (rev 10202)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java 2009-06-18 16:03:39 UTC (rev 10203)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.test.ws.jaxws.jbws2682;
-
-import javax.jws.WebService;
-
-/**
- * Test Endpoint.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 16th June 2009
- */
-@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2682")
-public interface Endpoint
-{
-
- public int echo(final int value);
-
-}
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java (from rev 10202, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java 2009-06-18 16:03:39 UTC (rev 10203)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ws.jaxws.jbws2682;
+
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 16th June 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2682")
+public interface Endpoint
+{
+
+ public int echo(final int value);
+
+}
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java 2009-06-17 17:06:56 UTC (rev 10202)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java 2009-06-18 16:03:39 UTC (rev 10203)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.test.ws.jaxws.jbws2682;
-
-import org.jboss.logging.Logger;
-
-import javax.jws.WebService;
-
-/**
- * Test Endpoint implementation.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 16th June 2009
- */
-@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2682", endpointInterface = "org.jboss.test.ws.jaxws.jbws2682.Endpoint")
-public class EndpointImpl implements Endpoint
-{
-
- private static final Logger log = Logger.getLogger(EndpointImpl.class);
-
- public int echo(final int value)
- {
- log.debug("echoing '" + value + "'");
- return value;
- }
-
-}
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java (from rev 10202, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java 2009-06-18 16:03:39 UTC (rev 10203)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ws.jaxws.jbws2682;
+
+import org.jboss.logging.Logger;
+
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 16th June 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2682", endpointInterface = "org.jboss.test.ws.jaxws.jbws2682.Endpoint")
+public class EndpointImpl implements Endpoint
+{
+
+ private static final Logger log = Logger.getLogger(EndpointImpl.class);
+
+ public int echo(final int value)
+ {
+ log.debug("echoing '" + value + "'");
+ return value;
+ }
+
+}
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java 2009-06-17 17:06:56 UTC (rev 10202)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java 2009-06-18 16:03:39 UTC (rev 10203)
@@ -1,120 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.test.ws.jaxws.jbws2682;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPConnection;
-import javax.xml.soap.SOAPConnectionFactory;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFault;
-import javax.xml.soap.SOAPMessage;
-
-import junit.framework.Test;
-
-import org.jboss.wsf.test.JBossWSTest;
-import org.jboss.wsf.test.JBossWSTestSetup;
-
-/**
- * JBWS2682 Test Case
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 16th June 2009
- * @see https://jira.jboss.org/jira/browse/JBWS-2682
- */
-public class JBWS2682TestCase extends JBossWSTest
-{
-
- public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-jbws2682/TestEndpoint";
-
- private String badMsgString =
- "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:jbw='http://ws.jboss.org/jbws2682'>" +
- " <soapenv:Header/>" + " <soapenv:Body>" +
- " <jbw:echo>" +
- " <arg0>1-1</arg0>" +
- " </jbw:echo>" +
- " </soapenv:Body>" +
- "</soapenv:Envelope>";
-
- private String goodMsgString =
- "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:jbw='http://ws.jboss.org/jbws2682'>" +
- " <soapenv:Header/>" +
- " <soapenv:Body>" +
- " <jbw:echo>" +
- " <arg0>646</arg0>" +
- " </jbw:echo>" +
- " </soapenv:Body>" +
- "</soapenv:Envelope>";
-
- public static Test suite() throws Exception
- {
- return new JBossWSTestSetup(JBWS2682TestCase.class, "jaxws-jbws2682.war");
- }
-
- public void testGoodMessage() throws Exception
- {
- SOAPMessage response = sendMessage(this.goodMsgString);
- SOAPEnvelope resEnv = response.getSOAPPart().getEnvelope();
- SOAPBody resBody = resEnv.getBody();
-
- Iterator it = resBody.getChildElements(new QName("http://ws.jboss.org/jbws2682", "echoResponse"));
- SOAPElement echoResponse = (SOAPElement)it.next();
- it = echoResponse.getChildElements(new QName("return"));
- SOAPElement returnElement = (SOAPElement)it.next();
-
- String value = returnElement.getValue();
- assertEquals("Expected return value", "646", returnElement.getValue());
- }
-
- public void testBadMessage() throws Exception
- {
- if (true)
- {
- System.out.println("FIXME [JBWS-2682] Incorrect Parsing of Badly Formed int.");
- return;
- }
-
- SOAPMessage response = sendMessage(this.badMsgString);
- SOAPEnvelope resEnv = response.getSOAPPart().getEnvelope();
- SOAPFault fault = resEnv.getBody().getFault();
- assertNotNull("Expected fault to be raised", fault);
- }
-
- private SOAPMessage sendMessage(final String message) throws SOAPException, IOException
- {
- MessageFactory msgFactory = MessageFactory.newInstance();
- SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(message.getBytes()));
-
- SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
- SOAPMessage resMsg = con.call(reqMsg, TARGET_ENDPOINT_ADDRESS);
-
- return resMsg;
- }
-
-}
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java (from rev 10202, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java 2009-06-18 16:03:39 UTC (rev 10203)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ws.jaxws.jbws2682;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * JBWS2682 Test Case
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 16th June 2009
+ * @see https://jira.jboss.org/jira/browse/JBWS-2682
+ */
+public class JBWS2682TestCase extends JBossWSTest
+{
+
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-jbws2682/TestEndpoint";
+
+ private String badMsgString =
+ "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:jbw='http://ws.jboss.org/jbws2682'>" +
+ " <soapenv:Header/>" + " <soapenv:Body>" +
+ " <jbw:echo>" +
+ " <arg0>1-1</arg0>" +
+ " </jbw:echo>" +
+ " </soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ private String goodMsgString =
+ "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:jbw='http://ws.jboss.org/jbws2682'>" +
+ " <soapenv:Header/>" +
+ " <soapenv:Body>" +
+ " <jbw:echo>" +
+ " <arg0>646</arg0>" +
+ " </jbw:echo>" +
+ " </soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static Test suite() throws Exception
+ {
+ return new JBossWSTestSetup(JBWS2682TestCase.class, "jaxws-jbws2682.war");
+ }
+
+ public void testGoodMessage() throws Exception
+ {
+ SOAPMessage response = sendMessage(this.goodMsgString);
+ SOAPEnvelope resEnv = response.getSOAPPart().getEnvelope();
+ SOAPBody resBody = resEnv.getBody();
+
+ Iterator it = resBody.getChildElements(new QName("http://ws.jboss.org/jbws2682", "echoResponse"));
+ SOAPElement echoResponse = (SOAPElement)it.next();
+ it = echoResponse.getChildElements(new QName("return"));
+ SOAPElement returnElement = (SOAPElement)it.next();
+
+ String value = returnElement.getValue();
+ assertEquals("Expected return value", "646", returnElement.getValue());
+ }
+
+ public void testBadMessage() throws Exception
+ {
+ if (true)
+ {
+ System.out.println("FIXME [JBWS-2682] Incorrect Parsing of Badly Formed int.");
+ return;
+ }
+
+ SOAPMessage response = sendMessage(this.badMsgString);
+ SOAPEnvelope resEnv = response.getSOAPPart().getEnvelope();
+ SOAPFault fault = resEnv.getBody().getFault();
+ assertNotNull("Expected fault to be raised", fault);
+ }
+
+ private SOAPMessage sendMessage(final String message) throws SOAPException, IOException
+ {
+ MessageFactory msgFactory = MessageFactory.newInstance();
+ SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(message.getBytes()));
+
+ SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
+ SOAPMessage resMsg = con.call(reqMsg, TARGET_ENDPOINT_ADDRESS);
+
+ return resMsg;
+ }
+
+}
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682 (from rev 10202, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682)
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF (from rev 10202, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF)
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml 2009-06-17 17:06:56 UTC (rev 10202)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml 2009-06-18 16:03:39 UTC (rev 10203)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
- version="2.4">
-
- <servlet>
- <servlet-name>TestEndpoint</servlet-name>
- <servlet-class>org.jboss.test.ws.jaxws.jbws2682.EndpointImpl</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>TestEndpoint</servlet-name>
- <url-pattern>/TestEndpoint</url-pattern>
- </servlet-mapping>
-
-</web-app>
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml (from rev 10202, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml 2009-06-18 16:03:39 UTC (rev 10203)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>TestEndpoint</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.jbws2682.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestEndpoint</servlet-name>
+ <url-pattern>/TestEndpoint</url-pattern>
+ </servlet-mapping>
+
+</web-app>
14 years, 10 months
JBossWS SVN: r10202 - stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-06-17 13:06:56 -0400 (Wed, 17 Jun 2009)
New Revision: 10202
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
Log:
[JBWS-2682] Incorrect Parsing of Badly Formed int - Test Case.
Modified: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java 2009-06-17 17:03:51 UTC (rev 10201)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java 2009-06-17 17:06:56 UTC (rev 10202)
@@ -26,7 +26,6 @@
import java.util.Iterator;
import javax.xml.namespace.QName;
-import javax.xml.soap.Detail;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
14 years, 10 months
JBossWS SVN: r10201 - in stack/native/trunk/modules/testsuite/native-tests: src/test/java/org/jboss/test/ws/jaxws and 4 other directories.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-06-17 13:03:51 -0400 (Wed, 17 Jun 2009)
New Revision: 10201
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF/
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml
Modified:
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
Log:
[JBWS-2682] Incorrect Parsing of Badly Formed int - Test Case.
Modified: stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2009-06-17 06:20:01 UTC (rev 10200)
+++ stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2009-06-17 17:03:51 UTC (rev 10201)
@@ -552,6 +552,14 @@
</metainf>
</jar>
+ <!-- jaxws-jbws2682 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws2682.war" webxml="${tests.output.dir}/test-resources/jaxws/jbws2682/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2682/Endpoint.class"/>
+ <include name="org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.class"/>
+ </classes>
+ </war>
+
<!-- jaxws-webserviceref -->
<war warfile="${tests.output.dir}/test-libs/jaxws-webserviceref.war" webxml="${tests.output.dir}/test-resources/jaxws/webserviceref/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java 2009-06-17 17:03:51 UTC (rev 10201)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ws.jaxws.jbws2682;
+
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 16th June 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2682")
+public interface Endpoint
+{
+
+ public int echo(final int value);
+
+}
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/Endpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java 2009-06-17 17:03:51 UTC (rev 10201)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ws.jaxws.jbws2682;
+
+import org.jboss.logging.Logger;
+
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 16th June 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2682", endpointInterface = "org.jboss.test.ws.jaxws.jbws2682.Endpoint")
+public class EndpointImpl implements Endpoint
+{
+
+ private static final Logger log = Logger.getLogger(EndpointImpl.class);
+
+ public int echo(final int value)
+ {
+ log.debug("echoing '" + value + "'");
+ return value;
+ }
+
+}
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java 2009-06-17 17:03:51 UTC (rev 10201)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ws.jaxws.jbws2682;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.Detail;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * JBWS2682 Test Case
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 16th June 2009
+ * @see https://jira.jboss.org/jira/browse/JBWS-2682
+ */
+public class JBWS2682TestCase extends JBossWSTest
+{
+
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-jbws2682/TestEndpoint";
+
+ private String badMsgString =
+ "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:jbw='http://ws.jboss.org/jbws2682'>" +
+ " <soapenv:Header/>" + " <soapenv:Body>" +
+ " <jbw:echo>" +
+ " <arg0>1-1</arg0>" +
+ " </jbw:echo>" +
+ " </soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ private String goodMsgString =
+ "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:jbw='http://ws.jboss.org/jbws2682'>" +
+ " <soapenv:Header/>" +
+ " <soapenv:Body>" +
+ " <jbw:echo>" +
+ " <arg0>646</arg0>" +
+ " </jbw:echo>" +
+ " </soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static Test suite() throws Exception
+ {
+ return new JBossWSTestSetup(JBWS2682TestCase.class, "jaxws-jbws2682.war");
+ }
+
+ public void testGoodMessage() throws Exception
+ {
+ SOAPMessage response = sendMessage(this.goodMsgString);
+ SOAPEnvelope resEnv = response.getSOAPPart().getEnvelope();
+ SOAPBody resBody = resEnv.getBody();
+
+ Iterator it = resBody.getChildElements(new QName("http://ws.jboss.org/jbws2682", "echoResponse"));
+ SOAPElement echoResponse = (SOAPElement)it.next();
+ it = echoResponse.getChildElements(new QName("return"));
+ SOAPElement returnElement = (SOAPElement)it.next();
+
+ String value = returnElement.getValue();
+ assertEquals("Expected return value", "646", returnElement.getValue());
+ }
+
+ public void testBadMessage() throws Exception
+ {
+ if (true)
+ {
+ System.out.println("FIXME [JBWS-2682] Incorrect Parsing of Badly Formed int.");
+ return;
+ }
+
+ SOAPMessage response = sendMessage(this.badMsgString);
+ SOAPEnvelope resEnv = response.getSOAPPart().getEnvelope();
+ SOAPFault fault = resEnv.getBody().getFault();
+ assertNotNull("Expected fault to be raised", fault);
+ }
+
+ private SOAPMessage sendMessage(final String message) throws SOAPException, IOException
+ {
+ MessageFactory msgFactory = MessageFactory.newInstance();
+ SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(message.getBytes()));
+
+ SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
+ SOAPMessage resMsg = con.call(reqMsg, TARGET_ENDPOINT_ADDRESS);
+
+ return resMsg;
+ }
+
+}
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2682/JBWS2682TestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml 2009-06-17 17:03:51 UTC (rev 10201)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>TestEndpoint</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.jbws2682.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestEndpoint</servlet-name>
+ <url-pattern>/TestEndpoint</url-pattern>
+ </servlet-mapping>
+
+</web-app>
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2682/WEB-INF/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
14 years, 10 months