Пример #1
0
    def get(self, private_id, public_id):
        try:
            exists = False
            db_data = yield self.cass.get_slice(key=private_id,
                                                column_family=config.PUBLIC_IDS_TABLE,
                                                start=public_id,
                                                finish=public_id)
            for column in db_data:
                if column.column.name == public_id:
                    exists = True
            if not exists:
                raise NotFoundException()
            encrypted_hash = yield self.cass.get(column_family=self.table,
                                                 key=private_id,
                                                 column=self.column)
            digest = utils.decrypt_password(encrypted_hash.column.value,
                                            settings.PASSWORD_ENCRYPTION_KEY)
        except NotFoundException, e:
            if not settings.HSS_ENABLED:
                raise HTTPError(httplib.NOT_FOUND)

            # Either the digest or the association doesn't exist in the DB, attempt an
            # import from the HSS
            try:
                digest = yield self.application.hss_gateway.get_digest(private_id, public_id)
                public_ids = yield self.application.hss_gateway.get_public_ids(private_id, public_id)
            except HSSNotFound, e:
                raise HTTPError(httplib.NOT_FOUND)
Пример #2
0
    def get(self, private_id, public_id):
        try:
            exists = False
            db_data = yield self.ha_get_slice(key=private_id,
                                              column_family=config.PUBLIC_IDS_TABLE,
                                              start=public_id,
                                              finish=public_id)
            for column in db_data:
                if column.column.name == public_id:
                    exists = True
            if not exists:
                raise NotFoundException()
            encrypted_hash = yield self.ha_get(column_family=self.table,
                                               key=private_id,
                                               column=self.column)
            digest = utils.decrypt_password(encrypted_hash.column.value,
                                            settings.PASSWORD_ENCRYPTION_KEY)
        except NotFoundException, e:
            if not settings.HSS_ENABLED:
                raise HTTPError(httplib.NOT_FOUND)

            # Either the digest or the association doesn't exist in the DB, attempt an
            # import from the HSS
            try:
                digest = yield self.application.hss_gateway.get_digest(private_id, public_id)
                public_ids = yield self.application.hss_gateway.get_public_ids(private_id, public_id)
            except HSSNotFound, e:
                raise HTTPError(httplib.NOT_FOUND)
Пример #3
0
 def test_encrypt_password(self):
     a = encrypt_password(u"foo", "bar")
     b = encrypt_password(u"foo", "bar")
     self.assertTrue(b[0] == a[0] == 'b')
     self.assertNotEqual(a, b)
     self.assertNotEqual(a, "foo")
     ad = decrypt_password(unicode(a), "bar")
     bd = decrypt_password(b, "bar")
     self.assertEquals(ad, u"foo")
     self.assertEquals(bd, u"foo")
     try:
         bdw = decrypt_password(b, "bar2")
     except:
         # May fail to decode the unicode.
         pass
     else:
         self.assertNotEqual(bdw, "foo")
Пример #4
0
 def test_encrypt_password(self):
     a = encrypt_password(u"foo", "bar")
     b = encrypt_password(u"foo", "bar")
     self.assertTrue(b[0] == a[0] == 'b')
     self.assertNotEqual(a, b)
     self.assertNotEqual(a, "foo")
     ad = decrypt_password(unicode(a), "bar")
     bd = decrypt_password(b, "bar")
     self.assertEquals(ad, u"foo")
     self.assertEquals(bd, u"foo")
     try:
         bdw = decrypt_password(b, "bar2")
     except:
         # May fail to decode the unicode.
         pass
     else:
         self.assertNotEqual(bdw, "foo")
Пример #5
0
 def get(self, private_id):
     try:
         encrypted_hash = yield self.cass.get(column_family=self.table,
                                              key=private_id,
                                              column=self.column)
         digest = utils.decrypt_password(encrypted_hash.column.value,
                                         settings.PASSWORD_ENCRYPTION_KEY)
     except NotFoundException, e:
         raise HTTPError(httplib.NOT_FOUND)
Пример #6
0
 def get(self, private_id):
     try:
         encrypted_hash = yield self.ha_get(column_family=self.table,
                                            key=private_id,
                                            column=self.column)
         digest = utils.decrypt_password(encrypted_hash.column.value,
                                         settings.PASSWORD_ENCRYPTION_KEY)
     except NotFoundException, e:
         raise HTTPError(httplib.NOT_FOUND)