Example #1
0
    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
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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=")
Example #5
0
 def __init__(self, user, passw, dt_diff=None):
     #        Old Style class ... sigh ...
     UsernameDigestToken.__init__(self, user, passw)
     self.dt_diff = dt_diff
Example #6
0
    def __init__(self, user, passw, dt_diff=None) :
#        Old Style class ... sigh ...
        UsernameDigestToken.__init__(self, user, passw)
        self.dt_diff = dt_diff
Example #7
0
    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=")