Skip Menu |

This queue is for tickets about the XML-Compile-WSS CPAN distribution.

Report information
The Basics
Id: 79318
Status: resolved
Priority: 0/
Queue: XML-Compile-WSS

People
Owner: Nobody in particular
Requestors: mcdave [...] stanford.edu
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.90
Fixed in: (no value)



Subject: Calling wsseBasicAuth produces something illegible
While looking at something else, it seemed that when I called wsseBasicAuth twice in a row with a "created" element, the second UsernameToken lacks xmlns:wsu=..., so the Created element can't be understood. I tried to reproduce the problem using just XML::Compile::Cache (thinking it was the writer causing the problems) but couldn't test to fail. But the attached script gives the following output, where it's "clear" that the second instance just uses "wsu:Created" without declaring that namespace. -- ok 1 - First basic auth returns something sensible ok 2 - First basic auth is legible # Good string: <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:Username>username</wsse:Username><wsu:Created>2012-08-31T05:21:44Z</wsu:Created><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">rf/31fRgiHE6rAYMpqoxswL6bAo=</wsse:Password></wsse:UsernameToken> ok 3 - Second basic auth returns something sensible not ok 4 - Second basic auth is legible # Failed test 'Second basic auth is legible' # at t/05double_basic_auth.t line 49. # :1: namespace error : Namespace prefix wsu on Created is not defined # s-wssecurity-secext-1.0.xsd"><wsse:Username>username</wsse:Username><wsu:Created # ^ # Bad string: <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:Username>username</wsse:Username><wsu:Created>2012-08-31T05:21:44Z</wsu:Created><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">rf/31fRgiHE6rAYMpqoxswL6bAo=</wsse:Password></wsse:UsernameToken> # Looks like you failed 1 test of 4. -- My versions of the packages that show up in the script are Test::More version 0.98 XML::Compile version 1.27 XML::Compile::Cache version 0.991 XML::Compile::SOAP version 2.29 XML::Compile::C14N version 0.10 XML::Compile::WSDL11 version 2.29 XML::Compile::SOAP11 version 2.29 XML::Compile::Transport::SOAPHTTP version 2.29 XML::Compile::SOAP::WSS version 0.90 XML::Compile::WSS::Util version 0.90
Subject: 05double_basic_auth.t
#!/usr/bin/env perl # # Is it true that calling wsseBasicAuth twice causes an error? # use strict ; use warnings ; use Carp qw/cluck/ ; use Data::Dumper ; # use Log::Report mode => 3; # use Digest::SHA1 qw/sha1_base64/; # use Encode qw/encode/; # use MIME::Base64 qw/encode_base64 decode_base64/ ; use Test::More tests => 4 ; use XML::Compile::WSDL11; use XML::Compile::SOAP11; use XML::Compile::Transport::SOAPHTTP; use XML::Compile::SOAP::WSS; use XML::Compile::WSS::Util qw/:wss11 :utp11/; my ($username, $password) = qw/username password/; my $wsdl = XML::Compile::WSDL11->new( 'examples/wsse/example.wsdl'); my $wss = XML::Compile::SOAP::WSS->new( version => 1.1, schema => $wsdl); my $untype = $wss->schema->findName('wsse:UsernameToken'); my $unreader = $wss->schema->reader($untype) ; my $now = time() ; my $ut1 = $wss->wsseBasicAuth($username, $password, UTP11_PDIGEST , created => $now ); ok( $ut1, 'First basic auth returns something sensible' ) ; my $ut1String = $ut1->{$untype}->toString() ; ok( $unreader->( $ut1String ), 'First basic auth is legible' ) and diag( "Good string: $ut1String" ) ; my $ut2 = $wss->wsseBasicAuth($username, $password, UTP11_PDIGEST , created => $now ); ok( $ut2, 'Second basic auth returns something sensible' ) ; my $ut2String = $ut2->{$untype}->toString() ; ok( eval { $unreader->( $ut2String ) }, 'Second basic auth is legible' ) or do { diag( $@ ) ;diag( "Bad string: $ut2String" ) ; }
Subject: Re: [rt.cpan.org #79318] Calling wsseBasicAuth produces something illegible
Date: Fri, 31 Aug 2012 09:30:53 +0200
To: David Tindall Mcmath via RT <bug-XML-Compile-WSS [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* David Tindall Mcmath via RT (bug-XML-Compile-WSS@rt.cpan.org) [120831 05:29]: Show quoted text
> Fri Aug 31 01:29:48 2012: Request 79318 was acted upon. > Transaction: Ticket created by mcdave@stanford.edu > Queue: XML-Compile-WSS > Subject: Calling wsseBasicAuth produces something illegible > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79318 > > > > While looking at something else, it seemed that when I called > wsseBasicAuth twice in a row with a "created" element, the second > UsernameToken lacks xmlns:wsu=..., so the Created element can't be > understood.
XML::Compile tries to limit the amount of xmlns declarations, which works better when everything is in one document-literal structure. With all this ugly weaving we have to do here, the counters may get it wrong. This helps: (chance on redundant xmlns's, not dangerous) if($created) { my $createdtype = $schema->findName('wsu:Created' ) ; # If _datetime changes $created into something different, # _that_ is what's going to need to be put into the # digest (if there's a digest). $created = _datetime($created) ; - my $cnode = $schema->writer($createdtype, include_namespaces => 0) + my $cnode = $schema->writer($createdtype, include_namespaces => 1) ->($doc, {_ => $created } ); push @additional, $createdtype => $cnode; } -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
got fixed, some releases ago