Skip to content

Commit

Permalink
Merge pull request #30837 from BerksanAtes/SpecialCharacters
Browse files Browse the repository at this point in the history
JAX-WS: IllegalArgumentException fix when special characters are used for namespace with combination of monitor-1.0 feature
  • Loading branch information
BerksanAtes authored Feb 26, 2025
2 parents 9d2777e + 7319f27 commit e0e747b
Show file tree
Hide file tree
Showing 19 changed files with 865 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
Expand Down
6 changes: 4 additions & 2 deletions dev/com.ibm.ws.org.apache.cxf.cxf.rt.management.3.2/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Export-Package: \

-includeresource: \
@${repo;org.apache.cxf:cxf-rt-management;${cxfVersion};EXACT}!/!*-INF/*, \
META-INF/cxf=resources/META-INF/cxf
META-INF/cxf=resources/META-INF/cxf, \
org/apache/cxf=${bin}/org/apache/cxf

-buildpath: \
org.apache.cxf:cxf-rt-management;strategy=exact;version=${cxfVersion}, \
Expand All @@ -58,4 +59,5 @@ Export-Package: \
com.ibm.ws.org.osgi.annotation.versioning;version=latest, \
com.ibm.websphere.javaee.wsdl4j.1.2;version=latest, \
javax.activation:activation;version=1.1, \
com.ibm.ws.logging.core
com.ibm.ws.logging.core, \
org.apache.cxf:cxf-core;strategy=exact;version=${cxfVersion}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cxf.management.interceptor;

import java.util.logging.Logger;

import javax.xml.namespace.QName;

import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.MessageSenderInterceptor;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.FaultMode;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;

public class ResponseTimeMessageOutInterceptor extends AbstractMessageResponseTimeInterceptor {
private EndingInterceptor ending = new EndingInterceptor();

Logger log = Logger.getLogger(ResponseTimeMessageOutInterceptor.class.getName());

public ResponseTimeMessageOutInterceptor() {
super(Phase.PREPARE_SEND_ENDING);
addBefore(MessageSenderInterceptor.MessageSenderEndingInterceptor.class.getName());
}

public void handleMessage(Message message) throws Fault {
Exchange ex = message.getExchange();
// Liberty change begin
boolean forceDisabled = getForceDisabled(ex);
if (!forceDisabled && isServiceCounterEnabled(ex)) {
// Liberty change end
if (ex.get(Exception.class) != null) {
endHandlingMessage(ex);
return;
}
if (Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))) {
return;
}
if (isClient(message)) {
if (ex.isOneWay()) {
message.getInterceptorChain().add(ending);
}
beginHandlingMessage(ex);
} else { // the message is handled by server
endHandlingMessage(ex);
}
}
}

// Liberty change begin
/*
* Disable counter either org.apache.cxf.management.counter.enabled property is set
* or interface name contains special character causing IllegalArgumentException
* according to JMX specification. Code logic below prevents FFDC creation by disabling
* counter for name spaces with special characters
*/
private boolean getForceDisabled(Exchange ex) {
boolean forceDisabled = Boolean.FALSE.equals(ex.get("org.apache.cxf.management.counter.enabled"));

Object object = ex.get("javax.xml.ws.wsdl.interface");
if(object != null && object instanceof QName) {
String namespaceURI = ((QName) object).getNamespaceURI();
if (!namespaceURI.matches("[a-zA-Z0-9./:?_]*$")) {
forceDisabled = true;
}
}
return forceDisabled;
}
// Liberty change end

@Override
public void handleFault(Message message) {
Exchange ex = message.getExchange();
if (ex.get("org.apache.cxf.management.counter.enabled") != null) {
if (ex.isOneWay()) {
// do nothing, done by the ResponseTimeInvokerInterceptor
} else {
FaultMode faultMode = message.get(FaultMode.class);
if (faultMode == null) {
// client side exceptions don't have FaultMode set un the message properties (as of 2.1.4)
faultMode = FaultMode.RUNTIME_FAULT;
}
ex.put(FaultMode.class, faultMode);
endHandlingMessage(ex);
}
}
}

EndingInterceptor getEndingInterceptor() {
return ending;
}

public class EndingInterceptor extends AbstractPhaseInterceptor<Message> {
public EndingInterceptor() {
super(Phase.PREPARE_SEND_ENDING);
}

public void handleMessage(Message message) throws Fault {
Exchange ex = message.getExchange();
endHandlingMessage(ex);
}

public void handleFault(Message message) throws Fault {
Exchange ex = message.getExchange();
endHandlingMessage(ex);
}
}
}
2 changes: 2 additions & 0 deletions dev/io.openliberty.jaxws_fat/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="fat/src"/>
<classpathentry kind="src" path="test-applications/specialcharacters/src"/>
<classpathentry kind="src" path="test-applications/saajclient/src"/>
<classpathentry kind="src" path="test-applications/BT11AddNumbersImplService/src"/>
<classpathentry kind="src" path="test-applications/cxfclient/src"/>
Expand All @@ -9,5 +10,6 @@
<classpathentry kind="src" path="test-applications/jaxws22mtom/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
7 changes: 2 additions & 5 deletions dev/io.openliberty.jaxws_fat/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ src: \
test-applications/BT11AddNumbersImplService/src,\
test-applications/jaxws22mtom/src,\
test-applications/defaultpackage/src,\
test-applications/saajclient/src


# test-applications/cxfclient/src,\
#
test-applications/saajclient/src,\
test-applications/specialcharacters/src

fat.project: true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 IBM Corporation and others.
* Copyright (c) 2024,2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -30,7 +30,8 @@
BindingTypeDefaultsTest.class,
DefaultPackageTest.class,
MtomAnnotationsTest.class,
SAAJBasicTest.class
SAAJBasicTest.class,
SpecialCharactersTest.class
})

