[ 
https://issues.apache.org/jira/browse/WSS-702?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Cedric Tabin updated WSS-702:
-----------------------------
    Description: 
Hello,

We are using wss4j with the Apache CXF library to connect to a SOAP web 
service. The latter has some security-enabled methods which involves signature 
and encryption.

When writing the unit tests related to this, we hit a strange problem: if the 
signature is enabled (through `WSS4JOutInterceptor`), then the process hangs 
during marshalling without any exception regardless of any timeout set in the 
connection (although a "Connection refused" exception should have been thrown 
right away since we are pointing to localhost:1234).

Here is the code snipped involved:
{code:java}
final ClientImpl client = (ClientImpl) ClientProxy.getClient(port);

//url points to localhost:1234 on which nothing is listening => connection 
should be refused immediately
client.getRequestContext().put(Message.ENDPOINT_ADDRESS, url);
client.setThreadLocalRequestContext(true);
client.setSynchronousTimeout(10000);

final HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setReceiveTimeout(1200000);
httpClientPolicy.setAllowChunking(true);
httpClientPolicy.setMaxRetransmits(0);
httpConduit.setClient(httpClientPolicy);

TLSClientParameters tlsClientParameters = new TLSClientParameters();
tlsClientParameters.setSecureSocketProtocol("TLSv1.3");
tlsClientParameters.setDisableCNCheck(true);
httpConduit.setTlsClientParameters(tlsClientParameters);

{    
    WSEncryptionPart sigTimestamp = new WSEncryptionPart("Timestamp", 
WSConstants.WSU_NS, "");   
    WSEncryptionPart sigBody = new WSEncryptionPart("Body", 
WSConstants.URI_SOAP11_ENV, "");       
    SignatureActionToken erpSignature = new SignatureActionToken();
    erpSignature.setUser(getSignatureUser());      
    erpSignature.setCryptoProperties(getOutSecurityPropFile());    
    erpSignature.setKeyIdentifierId(WSConstants.BST_DIRECT_REFERENCE);   
    erpSignature.setSignatureAlgorithm(WSConstants.RSA_SHA256);   
    erpSignature.setDigestAlgorithm(WSConstants.SHA256);    
    erpSignature.setParts(Arrays.asList(sigTimestamp, sigBody));

    List<HandlerAction> actions = new ArrayList<>();    
    actions.add(new HandlerAction(WSConstants.TS, null));    
    actions.add(new HandlerAction(WSConstants.SIGN, erpSignature));    

    Map<String, Object> properties = getOutSecurityProperties();
    properties.put(WSHandlerConstants.HANDLER_ACTIONS, actions);    
    ExtensibleWSS4JOutInterceptor wss4JOutInterceptor = new 
ExtensibleWSS4JOutInterceptor(properties, getAfterSignatureCallbacks());    
    wss4JOutInterceptor.setId("WSS4JOutSignatureInterceptor");         

    //if this line is commented => the process fails directly (which is 
correct) because nothing is listening at the endpoint    
   client.getOutInterceptors().add(wss4JOutInterceptor);
}

String operation = jaxbElement.getName().getLocalPart();
Object[] object = client.invoke(operation, jaxbElement.getValue());
return object[0];
{code}

If the `wss4JOutInterceptor` is not added, the the process immediately fails 
(which is expected).

{noformat}
org.apache.cxf.interceptor.Fault: Could not send Message.
at 
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:67)
at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:332)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:318)
 Caused by: java.net.ConnectException: ConnectException invoking 
[https://localhost:1234/Invalid:] Connection refused
at 
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
 Method)
at 
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at 
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at 
java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
Caused by: java.net.ConnectException
at 
java.net.http/jdk.internal.net.http.common.Utils.toConnectException(Utils.java:1055)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:198)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.checkRetryConnect(PlainHttpConnection.java:230)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.lambda$connectAsync$1(PlainHttpConnection.java:206)
at 
java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
at 
java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
at 
java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at 
java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.nio.channels.ClosedChannelException
at java.base/sun.nio.ch.SocketChannelImpl.ensureOpen(SocketChannelImpl.java:195)
at 
java.base/sun.nio.ch.SocketChannelImpl.beginConnect(SocketChannelImpl.java:760)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:848)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.lambda$connectAsync$0(PlainHttpConnection.java:183)
at 
java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:185)
{noformat}

If any help, here is the stacktrace where the process hangs forever:

{noformat}
 at java.lang.Object.wait(Object.java)
 at java.io.PipedInputStream.awaitSpace(PipedInputStream.java:273)
 at java.io.PipedInputStream.receive(PipedInputStream.java:231)
 at java.io.PipedOutputStream.write(PipedOutputStream.java:150)
 at 
