[Fedora-suds-list] WSSE Expires

khalid y kernity at gmail.com
Thu Dec 17 09:01:23 UTC 2009


You are welcome :-)

2009/12/16 Andrews, Gavin <Gavin.Andrews at morganstanley.com>

>   Thanks!  Your approach worked….  I slightly tweaked it…
>
>
>
> from datetime import timedelta,date,datetime,tzinfo
>
>
>
> class TimestampToken(Token):
>
>   def __init__(self, validity=60):
>
>       Token.__init__(self)
>
>       self.created = datetime.now()
>
>       self.expires = self.created+ timedelta(seconds = validity)
>
>   def xml(self):
>
>       root = Element("Timestamp", ns = wsuns)
>
>       u = Element('Created', ns = wsuns)
>
>       u.setText(self.created.isoformat())
>
>       p = Element('Expires', ns =wsuns)
>
>       p.setText(self.expires.isoformat())
>
>       root.append(u)
>
>       root.append(p)
>
>       return root
>
>
>
> security = Security()
>
> token = UsernameToken('MrAardvark','termite101')
>
> timetoken=TimestampToken(validity=60)
>
> security.tokens.append(timetoken)
>
> security.tokens.append(token)
>
>
>
> client.set_options(wsse=security)
>
>
>
> and got a good header…
>
>
>
>    <SOAP-ENV:Header>
>
>       <wsse:Security mustUnderstand="true">
>
>          <wsu:Timestamp>
>
>             <wsu:Created>2009-12-16T16:34:19.099520</wsu:Created>
>
>             <wsu:Expires>2009-12-16T16:35:19.099520</wsu:Expires>
>
>          </wsu:Timestamp>
>
>          <wsse:UsernameToken>
>
>             <wsse:Username>MrAardvark</wsse:Username>
>
>             <wsse:Password>termite101</wsse:Password>
>
>          </wsse:UsernameToken>
>
>       </wsse:Security>
>
>    </SOAP-ENV:Header>
>
>
>
> *From:* khalid y [mailto:kernity at gmail.com]
> *Sent:* Tuesday 15 December 2009 20:17
> *To:* Andrews, Gavin (IDEAS)
> *Cc:* fedora-suds-list at redhat.com
>
> *Subject:* Re: [Fedora-suds-list] WSSE Expires
>
>
>
> My solution was to add this expires like this but I'm not sure it's the
> best way with the newest version.
>
>
> from suds.client import Client
>
> # I created my own TimestampToken
>
> class TimestampToken(Token):
>   def __init__(self, validity=60):
>       Token.__init__(self)
>       self.created = datetime.now()
>       self.expires = self.created+ timedelta(seconds = validity)
>   def xml(self):
>       root = Element("Timestamp", ns = wsuns)
>       u = Element('Created', ns = wsuns)
>       u.setText(date.to_iso8601(self.created))
>       p = Element('Expires', ns =wsuns)
>       p.setText(date.to_iso8601(self.expires))
>       root.append(p)
>       return root
>
> url = "http://127.0.0.1:8080/api/AuthenticationService?wsdl"
> service = Client(url)
> security = Security()
> # Add your security token here :-)
>
> ######
>
> timetoken = TimestampToken(validity=60)
> security.tokens.append(timetoken)
> service.set_options(wsse=security)
>
> So my service is ready to handle request.
>
> @+++
>
> 2009/12/15 Andrews, Gavin <Gavin.Andrews at morganstanley.com>
>
> I am trying to perform a SOAP Client call to a server which mandates WSSE
> Authentication.
>
>
>
> Creating
>
>
>
>     <wsse:Security mustUnderstand="true">
>
>          <wsse:UsernameToken>
>
>             <wsse:Username>username</wsse:Username>
>
>             <wsse:Password>password</wsse:Password>
>
>             <wsu:Created>2009-12-15T19:01:46.229259</wsu:Created>
>
>          </wsse:UsernameToken>
>
>
>
> Works well, but the server still isn’t happy as it requires the wsu:Expires
> element.
>
>
>
> Is there a way to add expires into the UsernameToken?
>
>
>
> Thanks in advance,
>
> Gavin
>   ------------------------------
>
> NOTICE: If received in error, please destroy, and notify sender. Sender
> does not intend to waive confidentiality or privilege. Use of this email is
> prohibited when received in error. We may monitor and store emails to the
> extent permitted by applicable law.
>
>
> _______________________________________________
> fedora-suds-list mailing list
> fedora-suds-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-suds-list
>
>
>   ------------------------------
>
> NOTICE: If received in error, please destroy, and notify sender. Sender
> does not intend to waive confidentiality or privilege. Use of this email is
> prohibited when received in error. We may monitor and store emails to the
> extent permitted by applicable law.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/suds/attachments/20091217/081dd02d/attachment.html 


More information about the suds mailing list