public class FATSuite {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*******************************************************************************/
package com.ibm.ws.jaxws22.fat;

import static org.junit.Assert.assertNotNull;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;

import com.ibm.websphere.simplicity.ShrinkHelper;
import com.ibm.ws.jaxws.special.characters.servlet.SpecialCharacterTestServlet;

import componenttest.annotation.Server;
import componenttest.annotation.TestServlet;
import componenttest.custom.junit.runner.FATRunner;
import componenttest.custom.junit.runner.Mode;
import componenttest.custom.junit.runner.Mode.TestMode;
import componenttest.topology.impl.LibertyServer;
import componenttest.topology.utils.FATServletClient;


//fats.cxf.jaxws22.saaj.client

/**
* A basic test for SAAJ implementation in Liberty
*/
@RunWith(FATRunner.class)
@Mode(TestMode.FULL)
public class SpecialCharactersTest extends FATServletClient {

private static final String APP_NAME = "specialcharacters";

@Server("com.ibm.ws.jaxws22.specialcharacters_fat")
@TestServlet(servlet = SpecialCharacterTestServlet.class, contextRoot = APP_NAME)
public static LibertyServer server;

@BeforeClass
public static void setUp() throws Exception {

WebArchive app = ShrinkHelper.buildDefaultApp(APP_NAME, "com.ibm.ws.jaxws.special.characters.____.__or", "com.ibm.ws.jaxws.special.characters.____$__or",
"com.ibm.ws.jaxws.special.characters.servlet");

ShrinkHelper.exportDropinAppToServer(server, app);

server.startServer();
System.out.println("Starting Server");

assertNotNull("Application " + APP_NAME + " does not appear to have started.", server.waitForStringInLog("CWWKZ0001I:.*" + APP_NAME));

return;
}

@AfterClass
public static void tearDown() throws Exception {
if (server != null && server.isStarted()) {
server.stopServer();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bootstrap.include=../testports.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<server>
<featureManager>
<feature>servlet-3.1</feature>
<feature>jsp-2.2</feature>
<feature>jaxws-2.2</feature>
<feature>componenttest-1.0</feature>
<feature>monitor-1.0</feature> <!-- this feature was causing JMX IllegalArgumentException -->
</featureManager>

<include location="../fatTestPorts.xml" />
<javaPermission className="java.io.FilePermission" name="ALL FILES" actions="read"/>
<javaPermission className="java.lang.reflect.ReflectPermission" name="suppressAccessChecks"/>
<javaPermission className="java.lang.RuntimePermission" name="accessClassInPackage.com.sun.org.apache.xerces.internal.dom" />
<javaPermission className="java.lang.RuntimePermission" name="accessDeclaredMembers"/>
<javaPermission className="java.lang.RuntimePermission" name="createClassLoader"/>
<javaPermission className="java.lang.RuntimePermission" name="getClassLoader"/>
<javaPermission className="java.lang.RuntimePermission" name="setContextClassLoader" />
<javaPermission className="java.lang.RuntimePermission" name="setFactory"/>
<javaPermission className="java.lang.RuntimePermission" name="org.apache.cxf.permission"/>
<javaPermission className="java.net.NetPermission" name="setDefaultAuthenticator" />
<javaPermission className="java.net.SocketPermission" name="*" actions="connect,resolve"/>
<javaPermission className="java.net.URLPermission" name="http://localhost:8010/jaxws22mtom/MTOMAnnotationOnly" actions="GET:"/>
<javaPermission className="java.security.SecurityPermission" name="getPolicy"/>
<javaPermission className="java.security.SecurityPermission" name="getPolicy"/>
<javaPermission className="java.util.PropertyPermission" name="*" actions="read"/>
<javaPermission className="org.osgi.framework.ServicePermission" name="*" actions="get" />
<javaPermission className="org.osgi.framework.AdminPermission" name="*" actions="*" />
<javaPermission className="javax.security.auth.AuthPermission" name="*" actions="getSubject" />
</server>

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://characters.special.jaxws.ws.ibm.com/:.!?$()or.=*#," xmlns:intf="http://characters.special.jaxws.ws.ibm.com/:.!?$()or.=*#," xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://characters.special.jaxws.ws.ibm.com/:.!?$()or.=*#,">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://characters.special.jaxws.ws.ibm.com/:.!?$()or.=*#,">
<element name="SC">
<complexType>
<sequence>
<element name="input1" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="SCResponse">
<complexType>
<sequence>
<element name="output1" type="xsd:string"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="SCResponse">
<wsdl:part element="impl:SCResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="SCRequest">
<wsdl:part element="impl:SC" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="WebServiceWithSpecialCharactersPortType">
<wsdl:operation name="SC">
<wsdl:input message="impl:SCRequest" name="SCRequest">
</wsdl:input>
<wsdl:output message="impl:SCResponse" name="SCResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="soap12WebServiceWithSpecialCharactersSoapSoapBinding" type="impl:WebServiceWithSpecialCharactersPortType">
<wsdlsoap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SC">
<wsdlsoap12:operation soapAction="http://characters.special.jaxws.ws.ibm.com/:.!?$()or.=*#,/SC"/>
<wsdl:input name="SCRequest">
<wsdlsoap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="SCResponse">
<wsdlsoap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WebServiceWithSpecialCharacters">
<wsdl:port binding="impl:soap12WebServiceWithSpecialCharactersSoapSoapBinding" name="soap12WebServiceWithSpecialCharactersSoap">
<wsdlsoap12:address location="http://localhost:9080/L3SpecChars/WebServiceWithSpecialCharacters"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Loading

0 comments on commit e0e747b

Please sign in to comment.