<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:D="DAV:" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:st="" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Z="urn:schemas-microsoft-com:"><head><META content="text/html; charset=us-ascii" http-equiv="Content-Type">

<META content="text/html; charset=us-ascii" HTTP-EQUIV="Content-Type">
<meta content="Microsoft Word 12 (filtered medium)" name=Generator>
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head><BODY>
<DIV>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Thanks!  Your approach worked….  I slightly tweaked it…<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>from datetime import timedelta,date,datetime,tzinfo<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>class TimestampToken(Token): <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>  def __init__(self, validity=60):<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      Token.__init__(self)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      self.created = datetime.now()<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      self.expires = self.created+ timedelta(seconds = validity)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>  def xml(self): <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      root = Element("Timestamp", ns = wsuns)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      u = Element('Created', ns = wsuns)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      u.setText(self.created.isoformat())<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      p = Element('Expires', ns =wsuns)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      p.setText(self.expires.isoformat())<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      root.append(u) <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      root.append(p) <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      return root<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>security = Security()<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>token = UsernameToken('MrAardvark','termite101')<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>timetoken=TimestampToken(validity=60)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>security.tokens.append(timetoken)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>security.tokens.append(token)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>client.set_options(wsse=security)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>and got a good header…<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>   <SOAP-ENV:Header><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      <wsse:Security mustUnderstand="true"><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>         <wsu:Timestamp><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>           
<wsu:Created>2009-12-16T16:34:19.099520</wsu:Created><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>           
<wsu:Expires>2009-12-16T16:35:19.099520</wsu:Expires><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>         </wsu:Timestamp><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>         <wsse:UsernameToken><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>            <wsse:Username>MrAardvark</wsse:Username><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>            <wsse:Password>termite101</wsse:Password><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>         </wsse:UsernameToken><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>      </wsse:Security><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>   </SOAP-ENV:Header><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> khalid y
[mailto:kernity@gmail.com] <br>
<b>Sent:</b> Tuesday 15 December 2009 20:17<br>
<b>To:</b> Andrews, Gavin (IDEAS)<br>
<b>Cc:</b> fedora-suds-list@redhat.com<br>
<b>Subject:</b> Re: [Fedora-suds-list] WSSE Expires<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>My solution was to add this
expires like this but I'm not sure it's the best way with the newest version.<br>
<br>
from suds.client import Client<br>
<br>
# I created my own TimestampToken<br>
<br>
class TimestampToken(Token): <br>
  def __init__(self, validity=60):<br>
      Token.__init__(self)<br>
      self.created = datetime.now()<br>
      self.expires = self.created+ timedelta(seconds =
validity)<br>
  def xml(self): <br>
      root = Element("Timestamp", ns =
wsuns)<br>
      u = Element('Created', ns = wsuns)<br>
      u.setText(date.to_iso8601(self.created))<br>
      p = Element('Expires', ns =wsuns)<br>
      p.setText(date.to_iso8601(self.expires))<br>
      root.append(p) <br>
      return root<br>
<br>
url = "<a href="http://127.0.0.1:8080/api/AuthenticationService?wsdl">http://127.0.0.1:8080/api/AuthenticationService?wsdl</a>"<br>
service = Client(url)<br>
security = Security()<br>
# Add your security token here :-) <br>
<br>
######<br>
<br>
timetoken = TimestampToken(validity=60)<br>
security.tokens.append(timetoken)<br>
service.set_options(wsse=security)<br>
<br>
So my service is ready to handle request.<br>
<br>
@+++<o:p></o:p></p>

<div>

<p class=MsoNormal>2009/12/15 Andrews, Gavin <<a href="mailto:Gavin.Andrews@morganstanley.com">Gavin.Andrews@morganstanley.com</a>><o:p></o:p></p>

<div>

<div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I
am trying to perform a SOAP Client call to a server which mandates WSSE
Authentication.<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Creating
<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>   
<wsse:Security mustUnderstand="true"><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>        
<wsse:UsernameToken><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>           
<wsse:Username>username</wsse:Username><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>           
<wsse:Password>password</wsse:Password><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>           
<wsu:Created>2009-12-15T19:01:46.229259</wsu:Created><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>        
</wsse:UsernameToken><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Works
well, but the server still isn’t happy as it requires the wsu:Expires element.<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Is
there a way to add expires into the UsernameToken?<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Thanks
in advance,<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Gavin
<o:p></o:p></p>

</div>

</div>

<div>

<div align=center class=MsoNormal style='text-align:center'>

<hr align=center size=2 width="100%">

</div>

</div>

<p style='margin:0cm;margin-bottom:.0001pt'><span style='font-size:7.5pt;
font-family:"Arial","sans-serif";color:gray'>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.</span><o:p></o:p></p>

</div>

<p class=MsoNormal><br>
_______________________________________________<br>
fedora-suds-list mailing list<br>
<a href="mailto:fedora-suds-list@redhat.com">fedora-suds-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/fedora-suds-list" target="_blank">https://www.redhat.com/mailman/listinfo/fedora-suds-list</a><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p> </o:p></p>

</div>

</DIV>
<DIV>
<HR>
</DIV>
<P CLASS="BulletedList" STYLE="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0in; mso-list: none; tab-stops: .5in"><SPAN STYLE="FONT-SIZE: 8pt; COLOR: gray; mso-bidi-font-family: Arial"><FONT COLOR="gray" FACE="Arial" SIZE="1">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<SPAN STYLE="FONT-SIZE: 7.5pt; COLOR: gray; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-GB; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"> may monitor and store emails to the extent permitted by applicable law.</SPAN></FONT></SPAN></P>
<DIV></DIV></BODY></HTML>