Пример #1
0
    def do_login(self):
        assert isinstance(self.config['device'].get(), basestring)
        assert isinstance(self.config['enable_twofactors'].get(), bool)
        if not self.password.isalnum():
            raise BrowserIncorrectPassword()

        if self.auth_token and self.config['pin_code'].get():
            self.page.authenticate()
        else:
            for _ in range(3):
                self.login.go()
                try:
                    self.page.login(self.username, self.password)
                except VirtKeyboardError:
                    self.logger.error('Failed to process VirtualKeyboard')
                else:
                    break
            else:
                raise VirtKeyboardError()

            if self.login.is_here() or self.error.is_here():
                raise BrowserIncorrectPassword()

            # After login, we might be redirected to the two factor authentication page.
            self.handle_authentication()

        if self.authentication.is_here():
            raise BrowserIncorrectAuthenticationCode('Invalid PIN code')
Пример #2
0
 def get_symbol_code(self, md5sum_list):
     for md5sum in md5sum_list:
         try:
             code = MappedVirtKeyboard.get_symbol_code(self, md5sum)
         except VirtKeyboardError:
             continue
         else:
             return ''.join(re.findall(r"'(\d+)'", code)[-2:])
     raise VirtKeyboardError('Symbol not found')
Пример #3
0
 def get_code(self, password):
     code = ''
     for i, d in enumerate(password):
         if i > 0:
             code += '|'
         try:
             code += self.md5[self.symbols[d]]
         except KeyError:
             raise VirtKeyboardError()
     return code