def xml(self): self.created = Token.utc() root = Element("Timestamp", ns=WSUNS) created = Element('Created', ns=WSUNS) created.setText(self._trim_to_ms(str(UTC(self.created)))) root.append(created) if self.validity is not None: self.expires = self.created + timedelta(seconds=self.validity) expires = Element('Expires', ns=WSUNS) expires.setText(self._trim_to_ms(str(UTC(self.expires)))) root.append(expires) return root
def setnonce(self, text=None): if text is None: s = [] s.append(self.username) s.append(self.password) s.append(Token.sysdate()) m = md5() m.update(':'.join(s)) self.raw_nonce = m.digest() self.nonce = b64encode(self.raw_nonce) else: self.nonce = text
def setnonce(self, text=None): """ Set I{nonce} which is arbitraty set of bytes to prevent reply attacks. @param text: The nonce text value. Generated when I{None}. @type text: str @override: Nonce save binary string to build digest password """ if text is None: s = [] s.append(self.username) s.append(self.password) s.append(Token.sysdate()) m = md5() m.update(':'.join(s)) self.raw_nonce = m.digest() self.nonce = b64encode(self.raw_nonce) else: self.nonce = text
def setnonce(self, text=None): """ Set I{nonce} which is arbitraty set of bytes to prevent reply attacks. @param text: The nonce text value. Generated when I{None}. @type text: str @override: Nonce save binary string to build digest password """ if text is None: s = [] s.append(self.username) s.append(self.password) s.append(Token.sysdate()) m = md5() m.update(':'.join(s).encode( 'ascii')) ## Python3 change: We we need to encode the value self.raw_nonce = m.digest() self.nonce = b64encode(self.raw_nonce).decode( 'ascii') ## Python3 change: We we need to encode the value else: self.nonce = text
def __init__(self, validity=None): Token.__init__(self) self.validity = validity