def _init_client(self, wsdl_definition, endpoint): client = Client(wsdl_definition, location=endpoint) security = Security() token = UsernameDigestToken(settings.MODC_DOI_API_ID, settings.MODC_DOI_API_PASSWORD) security.tokens.append(token) client.set_options(wsse=security) return client
def set_wsse(self, user=None, passwd=None): ''' Basic ws-security auth ''' if user: self.user = user if passwd: self.passwd = passwd security = Security() if self.encrypt: token = UsernameDigestToken(self.user, self.passwd) else: token = UsernameToken(self.user, self.passwd) token.setnonce() token.setcreated() security.tokens.append(token) self.ws_client.set_options(wsse=security)
def test_digest_generation(self): token = UsernameDigestToken() token.username = '******' # case 1 token.password = '******' token.nonce = base64.decodestring("8kqcOS9SFYxSRslITbBmlw==") token.created = "2012-10-29T08:18:34.836Z" self.assertEquals(token.generate_digest(), "LOzA3VPv+2hFGOHq8O6gcEXsc/k=") # case 2 token.password = '******' token.nonce = base64.decodestring("m4feQj9DG96uNY1tCoFBnA==") token.created = "2012-10-29T08:49:58.645Z" self.assertEquals(token.generate_digest(), "K80tK4TyuvjuXvMu++O8twrXuTY=") # case 3 token.password = '******' token.nonce = base64.decodestring("MzI2NjYyNzYxMQ==") token.created = "2012-10-29T05:39:24Z" self.assertEquals(token.generate_digest(), "88FDZSIoCwQT9zhMqpcekDvZwVo=")
def __init__(self, user, passw, dt_diff=None): # Old Style class ... sigh ... UsernameDigestToken.__init__(self, user, passw) self.dt_diff = dt_diff
def __init__(self, user, passw, dt_diff=None) : # Old Style class ... sigh ... UsernameDigestToken.__init__(self, user, passw) self.dt_diff = dt_diff