-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30837 from BerksanAtes/SpecialCharacters
JAX-WS: IllegalArgumentException fix when special characters are used for namespace with combination of monitor-1.0 feature
- Loading branch information
Showing
19 changed files
with
865 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...ment.3.2/src/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
dev/io.openliberty.jaxws_fat/fat/src/com/ibm/ws/jaxws22/fat/SpecialCharactersTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...y.jaxws_fat/publish/servers/com.ibm.ws.jaxws22.specialcharacters_fat/bootstrap.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bootstrap.include=../testports.properties |
30 changes: 30 additions & 0 deletions
30
...openliberty.jaxws_fat/publish/servers/com.ibm.ws.jaxws22.specialcharacters_fat/server.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
54 changes: 54 additions & 0 deletions
54
...pplications/specialcharacters/resources/WEB-INF/wsdl/WebServiceWithSpecialCharacters.wsdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.