'Validate the authorization provided in the auth dict. Returns True
when the validation was successfull and False when it was not.'

def _validate_challenges(self, auth):

    for challenge in auth['challenges']:
        if (self.challenge != challenge['type']):
            continue
        uri = challenge['uri']
        token = re.sub('[^A-Za-z0-9_\\-]', '_', challenge['token'])
        keyauthorization = self.account.get_keyauthorization(token)
        challenge_response = {'resource': 'challenge', 'keyAuthorization': keyauthorization}
        (result, info) = self.account.send_signed_request(uri, challenge_response)
        if (info['status'] not in [200, 202]):
            self.module.fail_json(msg='Error    validating    challenge:    CODE:    {0}    RESULT:    {1}'.format(info['status'], result))
    status = ''
    while (status not in ['valid', 'invalid', 'revoked']):
        result = simple_get(self.module, auth['uri'])
        result['uri'] = auth['uri']
        if self._add_or_update_auth(result):
            self.changed = True
        if ('status' not in result):
            status = 'pending'
        else:
            status = result['status']
        time.sleep(2)
    if (status == 'invalid'):
        error_details = ''
        for challenge in result['challenges']:
            if (challenge['status'] == 'invalid'):
                error_details += '    CHALLENGE:    {0}'.format(challenge['type'])
                if ('error' in challenge):
                    error_details += '    DETAILS:    {0};'.format(challenge['error']['detail'])
                else:
                    error_details += ';'
        self.module.fail_json(msg='Authorization    for    {0}    returned    invalid:    {1}'.format(result['identifier']['value'], error_details))
    return (status == 'valid')
