CXF and Encrypt

View: New views
6 Messages — Rating Filter:   Alert me  

CXF and Encrypt

by Kid_79 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,
I'm using CXF 2.1.4 with my interceptor (my WSS4J).
When I use action = Encrypt Signature UsernameToken I'have this error:

org.apache.cxf.interceptor.Fault: Message part {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.  (Does it exist in service WSDL?)

Can you help me?

Thanks

Re: CXF and Encrypt

by Glen Mazza :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hmmm...perhaps my tutorial[1] might point out where the error is

HTH,
Glen

[1] http://www.jroller.com/gmazza/entry/implementing_ws_security_with_the

Kid_79 wrote:
Hi all,
I'm using CXF 2.1.4 with my interceptor (my WSS4J).
When I use action = Encrypt Signature UsernameToken I'have this error:

org.apache.cxf.interceptor.Fault: Message part {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.  (Does it exist in service WSDL?)

Can you help me?

Thanks

Re: CXF and Encrypt

by dkulp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri June 26 2009 1:23:49 pm Kid_79 wrote:
> Hi all,
> I'm using CXF 2.1.4 with my interceptor (my WSS4J).
> When I use action = Encrypt Signature UsernameToken I'have this error:
>
> org.apache.cxf.interceptor.Fault: Message part
> {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.  (Does
> it exist in service WSDL?)
>
> Can you help me?

It sounds like your interceptor isn't properly decrypting everything.   That
element is left encrypted so we don't know what it is.

--
Daniel Kulp
dkulp@...
http://www.dankulp.com/blog

Re: CXF and Encrypt

by Kid_79 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all, I don't solve my error. Now I try to describe this my problem.

A client calls a web service that it uses a my interceptor (RequestInterceptor); it gets SOAPMessage from SoapMessage of CXF and then it uses my task for encrypt/signature implemented with wss4j and this task returns a modify SOAPMessage; now in RequestInterceptor I set SOAPMessage into cxf SoapMessage.
Now here it's ok, in TCP monitor I have an encrypt/signature Envelope.
After RequestInterceptor, I call another web service that decrypt/signature; this web service uses an interceptor (RequestInterceptor) the same as the first (that it gets SOAPMessage, etcc and a task uses decrypt/signature) and then in RequestInterceptor I set SOAPMessage into cxf SoapMessage.
The operation decrypt/signature are ok, wss4j works; but in this point I have an error, on DocLiteralInInterceptor interceptor.

If I use in my task signature or usernameToken it's works, while when I use a encrypt I have an error.
It seems when the body is changed!!

I hope to be clear to describe the problem and that someone can help me.

This is my error:
org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Message part {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.  (Does it exist in service WSDL?)
        at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)


dkulp wrote:
On Fri June 26 2009 1:23:49 pm Kid_79 wrote:
> Hi all,
> I'm using CXF 2.1.4 with my interceptor (my WSS4J).
> When I use action = Encrypt Signature UsernameToken I'have this error:
>
> org.apache.cxf.interceptor.Fault: Message part
> {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.  (Does
> it exist in service WSDL?)
>
> Can you help me?

It sounds like your interceptor isn't properly decrypting everything.   That
element is left encrypted so we don't know what it is.

--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: CXF and Encrypt

by dkulp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


If you modify the SAAJ stuff in an interceptor, you probably also need to
replace the XMLStreamReader that is wrappering the SAAJ model.    Try doing:

DOMSource bodySource = new
DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
xmlReader = StaxUtils.createXMLStreamReader(bodySource);
xmlReader.nextTag();
xmlReader.nextTag(); // move past body tag
message.setContent(XMLStreamReader.class, xmlReader);  

(not sure on the number of nextTag things in there)

Basically, internally, most things in CXF operate on the XMLStreamReader.  
Thus, it has to be correct and pointing at the right elements.   Most likely,
when your interceptor is running, it's pointing at the encrypted element and
you are replacing it with a non-encrypted element, but the reader is still
pointing at it.

Dan



On Thu July 9 2009 1:27:56 pm Kid_79 wrote:

> Hi all, I don't solve my error. Now I try to describe this my problem.
>
> A client calls a web service that it uses a my interceptor
> (RequestInterceptor); it gets SOAPMessage from SoapMessage of CXF and then
> it uses my task for encrypt/signature implemented with wss4j and this task
> returns a modify SOAPMessage; now in RequestInterceptor I set SOAPMessage
> into cxf SoapMessage.
> Now here it's ok, in TCP monitor I have an encrypt/signature Envelope.
> After RequestInterceptor, I call another web service that
> decrypt/signature; this web service uses an interceptor
> (RequestInterceptor) the same as the first (that it gets SOAPMessage, etcc
> and a task uses decrypt/signature) and then in RequestInterceptor I set
> SOAPMessage into cxf SoapMessage. The operation decrypt/signature are ok,
> wss4j works; but in this point I have an error, on DocLiteralInInterceptor
> interceptor.
>
> If I use in my task signature or usernameToken it's works, while when I use
> a encrypt I have an error.
> It seems when the body is changed!!
>
> I hope to be clear to describe the problem and that someone can help me.
>
> This is my error:
> org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Message part
> {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.  (Does
> it exist in service WSDL?)
> at
> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteral
>InInterceptor.java) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>n.java:236)
>
> dkulp wrote:
> > On Fri June 26 2009 1:23:49 pm Kid_79 wrote:
> >> Hi all,
> >> I'm using CXF 2.1.4 with my interceptor (my WSS4J).
> >> When I use action = Encrypt Signature UsernameToken I'have this error:
> >>
> >> org.apache.cxf.interceptor.Fault: Message part
> >> {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.
> >> (Does
> >> it exist in service WSDL?)
> >>
> >> Can you help me?
> >
> > It sounds like your interceptor isn't properly decrypting everything.
> > That
> > element is left encrypted so we don't know what it is.
> >
> > --
> > Daniel Kulp
> > dkulp@...
> > http://www.dankulp.com/blog

--
Daniel Kulp
dkulp@...
http://www.dankulp.com/blog

Re: CXF and Encrypt

by Kid_79 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank Dan,
it's works.

For information, at the end of my RequestInterceptor, after that I set SOAPMessage into cxf SoapMessage, I set XMLStreamReader too.
It's right to set both SOAPMessage or XMLStreamReader?

Without setting SOAPMessage it's not works.
However I use setting SOAPMessage for attachment too.

dkulp wrote:
If you modify the SAAJ stuff in an interceptor, you probably also need to
replace the XMLStreamReader that is wrappering the SAAJ model.    Try doing:

DOMSource bodySource = new
DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
xmlReader = StaxUtils.createXMLStreamReader(bodySource);
xmlReader.nextTag();
xmlReader.nextTag(); // move past body tag
message.setContent(XMLStreamReader.class, xmlReader);  

(not sure on the number of nextTag things in there)

Basically, internally, most things in CXF operate on the XMLStreamReader.  
Thus, it has to be correct and pointing at the right elements.   Most likely,
when your interceptor is running, it's pointing at the encrypted element and
you are replacing it with a non-encrypted element, but the reader is still
pointing at it.

Dan



On Thu July 9 2009 1:27:56 pm Kid_79 wrote:
> Hi all, I don't solve my error. Now I try to describe this my problem.
>
> A client calls a web service that it uses a my interceptor
> (RequestInterceptor); it gets SOAPMessage from SoapMessage of CXF and then
> it uses my task for encrypt/signature implemented with wss4j and this task
> returns a modify SOAPMessage; now in RequestInterceptor I set SOAPMessage
> into cxf SoapMessage.
> Now here it's ok, in TCP monitor I have an encrypt/signature Envelope.
> After RequestInterceptor, I call another web service that
> decrypt/signature; this web service uses an interceptor
> (RequestInterceptor) the same as the first (that it gets SOAPMessage, etcc
> and a task uses decrypt/signature) and then in RequestInterceptor I set
> SOAPMessage into cxf SoapMessage. The operation decrypt/signature are ok,
> wss4j works; but in this point I have an error, on DocLiteralInInterceptor
> interceptor.
>
> If I use in my task signature or usernameToken it's works, while when I use
> a encrypt I have an error.
> It seems when the body is changed!!
>
> I hope to be clear to describe the problem and that someone can help me.
>
> This is my error:
> org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Message part
> {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.  (Does
> it exist in service WSDL?)
> at
> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteral
>InInterceptor.java) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>n.java:236)
>
> dkulp wrote:
> > On Fri June 26 2009 1:23:49 pm Kid_79 wrote:
> >> Hi all,
> >> I'm using CXF 2.1.4 with my interceptor (my WSS4J).
> >> When I use action = Encrypt Signature UsernameToken I'have this error:
> >>
> >> org.apache.cxf.interceptor.Fault: Message part
> >> {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.
> >> (Does
> >> it exist in service WSDL?)
> >>
> >> Can you help me?
> >
> > It sounds like your interceptor isn't properly decrypting everything.
> > That
> > element is left encrypted so we don't know what it is.
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog