Exemple #1
0
 def xml(self):
     root = Element("Timestamp", ns=wsuns)
     created = Element('Created', ns=wsuns)
     created.setText(str(UTC(self.created)))
     expires = Element('Expires', ns=wsuns)
     expires.setText(str(UTC(self.expires)))
     root.append(created)
     root.append(expires)
     return root
Exemple #2
0
 def xml(self):
     root = Element("Timestamp", ns=wsuns)
     # xsd:datetime format does not have fractional seconds
     created = Element('Created', ns=wsuns)
     created.setText(
         str(
             UTC(self.created -
                 timedelta(microseconds=self.created.microsecond))))
     expires = Element('Expires', ns=wsuns)
     expires.setText(
         str(
             UTC(self.expires -
                 timedelta(microseconds=self.expires.microsecond))))
     root.append(created)
     root.append(expires)
     return root
Exemple #3
0
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('UsernameToken', ns=wssens)
     u = Element('Username', ns=wssens)
     u.setText(self.username)
     root.append(u)
     p = Element('Password', ns=wssens)
     p.setText(self.password)
     root.append(p)
     if self.nonce is not None:
         n = Element('Nonce', ns=wssens)
         n.setText(self.nonce)
         root.append(n)
     if self.created is not None:
         n = Element('Created', ns=wsuns)
         n.setText(
             str(
                 UTC(self.created -
                     timedelta(microseconds=self.created.microsecond))))
         root.append(n)
     return root
Exemple #4
0
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('UsernameToken', ns=wssens)
     u = Element('Username', ns=wssens)
     u.setText(self.username)
     root.append(u)
     p = Element('Password', ns=wssens)
     p.setText(self.password)
     p.set(
         'Type', 'http://docs.oasis-open.org/wss/2004/01/'
         'oasis-200401-wss-username-token-profile-1.0#' +
         ('PasswordDigest' if self.digest else 'PasswordText'))
     root.append(p)
     if self.nonce is not None:
         n = Element('Nonce', ns=wssens)
         if self.digest:
             n.set(
                 'EncodingType', 'http://docs.oasis-open.org/wss/2004'
                 '/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'
             )
             n.setText(b64encode(self.nonce))
         else:
             n.setText(self.nonce)
         root.append(n)
     if self.created is not None:
         n = Element('Created', ns=wsuns)
         n.setText(str(UTC(self.created)))
         root.append(n)
     return root
Exemple #5
0
 def __init__(self, username=None, password=None, digest=False):
     """
     @param username: A username.
     @type username: str
     @param password: A password.
     @type password: str
     @param digest: Enables digest generation.
     @type digest: bool
     """
     Token.__init__(self)
     self.username = username
     self.password = password
     self.digest = digest
     if digest:
         self.setnonce()
         self.setcreated()
         m = sha1()
         m.update(self.nonce)
         m.update(str(UTC(self.created)))
         m.update(password)
         self.password = b64encode(m.digest())
     else:
         self.nonce = None
         self.created = None
 def setcreated(self, *args, **kwargs):
     UsernameToken.setcreated(self, *args, **kwargs)
     if is_debian_based:
         self.created = str(self.created.replace(tzinfo=UtcTimezone()))
     else:
         self.created = str(UTC(self.created))
Exemple #7
0
 def sysdate(cls):
     utc = UTC()
     return str(utc)
Exemple #8
0
 def setcreated(self, *args, **kwargs):
     dt_adjusted = None
     if self.dt_diff:
         dt_adjusted = (self.dt_diff + dt.datetime.utcnow())
     UsernameToken.setcreated(self, dt=dt_adjusted, *args, **kwargs)
     self.created = str(UTC(self.created))