org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:51)
 at 
org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.write(UTF8XmlOutput.java:386)
 at org.glassfish.jaxb.runtime.v2.runtime.output.Encoded.write(Encoded.java:137)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.writePrefix(UTF8XmlOutput.java:205)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.writeName(UTF8XmlOutput.java:209)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.beginStartTag(UTF8XmlOutput.java:138)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.ForkXmlOutput.beginStartTag(ForkXmlOutput.java:48)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:288)
 at 
org.glassfish.jaxb.runtime.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1115)
 at 
org.glassfish.jaxb.runtime.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1092)
 at 
org.glassfish.jaxb.runtime.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:224)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:94)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:38)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:132)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:122)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:125)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:93)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:316)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:324)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:38)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:456)
 at 
org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:265)
 at 
org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:197)
 at 
jakarta.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:86)
 at 
org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:642)
 at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:244)
 at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:238)
 at 
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:118)
 at 
org.apache.cxf.wsdl.interceptors.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
 at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
 at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:332)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:318)
{noformat}

Any workaround is welcome.

Thanks & best regards.

 

  was:
Hello,

We are using wss4j with the Apache CXF library to connect to a SOAP web 
service. The latter has some security-enabled methods which involves signature 
and encryption.

When writing the unit tests related to this, we hit a strange problem: if the 
signature is enabled (through `WSS4JOutInterceptor`), then the process hangs 
during marshalling without any exception regardless of any timeout set in the 
connection (although a "Connection refused" exception should have been thrown 
right away since we are pointing to localhost:1234).

Here is the code snipped involved:


{code:java}
final ClientImpl client = (ClientImpl) ClientProxy.getClient(port);

//url points to localhost:1234 on which nothing is listening => connection 
should be refused immediately
client.getRequestContext().put(Message.ENDPOINT_ADDRESS, url);
client.setThreadLocalRequestContext(true);
client.setSynchronousTimeout(10000);

final HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setReceiveTimeout(1200000);
httpClientPolicy.setAllowChunking(true);
httpClientPolicy.setMaxRetransmits(0);
httpConduit.setClient(httpClientPolicy);

TLSClientParameters tlsClientParameters = new TLSClientParameters();
tlsClientParameters.setSecureSocketProtocol("TLSv1.3");
tlsClientParameters.setDisableCNCheck(true);
httpConduit.setTlsClientParameters(tlsClientParameters);

{    
    WSEncryptionPart sigTimestamp = new WSEncryptionPart("Timestamp", 
WSConstants.WSU_NS, "");   
    WSEncryptionPart sigBody = new WSEncryptionPart("Body", 
WSConstants.URI_SOAP11_ENV, "");       
    SignatureActionToken erpSignature = new SignatureActionToken();
    erpSignature.setUser(getSignatureUser());      
    erpSignature.setCryptoProperties(getOutSecurityPropFile());    
    erpSignature.setKeyIdentifierId(WSConstants.BST_DIRECT_REFERENCE);   
    erpSignature.setSignatureAlgorithm(WSConstants.RSA_SHA256);   
    erpSignature.setDigestAlgorithm(WSConstants.SHA256);    
    erpSignature.setParts(Arrays.asList(sigTimestamp, sigBody));

    List<HandlerAction> actions = new ArrayList<>();    
    actions.add(new HandlerAction(WSConstants.TS, null));    
    actions.add(new HandlerAction(WSConstants.SIGN, erpSignature));    

    Map<String, Object> properties = getOutSecurityProperties();
    properties.put(WSHandlerConstants.HANDLER_ACTIONS, actions);    
    ExtensibleWSS4JOutInterceptor wss4JOutInterceptor = new 
ExtensibleWSS4JOutInterceptor(properties, getAfterSignatureCallbacks());    
    wss4JOutInterceptor.setId("WSS4JOutSignatureInterceptor");         

    //if this line is commented => the process fails directly (which is 
correct) because nothing is listening at the endpoint    
   client.getOutInterceptors().add(wss4JOutInterceptor);
}

String operation = jaxbElement.getName().getLocalPart();
Object[] object = client.invoke(operation, jaxbElement.getValue());
return object[0];
{code}







If the `wss4JOutInterceptor` is not added, the the process immediately fails 
(which is expected).

