The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Don Stadler (74) [Avatar] Offline
#1
Tjis,

You mentioned a WS-Security example. The book walks through the WS-Security deployment for both Mule and servicemix but doesn't mention an example.

Being the annoying person I am I decided to look in the ch7-build.xml file and found targets named chapter7-wss-provide and chapter7-wss-consume, which seemed to fit. So I ran them in seperate windows. The provide target ran nicely, the consum op wasn't as polite.

gn:compile-classes:
[javac] Compiling 17 source files to C:osesbinactionworkspaceworkspace-mu
lemuleclasses
[javac] Note: C:osesbinactionworkspaceworkspace-mulemulesrcesbchapter
7TestPwdCallback.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[echo] Compiling classes
[jar] Building jar: C:osesbinactionesbmule-2.0.2libuserchapter7-wss-
consume.jar
[java] FATAL ERROR in native method: JDWP No transports initialized, jvmtiE
rror=AGENT_ERROR_TRANSPORT_INIT(197)
[java] ERROR: transport error 202: bind failed: Address already in use
[java] ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT
(510)
[java] JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initi
alized [../../../src/share/back/debugInit.c:690]
[java] Java Result: 1
tijs.rademakers (494) [Avatar] Offline
#2
Re: Chapter 7 WS-Security Mule example
Okay, we should include the examples in the book.
Note that you can run the chapter7-wss-provide target and use the Swing test client to invoke the web service. And you can seperately run the chapter7-wss-consume target and it has both a web service client as well as a web service provider there in one Mule configuration. So you can't run the targets together as they use a Mule instance with the same ports, and you get the exception you mentioned here.

Best regards,

Tijs
Don Stadler (74) [Avatar] Offline
#3
Re: Chapter 7 WS-Security Mule example
I ran the chapter7-wss-provide target and got a fault in the response box:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">ns1:UnsupportedAlgorithm</faultcode><faultstring>An unsupported signature or encryption algorithm was used (unsupported key transport encryption algorithm: No such algorithm: http://www.w3.org/2001/04/xmlenc#rsa-1_5)</faultstring></soap:Fault></soap:Body></soap:Envelope>

I ran the chapter7-wss-consume target seperately and tested it with the test client. The Mule trace showed the samne problem shown above:

