unpack the username and password for the benefit of the user defined user manager
(self, isession, token)
| 47 | self.user_manager = user_manager |
| 48 | |
| 49 | def check_user_token(self, isession, token): |
| 50 | """ |
| 51 | unpack the username and password for the benefit of the user defined user manager |
| 52 | """ |
| 53 | userName = token.UserName |
| 54 | passwd = token.Password |
| 55 | |
| 56 | # decrypt password is we can |
| 57 | if str(token.EncryptionAlgorithm) != "None": |
| 58 | if use_crypto == False: |
| 59 | return False; |
| 60 | try: |
| 61 | if token.EncryptionAlgorithm == "http://www.w3.org/2001/04/xmlenc#rsa-1_5": |
| 62 | raw_pw = uacrypto.decrypt_rsa15(self.private_key, passwd) |
| 63 | elif token.EncryptionAlgorithm == "http://www.w3.org/2001/04/xmlenc#rsa-oaep": |
| 64 | raw_pw = uacrypto.decrypt_rsa_oaep(self.private_key, passwd) |
| 65 | else: |
| 66 | self.logger.warning("Unknown password encoding '{0}'".format(token.EncryptionAlgorithm)) |
| 67 | return False |
| 68 | length = unpack_from('<I', raw_pw)[0] - len(isession.nonce) |
| 69 | passwd = raw_pw[4:4 + length] |
| 70 | passwd = passwd.decode('utf-8') |
| 71 | except Exception as exp: |
| 72 | self.logger.warning("Unable to decrypt password") |
| 73 | return False |
| 74 | else: |
| 75 | try: |
| 76 | passwd = passwd.decode('utf-8') |
| 77 | except: |
| 78 | self.logger.warning("Unable to decode password") |
| 79 | |
| 80 | # call user_manager |
| 81 | return self.user_manager(isession, userName, passwd) |
no test coverage detected