```
org.apache.cxf.interceptor.Fault: Could not send Message.
at 
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:67)
at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:332)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:318)
 Caused by: java.net.ConnectException: ConnectException invoking 
[https://localhost:1234/Invalid:] Connection refused
at 
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
 Method)
at 
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at 
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at 
java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
Caused by: java.net.ConnectException
at 
java.net.http/jdk.internal.net.http.common.Utils.toConnectException(Utils.java:1055)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:198)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.checkRetryConnect(PlainHttpConnection.java:230)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.lambda$connectAsync$1(PlainHttpConnection.java:206)
at 
java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
at 
java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
at 
java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at 
java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.nio.channels.ClosedChannelException
at java.base/sun.nio.ch.SocketChannelImpl.ensureOpen(SocketChannelImpl.java:195)
at 
java.base/sun.nio.ch.SocketChannelImpl.beginConnect(SocketChannelImpl.java:760)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:848)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.lambda$connectAsync$0(PlainHttpConnection.java:183)
at 
java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at 
java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:185)
```
 

If any help, here is the stacktrace where the process hangs forever:

```

 at java.lang.Object.wait(Object.java)
 at java.io.PipedInputStream.awaitSpace(PipedInputStream.java:273)
 at java.io.PipedInputStream.receive(PipedInputStream.java:231)
 at java.io.PipedOutputStream.write(PipedOutputStream.java:150)
 at 
org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:51)
 at 
org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.write(UTF8XmlOutput.java:386)
 at org.glassfish.jaxb.runtime.v2.runtime.output.Encoded.write(Encoded.java:137)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.writePrefix(UTF8XmlOutput.java:205)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.writeName(UTF8XmlOutput.java:209)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.beginStartTag(UTF8XmlOutput.java:138)
 at 
org.glassfish.jaxb.runtime.v2.runtime.output.ForkXmlOutput.beginStartTag(ForkXmlOutput.java:48)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:288)
 at 
org.glassfish.jaxb.runtime.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1115)
 at 
org.glassfish.jaxb.runtime.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1092)
 at 
org.glassfish.jaxb.runtime.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:224)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:94)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:38)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:132)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:122)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
 at 
org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:125)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:93)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:316)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:324)
 at 
org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:38)
 at 
org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:456)
 at 
org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:265)
 at 
org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:197)
 at 
jakarta.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:86)
 at 
org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:642)
 at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:244)
 at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:238)
 at 
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:118)
 at 
org.apache.cxf.wsdl.interceptors.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
 at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
 at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:332)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:318)

```

Any workaround is welcome.

Thanks & best regards.

 


> Process hangs when a signature is added and server not reachable
> ----------------------------------------------------------------
>
>                 Key: WSS-702
>                 URL: https://issues.apache.org/jira/browse/WSS-702
>             Project: WSS4J
>          Issue Type: Bug
>    Affects Versions: 3.0.1
>         Environment: Linux Debian
> JDK 17
> Apache CFX 4.0.2
> WSS4j 3.0.1 (and also 3.0.0)
>            Reporter: Cedric Tabin
>            Assignee: Colm O hEigeartaigh
>            Priority: Major
>
> Hello,
> We are using wss4j with the Apache CXF library to connect to a SOAP web 
> service. The latter has some security-enabled methods which involves 
> signature and encryption.
> When writing the unit tests related to this, we hit a strange problem: if the 
> signature is enabled (through `WSS4JOutInterceptor`), then the process hangs 
> during marshalling without any exception regardless of any timeout set in the 
> connection (although a "Connection refused" exception should have been thrown 
> right away since we are pointing to localhost:1234).
> Here is the code snipped involved:
> {code:java}
> final ClientImpl client = (ClientImpl) ClientProxy.getClient(port);
> //url points to localhost:1234 on which nothing is listening => connection 
> should be refused immediately
> client.getRequestContext().put(Message.ENDPOINT_ADDRESS, url);
> client.setThreadLocalRequestContext(true);
> client.setSynchronousTimeout(10000);
> final HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
> httpClientPolicy.setReceiveTimeout(1200000);
> httpClientPolicy.setAllowChunking(true);
> httpClientPolicy.setMaxRetransmits(0);
> httpConduit.setClient(httpClientPolicy);
> TLSClientParameters tlsClientParameters = new TLSClientParameters();
> tlsClientParameters.setSecureSocketProtocol("TLSv1.3");
> tlsClientParameters.setDisableCNCheck(true);
> httpConduit.setTlsClientParameters(tlsClientParameters);
> {    
>     WSEncryptionPart sigTimestamp = new WSEncryptionPart("Timestamp", 
> WSConstants.WSU_NS, "");   
>     WSEncryptionPart sigBody = new WSEncryptionPart("Body", 
> WSConstants.URI_SOAP11_ENV, "");       
>     SignatureActionToken erpSignature = new SignatureActionToken();
>     erpSignature.setUser(getSignatureUser());      
>     erpSignature.setCryptoProperties(getOutSecurityPropFile());    
>     erpSignature.setKeyIdentifierId(WSConstants.BST_DIRECT_REFERENCE);   
>     erpSignature.setSignatureAlgorithm(WSConstants.RSA_SHA256);   
>     erpSignature.setDigestAlgorithm(WSConstants.SHA256);    
>     erpSignature.setParts(Arrays.asList(sigTimestamp, sigBody));
>     List<HandlerAction> actions = new ArrayList<>();    
>     actions.add(new HandlerAction(WSConstants.TS, null));    
>     actions.add(new HandlerAction(WSConstants.SIGN, erpSignature));    
>     Map<String, Object> properties = getOutSecurityProperties();
>     properties.put(WSHandlerConstants.HANDLER_ACTIONS, actions);    
>     ExtensibleWSS4JOutInterceptor wss4JOutInterceptor = new 
> ExtensibleWSS4JOutInterceptor(properties, getAfterSignatureCallbacks());    
>     wss4JOutInterceptor.setId("WSS4JOutSignatureInterceptor");         
>     //if this line is commented => the process fails directly (which is 
> correct) because nothing is listening at the endpoint    
>    client.getOutInterceptors().add(wss4JOutInterceptor);
> }
> String operation = jaxbElement.getName().getLocalPart();
> Object[] object = client.invoke(operation, jaxbElement.getValue());
> return object[0];
> {code}
> If the `wss4JOutInterceptor` is not added, the the process immediately fails 
> (which is expected).
> {noformat}
> org.apache.cxf.interceptor.Fault: Could not send Message.
> at 
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:67)
> at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
> at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:332)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:318)
>  Caused by: java.net.ConnectException: ConnectException invoking 
> [https://localhost:1234/Invalid:] Connection refused
> at 
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>  Method)
> at 
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
> at 
> java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at 
> java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
> at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
> Caused by: java.net.ConnectException
> at 
> java.net.http/jdk.internal.net.http.common.Utils.toConnectException(Utils.java:1055)
> at 
> java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:198)
> at 
> java.net.http/jdk.internal.net.http.PlainHttpConnection.checkRetryConnect(PlainHttpConnection.java:230)
> at 
> java.net.http/jdk.internal.net.http.PlainHttpConnection.lambda$connectAsync$1(PlainHttpConnection.java:206)
> at 
> java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
> at 
> java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
> at 
> java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
> at 
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
> at 
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
> at 
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
> at java.base/java.lang.Thread.run(Thread.java:833)
> Caused by: java.nio.channels.ClosedChannelException
> at 
> java.base/sun.nio.ch.SocketChannelImpl.ensureOpen(SocketChannelImpl.java:195)
> at 
> java.base/sun.nio.ch.SocketChannelImpl.beginConnect(SocketChannelImpl.java:760)
> at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:848)
> at 
> java.net.http/jdk.internal.net.http.PlainHttpConnection.lambda$connectAsync$0(PlainHttpConnection.java:183)
> at 
> java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
> at 
> java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:185)
> {noformat}
> If any help, here is the stacktrace where the process hangs forever:
> {noformat}
>  at java.lang.Object.wait(Object.java)
>  at java.io.PipedInputStream.awaitSpace(PipedInputStream.java:273)
>  at java.io.PipedInputStream.receive(PipedInputStream.java:231)
>  at java.io.PipedOutputStream.write(PipedOutputStream.java:150)
>  at 
> org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:51)
>  at 
> org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.write(UTF8XmlOutput.java:386)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.output.Encoded.write(Encoded.java:137)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.writePrefix(UTF8XmlOutput.java:205)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.writeName(UTF8XmlOutput.java:209)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.output.UTF8XmlOutput.beginStartTag(UTF8XmlOutput.java:138)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.output.ForkXmlOutput.beginStartTag(ForkXmlOutput.java:48)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:288)
>  at 
> org.glassfish.jaxb.runtime.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1115)
>  at 
> org.glassfish.jaxb.runtime.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1092)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:224)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:94)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:38)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:132)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:122)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:128)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:125)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:93)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:316)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:324)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:38)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:456)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:265)
>  at 
> org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:197)
>  at 
> jakarta.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:86)
>  at 
> org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:642)
>  at 
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:244)
>  at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:238)
>  at 
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:118)
>  at 
> org.apache.cxf.wsdl.interceptors.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
>  at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
>  at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528)
>  at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
>  at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354)
>  at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312)
>  at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:332)
>  at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:318)
> {noformat}
> Any workaround is welcome.
> Thanks & best regards.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ws.apache.org
For additional commands, e-mail: dev-h...@ws.apache.org


Reply via email to