************
[java] Root Exception stack trace:
[java] org.apache.ws.security.WSSecurityException: WSHandler: Encryption: e
rror during message processingorg.apache.ws.security.WSSecurityException: An uns
upported signature or encryption algorithm was used (unsupported key transport e
ncryption algorithm: No such algorithm: http://www.w3.org/2001/04/xmlenc#rsa-1_5
)
[java] at org.apache.ws.security.action.EncryptionAction.execute(Encryp
tionAction.java:65)
[java] at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHan
dler.java:197)
[java] at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.handleMe
ssage(WSS4JOutInterceptor.java:169)
[java] at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.handleMe
ssage(WSS4JOutInterceptor.java:43)
[java] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseI
nterceptorChain.java:221)
[java] at org.mule.transport.cxf.transport.MuleUniversalConduit$2.write
(MuleUniversalConduit.java:162)
[java] at org.mule.transport.http.StreamPayloadRequestEntity.writeReque
st(StreamPayloadRequestEntity.java:39)
[java] at org.apache.commons.httpclient.methods.EntityEnclosingMethod.w
riteRequestBody(EntityEnclosingMethod.java:499)
[java] at org.apache.commons.httpclient.HttpMethodBase.writeRequest(Htt
pMethodBase.java:2114)
[java] at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMeth
odBase.java:1096)
[java] at org.apache.commons.httpclient.HttpMethodDirector.executeWithR
etry(HttpMethodDirector.java:39smilie
[java] at org.apache.commons.httpclient.HttpMethodDirector.executeMetho
d(HttpMethodDirector.java:171)
[java] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpCl
ient.java:397)
[java] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpCl
ient.java:346)
[java] at org.mule.transport.http.HttpClientMessageDispatcher.execute(H
ttpClientMessageDispatcher.java:109)
[java] at org.mule.transport.http.HttpClientMessageDispatcher.doSend(Ht
tpClientMessageDispatcher.java:243)
[java] at org.mule.transport.AbstractMessageDispatcher.send(AbstractMes
sageDispatcher.java:157)
[java] at org.mule.transport.AbstractConnector.send(AbstractConnector.j
ava:1890)
[java] at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboun
dEndpoint.java:76)
[java] at org.mule.transport.cxf.transport.MuleUniversalConduit.sendStr
eam(MuleUniversalConduit.java:270)
[java] at org.mule.transport.cxf.transport.MuleUniversalConduit.dispatc
hMuleMessage(MuleUniversalConduit.java:182)
[java] at org.mule.transport.cxf.transport.MuleUniversalConduit$1.handl
eMessage(MuleUniversalConduit.java:142)
[java] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseI
nterceptorChain.java:221)
[java] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276
)
[java] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222
)
[java] at org.mule.transport.cxf.CxfMessageDispatcher.doSendWithClient(
CxfMessageDispatcher.java:195)
[java] at org.mule.transport.cxf.CxfMessageDispatcher.doSend(CxfMessage
Dispatcher.java:129)
[java] at org.mule.transport.AbstractMessageDispatcher.send(AbstractMes
sageDispatcher.java:157)
[java] at org.mule.transport.AbstractConnector.send(AbstractConnector.j
ava:1890)
[java] at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboun
dEndpoint.java:76)
[java] at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java
:327)
[java] at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java
:213)
[java] at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransa
ction(AbstractOutboundRouter.java:14smilie
[java] at org.mule.transaction.TransactionTemplate.execute(TransactionT
emplate.java:99)
[java] at org.mule.routing.outbound.AbstractOutboundRouter.send(Abstrac
tOutboundRouter.java:155)
[java] at org.mule.routing.outbound.ChainingRouter.route(ChainingRouter
.java:67)
[java] at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.d
oInTransaction(DefaultOutboundRouterCollection.java:64)
[java] at org.mule.transaction.TransactionTemplate.execute(TransactionT
emplate.java:45)
[java] at org.mule.routing.outbound.DefaultOutboundRouterCollection.rou
te(DefaultOutboundRouterCollection.java:69)
[java] at org.mule.service.AbstractService.dispatchToOutboundRouter(Abs
tractService.java:883)
[java] at org.mule.model.seda.SedaService.dispatchToOutboundRouter(Seda
Service.java:514)
[java] at org.mule.model.seda.SedaService$ComponentStageWorker.run(Seda
Service.java:537)
[java] at org.mule.work.WorkerContext.run(WorkerContext.java:310)
[java] at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExec
utor.runWorker(ThreadPoolExecutor.java:1061)
[java] at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExec
utor$Worker.run(ThreadPoolExecutor.java:575)
[java] at java.lang.Thread.run(Thread.java:619)
[java]
[java] ********************************************************************
************
[java]
[java] ERROR - DefaultServiceExceptionStrategy -
[java] ********************************************************************
************
[java] Message : Failed to route event via endpoint: DefaultO
utboundEndpoint{endpointUri=http://localhost:8081/services/CoCservice?wsdl&metho
d=getCompany, connector=CxfWsdlConnector{this=2c1b13, started=true, initialised=
true, name='wsdlCxfConnector', disposed=false, numberOfConcurrentTransactedRecei
vers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtoco
ls=[wsdl-cxf, wsdl-cxf:http, wsdl-cxf:https, wsdl:http, wsdl:https], serviceOver
rides=null}, transformer=[], name='endpoint.http.localhost.8081.services.CoCserv
ice.wsdl', properties={port={http://opensource.esb.org/CoC/}ChamberOfCommerceSer
viceImplPort, wsdl=, service={http://opensource.esb.org/CoC/}ChamberOfCommerceSe
rviceImplService, method=getCompany}, transactionConfig=Transaction{factory=null
, action=NEVER, timeout=0}, filter=null, deleteUnacceptedMessages=false, securit
yFilter=null, synchronous=true, initialState=started, remoteSync=true, remoteSyn
cTimeout=3000, endpointEncoding=UTF-8}. Message payload is of type: String
[java] Type : org.mule.api.transport.DispatchException
[java] Code : MULE_ERROR-42999
[java] Payload : Holthouse Carlin & Van Tright LLP (HCVT)
[java] JavaDoc : http://mule.mulesource.org/docs/apidocs/org/
mule/api/transport/DispatchException.html
[java] ********************************************************************
************
[java] Exception stack is:
[java] 1. WSHandler: Encryption: error during message processingorg.apache.
ws.security.WSSecurityException: An unsupported signature or encryption algorith
m was used (unsupported key transport encryption algorithm: No such algorithm: h
ttp://www.w3.org/2001/04/xmlenc#rsa-1_5) (org.apache.ws.security.WSSecurityExcep
tion)
[java] org.apache.ws.security.action.EncryptionAction:65 (null)
[java] 2. Security processing failed. (org.apache.cxf.binding.soap.SoapFaul
t)
[java] org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor:184 (null)
[java] 3. Failed to route event via endpoint: DefaultOutboundEndpoint{endpo
intUri=http://localhost:8081/services/CoCservice?wsdl&method=getCompany, connect
or=CxfWsdlConnector{this=2c1b13, started=true, initialised=true, name='wsdlCxfCo
nnector', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipl
eTransactedReceivers=true, connected=true, supportedProtocols=[wsdl-cxf, wsdl-cx
f:http, wsdl-cxf:https, wsdl:http, wsdl:https], serviceOverrides=null}, transfor
mer=[], name='endpoint.http.localhost.8081.services.CoCservice.wsdl', properties
={port={http://opensource.esb.org/CoC/}ChamberOfCommerceServiceImplPort, wsdl=,
service={http://opensource.esb.org/CoC/}ChamberOfCommerceServiceImplService, met
hod=getCompany}, transactionConfig=Transaction{factory=null, action=NEVER, timeo
ut=0}, filter=null, deleteUnacceptedMessages=false, securityFilter=null, synchro
nous=true, initialState=started, remoteSync=true, remoteSyncTimeout=3000, endpoi
ntEncoding=UTF-8}. Message payload is of type: String (org.mule.api.transport.Di
spatchException)
[java] org.mule.transport.AbstractMessageDispatcher:188 (http://mule.mule
source.org/docs/apidocs/org/mule/api/transport/DispatchException.html)
[java] ********************************************************************
************
[java] Root Exception stack trace:
[java] org.apache.ws.security.WSSecurityException: WSHandler: Encryption: e
rror during message processingorg.apache.ws.security.WSSecurityException: An uns
upported signature or encryption algorithm was used (unsupported key transport e
ncryption algorithm: No such algorithm: http://www.w3.org/2001/04/xmlenc#rsa-1_5
)
[java] at org.apache.ws.security.action.EncryptionAction.execute(Encryp
tionAction.java:65)
[java] at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHan
dler.java:197)
[java] at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.handleMe
ssage(WSS4JOutInterceptor.java:169)
[java] at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.handleMe
ssage(WSS4JOutInterceptor.java:43)
[java] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseI
nterceptorChain.java:221)
[java] at org.mule.transport.cxf.transport.MuleUniversalConduit$2.write
(MuleUniversalConduit.java:162)
[java] at org.mule.transport.http.StreamPayloadRequestEntity.writeReque
st(StreamPayloadRequestEntity.java:39)
[java] at org.apache.commons.httpclient.methods.EntityEnclosingMethod.w
riteRequestBody(EntityEnclosingMethod.java:499)
[java] at org.apache.commons.httpclient.HttpMethodBase.writeRequest(Htt
pMethodBase.java:2114)
[java] at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMeth
odBase.java:1096)
[java] at org.apache.commons.httpclient.HttpMethodDirector.executeWithR
etry(HttpMethodDirector.java:39smilie
[java] at org.apache.commons.httpclient.HttpMethodDirector.executeMetho
d(HttpMethodDirector.java:171)
[java] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpCl
ient.java:397)
[java] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpCl
ient.java:346)
[java] at org.mule.transport.http.HttpClientMessageDispatcher.execute(H
ttpClientMessageDispatcher.java:109)
[java] at org.mule.transport.http.HttpClientMessageDispatcher.doSend(Ht
tpClientMessageDispatcher.java:243)
[java] at org.mule.transport.AbstractMessageDispatcher.send(AbstractMes
sageDispatcher.java:157)
[java] at org.mule.transport.AbstractConnector.send(AbstractConnector.j
ava:1890)
[java] at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboun
dEndpoint.java:76)
[java] at org.mule.transport.cxf.transport.MuleUniversalConduit.sendStr
eam(MuleUniversalConduit.java:270)
[java] at org.mule.transport.cxf.transport.MuleUniversalConduit.dispatc
hMuleMessage(MuleUniversalConduit.java:182)
[java] at org.mule.transport.cxf.transport.MuleUniversalConduit$1.handl
eMessage(MuleUniversalConduit.java:142)
[java] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseI
nterceptorChain.java:221)
[java] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276
)
[java] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222
)
[java] at org.mule.transport.cxf.CxfMessageDispatcher.doSendWithClient(
CxfMessageDispatcher.java:195)
[java] at org.mule.transport.cxf.CxfMessageDispatcher.doSend(CxfMessage
Dispatcher.java:129)
[java] at org.mule.transport.AbstractMessageDispatcher.send(AbstractMes
sageDispatcher.java:157)
[java] at org.mule.transport.AbstractConnector.send(AbstractConnector.j
ava:1890)
[java] at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboun
dEndpoint.java:76)
[java] at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java
:327)
[java] at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java
:213)
[java] at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransa
ction(AbstractOutboundRouter.java:14smilie
[java] at org.mule.transaction.TransactionTemplate.execute(TransactionT
emplate.java:99)
[java] at org.mule.routing.outbound.AbstractOutboundRouter.send(Abstrac
tOutboundRouter.java:155)
[java] at org.mule.routing.outbound.ChainingRouter.route(ChainingRouter
.java:67)
[java] at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.d
oInTransaction(DefaultOutboundRouterCollection.java:64)
[java] at org.mule.transaction.TransactionTemplate.execute(TransactionT
emplate.java:45)
[java] at org.mule.routing.outbound.DefaultOutboundRouterCollection.rou
te(DefaultOutboundRouterCollection.java:69)
[java] at org.mule.service.AbstractService.dispatchToOutboundRouter(Abs
tractService.java:883)
[java] at org.mule.model.seda.SedaService.dispatchToOutboundRouter(Seda
Service.java:514)
[java] at org.mule.model.seda.SedaService$ComponentStageWorker.run(Seda
Service.java:537)
[java] at org.mule.work.WorkerContext.run(WorkerContext.java:310)
[java] at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExec
utor.runWorker(ThreadPoolExecutor.java:1061)
[java] at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExec
utor$Worker.run(ThreadPoolExecutor.java:575)
[java] at java.lang.Thread.run(Thread.java:619)
[java]
[java] ********************************************************************
************
[java]

Message was edited by:
Don Stadler
bobs99 (5) [Avatar] Offline
#4
Re: Chapter 7 WS-Security Mule example
I think the error you are seeing could be becaase you need to download the bouncy castle jar.

Try downloading the jar file; bcprov-jdk16-141.jar for the encryption alogrithm you need then deploy into the JRE: ...jrelibext plus add the following entry to the file: ...jrelibsecurityjava.security

security.provider.nn=org.bouncycastle.jce.provider.BouncyCastleProvider

where 'nn' is the next number in the list.

Playing around with encryption and signing that worked fine for me. Although I can now get the signing examples and encrypting examples to work seperately, I cannot get BOTH signing and encryption to work at the same time ... yet!