You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Pampolini Matteo <ma...@selex-es.com> on 2014/04/15 15:25:11 UTC
Please help me with HTTP authentication/XML message modification
Hello there,
I'm developing an ONVIF client module that needs to make appropriate SOAP requests to
some remote devices. Usually these devices accept HTTP text or digest authentication or both.
Sometimes it happens that their date/time is not synchronized with the one of the client PC,
thus authentication fails. However, ONVIF devices provide a method to retrieve their current
date/time to calculate an offset and then set the right time inside the SOAP request.
The only way I found to achieve this is through an out interceptor that takes the XML message
and modifies the wsu:Created element accordingly. Googling a lot I came to this link:
http://stackoverflow.com/questions/6915428/how-to-modify-the-raw-xml-message-of-an-outbound-cxf-request
The problem is that adding this interceptor, I can modify the XML message, but I see no packet transmitted
over the wire. If I just comment out the line:
message.getInterceptorChain().doIntercept(message);
the packet is transmitted, but my XML message to be modified is empty.
Any ideas? I really don't know how to go further...
Many thanks in advance,
Matteo
This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
Questa e-mail e tutti i suoi allegati sono da intendersi inviati in via riservata all'effettivo destinatario e possono essere soggetti a restrizioni legali. Se non siete l'effettivo destinatario o avete ricevuto il messaggio per errore siete pregati di cancellarlo dal vostro sistema e di avvisare il mittente. E' vietata la duplicazione, l'uso a qualsiasi titolo, la divulgazione o la distribuzione dei contenuti di questa e-mail a qualunque altro soggetto.
Prima di stampare questa comunicazione consideratene, per favore, l'impatto ambientale
Please consider the environment before printing this email
Re: Please help me with HTTP authentication/XML message modification
Posted by Daniel Kulp <dk...@apache.org>.
The WSSConfig object that is used to pass configuration into WSS4J has a WSTimeSource object which can be used to provide a custom time source for use with creating timestamps in the UsernameToken. That’s what I’d look into doing.
Dan
On Apr 15, 2014, at 9:25 AM, Pampolini Matteo <ma...@selex-es.com> wrote:
> Hello there,
>
> I'm developing an ONVIF client module that needs to make appropriate SOAP requests to
> some remote devices. Usually these devices accept HTTP text or digest authentication or both.
>
> Sometimes it happens that their date/time is not synchronized with the one of the client PC,
> thus authentication fails. However, ONVIF devices provide a method to retrieve their current
> date/time to calculate an offset and then set the right time inside the SOAP request.
>
> The only way I found to achieve this is through an out interceptor that takes the XML message
> and modifies the wsu:Created element accordingly. Googling a lot I came to this link:
>
> http://stackoverflow.com/questions/6915428/how-to-modify-the-raw-xml-message-of-an-outbound-cxf-request
>
> The problem is that adding this interceptor, I can modify the XML message, but I see no packet transmitted
> over the wire. If I just comment out the line:
>
> message.getInterceptorChain().doIntercept(message);
>
> the packet is transmitted, but my XML message to be modified is empty.
>
> Any ideas? I really don't know how to go further...
>
> Many thanks in advance,
>
> Matteo
>
> This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
> Questa e-mail e tutti i suoi allegati sono da intendersi inviati in via riservata all'effettivo destinatario e possono essere soggetti a restrizioni legali. Se non siete l'effettivo destinatario o avete ricevuto il messaggio per errore siete pregati di cancellarlo dal vostro sistema e di avvisare il mittente. E' vietata la duplicazione, l'uso a qualsiasi titolo, la divulgazione o la distribuzione dei contenuti di questa e-mail a qualunque altro soggetto.
>
> Prima di stampare questa comunicazione consideratene, per favore, l'impatto ambientale
> Please consider the environment before printing this email
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Re: Please help me with HTTP authentication/XML message modification
Posted by Colm O hEigeartaigh <co...@apache.org>.
I would tackle it by copying how the WSS4JOutInterceptor gets the SAAJ
Document + make sure this interceptor runs before the WSS4JOutInterceptor.
Colm.
On Tue, Apr 15, 2014 at 6:07 PM, Hart, Andrew B. <AH...@akimeka.com> wrote:
> Wrt Matteo's message, I decided to revisit this as well, using the
> abstract MessageChangeInterceptor at the stackoverflow link he included.
> So, I have my interceptor constructor like this:
>
> public MessageChangeInterceptor() {
> super(Phase.PRE_STREAM);
> List<String> interceptors = new ArrayList<String>();
>
> interceptors.add(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.class.getName());
> interceptors.add(SoapPreProtocolOutInterceptor.class.getName());
> //addBefore(SoapPreProtocolOutInterceptor.class.getName());
> addBefore(interceptors);
> }
> [...]
>
> It's being setup in the jboss-cxf.xml config file like this:
>
> <bean id="TestInterceptor"
> class="com.akimeka.ws.common.interceptors.TestChangeInterceptor" />
>
> <bean id="Sign_Response"
> class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
> <constructor-arg>
> <map>
> <entry key="action" value="Timestamp Signature Encrypt"/>
> ...
> <jaxws:inInterceptors>
> <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
> <ref bean="Sign_Request"/>
> </jaxws:inInterceptors>
>
>
> But, my problem is that I see the Soap message dumped out to my log, but
> it is already encrypted.
>
> So, my question is, how can I set this interceptor up to allow me access
> to the Soap envelope before this occurs...
>
> Again, using CXF 2.3.1 with JBoss 6.
>
> Regards,
>
> -- Andy
>
>
>
>
> -----Original Message-----
> From: Pampolini Matteo [mailto:matteo.pampolini@selex-es.com]
> Sent: Tuesday, April 15, 2014 8:25 AM
> To: users@cxf.apache.org
> Subject: Please help me with HTTP authentication/XML message modification
>
> Hello there,
>
> I'm developing an ONVIF client module that needs to make appropriate SOAP
> requests to some remote devices. Usually these devices accept HTTP text or
> digest authentication or both.
>
> Sometimes it happens that their date/time is not synchronized with the one
> of the client PC, thus authentication fails. However, ONVIF devices provide
> a method to retrieve their current date/time to calculate an offset and
> then set the right time inside the SOAP request.
>
> The only way I found to achieve this is through an out interceptor that
> takes the XML message and modifies the wsu:Created element accordingly.
> Googling a lot I came to this link:
>
>
> http://stackoverflow.com/questions/6915428/how-to-modify-the-raw-xml-message-of-an-outbound-cxf-request
>
> The problem is that adding this interceptor, I can modify the XML message,
> but I see no packet transmitted over the wire. If I just comment out the
> line:
>
> message.getInterceptorChain().doIntercept(message);
>
> the packet is transmitted, but my XML message to be modified is empty.
>
> Any ideas? I really don't know how to go further...
>
> Many thanks in advance,
>
> Matteo
>
> This email and any attachments are confidential to the intended recipient
> and may also be privileged. If you are not the intended recipient please
> delete it from your system and notify the sender. You should not copy it or
> use it for any purpose nor disclose or distribute its contents to any other
> person.
> Questa e-mail e tutti i suoi allegati sono da intendersi inviati in via
> riservata all'effettivo destinatario e possono essere soggetti a
> restrizioni legali. Se non siete l'effettivo destinatario o avete ricevuto
> il messaggio per errore siete pregati di cancellarlo dal vostro sistema e
> di avvisare il mittente. E' vietata la duplicazione, l'uso a qualsiasi
> titolo, la divulgazione o la distribuzione dei contenuti di questa e-mail a
> qualunque altro soggetto.
>
> Prima di stampare questa comunicazione consideratene, per favore,
> l'impatto ambientale Please consider the environment before printing this
> email
>
--
Colm O hEigeartaigh
Talend Community Coder
http://coders.talend.com
RE: Please help me with HTTP authentication/XML message modification
Posted by "Hart, Andrew B." <AH...@Akimeka.com>.
Wrt Matteo's message, I decided to revisit this as well, using the abstract MessageChangeInterceptor at the stackoverflow link he included.
So, I have my interceptor constructor like this:
public MessageChangeInterceptor() {
super(Phase.PRE_STREAM);
List<String> interceptors = new ArrayList<String>();
interceptors.add(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.class.getName());
interceptors.add(SoapPreProtocolOutInterceptor.class.getName());
//addBefore(SoapPreProtocolOutInterceptor.class.getName());
addBefore(interceptors);
}
[...]
It's being setup in the jboss-cxf.xml config file like this:
<bean id="TestInterceptor" class="com.akimeka.ws.common.interceptors.TestChangeInterceptor" />
<bean id="Sign_Response" class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Timestamp Signature Encrypt"/>
...
<jaxws:inInterceptors>
<bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
<ref bean="Sign_Request"/>
</jaxws:inInterceptors>
But, my problem is that I see the Soap message dumped out to my log, but it is already encrypted.
So, my question is, how can I set this interceptor up to allow me access to the Soap envelope before this occurs...
Again, using CXF 2.3.1 with JBoss 6.
Regards,
-- Andy
-----Original Message-----
From: Pampolini Matteo [mailto:matteo.pampolini@selex-es.com]
Sent: Tuesday, April 15, 2014 8:25 AM
To: users@cxf.apache.org
Subject: Please help me with HTTP authentication/XML message modification
Hello there,
I'm developing an ONVIF client module that needs to make appropriate SOAP requests to some remote devices. Usually these devices accept HTTP text or digest authentication or both.
Sometimes it happens that their date/time is not synchronized with the one of the client PC, thus authentication fails. However, ONVIF devices provide a method to retrieve their current date/time to calculate an offset and then set the right time inside the SOAP request.
The only way I found to achieve this is through an out interceptor that takes the XML message and modifies the wsu:Created element accordingly. Googling a lot I came to this link:
http://stackoverflow.com/questions/6915428/how-to-modify-the-raw-xml-message-of-an-outbound-cxf-request
The problem is that adding this interceptor, I can modify the XML message, but I see no packet transmitted over the wire. If I just comment out the line:
message.getInterceptorChain().doIntercept(message);
the packet is transmitted, but my XML message to be modified is empty.
Any ideas? I really don't know how to go further...
Many thanks in advance,
Matteo
This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
Questa e-mail e tutti i suoi allegati sono da intendersi inviati in via riservata all'effettivo destinatario e possono essere soggetti a restrizioni legali. Se non siete l'effettivo destinatario o avete ricevuto il messaggio per errore siete pregati di cancellarlo dal vostro sistema e di avvisare il mittente. E' vietata la duplicazione, l'uso a qualsiasi titolo, la divulgazione o la distribuzione dei contenuti di questa e-mail a qualunque altro soggetto.
Prima di stampare questa comunicazione consideratene, per favore, l'impatto ambientale Please consider the environment before printing this email
Re: Please help me with HTTP authentication/XML message modification
Posted by Pampolini Matteo <ma...@selex-es.com>.
Hi Dan,
many thanks for your and all other replies. Just another question: how
can I pass WSSConfig
object to the WSS4J out interceptor in a "legal" way without hacking the
code?
Regards, Matteo
On 16/04/2014 17:19, Daniel Kulp wrote:
> The WSSConfig object that is used to pass configuration into WSS4J has a WSTimeSource object which can be used to provide a custom time source for use with creating timestamps in the UsernameToken. That’s what I’d look into doing.
>
> Dan
>
>
> On Apr 15, 2014, at 9:25 AM, Pampolini Matteo <ma...@selex-es.com> wrote:
>
>> Hello there,
>>
>> I'm developing an ONVIF client module that needs to make appropriate SOAP requests to
>> some remote devices. Usually these devices accept HTTP text or digest authentication or both.
>>
>> Sometimes it happens that their date/time is not synchronized with the one of the client PC,
>> thus authentication fails. However, ONVIF devices provide a method to retrieve their current
>> date/time to calculate an offset and then set the right time inside the SOAP request.
>>
>> The only way I found to achieve this is through an out interceptor that takes the XML message
>> and modifies the wsu:Created element accordingly. Googling a lot I came to this link:
>>
>> http://stackoverflow.com/questions/6915428/how-to-modify-the-raw-xml-message-of-an-outbound-cxf-request
>>
>> The problem is that adding this interceptor, I can modify the XML message, but I see no packet transmitted
>> over the wire. If I just comment out the line:
>>
>> message.getInterceptorChain().doIntercept(message);
>>
>> the packet is transmitted, but my XML message to be modified is empty.
>>
>> Any ideas? I really don't know how to go further...
>>
>> Many thanks in advance,
>>
>> Matteo
>>
>> This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
>> Questa e-mail e tutti i suoi allegati sono da intendersi inviati in via riservata all'effettivo destinatario e possono essere soggetti a restrizioni legali. Se non siete l'effettivo destinatario o avete ricevuto il messaggio per errore siete pregati di cancellarlo dal vostro sistema e di avvisare il mittente. E' vietata la duplicazione, l'uso a qualsiasi titolo, la divulgazione o la distribuzione dei contenuti di questa e-mail a qualunque altro soggetto.
>>
>> Prima di stampare questa comunicazione consideratene, per favore, l'impatto ambientale
>> Please consider the environment before printing this email
This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
Questa e-mail e tutti i suoi allegati sono da intendersi inviati in via riservata all'effettivo destinatario e possono essere soggetti a restrizioni legali. Se non siete l'effettivo destinatario o avete ricevuto il messaggio per errore siete pregati di cancellarlo dal vostro sistema e di avvisare il mittente. E' vietata la duplicazione, l'uso a qualsiasi titolo, la divulgazione o la distribuzione dei contenuti di questa e-mail a qualunque altro soggetto.
Prima di stampare questa comunicazione consideratene, per favore, l'impatto ambientale
Please consider the environment before printing this email