Validates that we can only authenticate to one S3 and one GCS.
494916
def validate_stores_secrets_keys(stores_secrets):
        """"""
        stores = set([])
        for store_secret in stores_secrets:
            if store_secret['store'] in stores:
                raise TensorboardValidation('Received an invalid store configuration.')
            elif store_secret['store'] not in {GCS, S3}:
                raise TensorboardValidation('Received an unsupported store configuration.')
            stores.add(store_secret['store'])
527317
def validate_session(self, client, session):
        
        if session:
            if session._client is not client:
                raise InvalidOperation(
                    'Can only use session with the MongoClient that'
                    ' started it')
            if session._authset != self.authset:
                raise InvalidOperation(
                    'Cannot use session after authenticating with different'
                    ' credentials')
409591
def validate(self, pA, pB):
        
        if pA in pB.links or \
           pB in pA.links:
            raise Exception('Already linked')
        dA = pA.domains()
        dB = pB.domains()
        for d in dA:
            if d in dB:
                raise Exception('Duplicate domain "%s" found' % d)
        for d in dB:
            if d in dA:
                raise Exception('Duplicate domain "%s" found' % d)
        kA = pA.keys()
        kB = pB.keys()
        for k in kA:
            if k in kB:
                raise Exception('Duplicate key %s found' % k)
        for k in kB:
            if k in kA:
                raise Exception('Duplicate key %s found' % k)
        return self
459341
def validate_keys(self):
        
        url = 'https://api.twitter.com/1.1/account/verify_credentials.json'

        keys_present = self.consumer_key and self.consumer_secret and \
                       self.access_token and self.access_token_secret

        if keys_present:
            try:
                # Need to explicitly reconnect to confirm the current creds
                # are used in the session object.
                self.connect()
                self.get(url)
            except requests.HTTPError as e:
                if e.response.status_code == 401:
                    raise RuntimeError('Invalid credentials provided.')
                else:
                    raise e
        else:
            raise RuntimeError('Incomplete credentials provided.')
137762
def validate(self, r):
        '''
        
        '''
        if self.show_invalid:
            r.valid = True
        elif r.valid:
            if not r.description:
                r.valid = False

            if r.size and (r.size + r.offset) > r.file.size:
                r.valid = False

            if r.jump and (r.jump + r.offset) > r.file.size:
                r.valid = False

            if hasattr(r, "location") and (r.location != r.offset):
                r.valid = False

        if r.valid:
            # Don't keep displaying signatures that repeat a bunch of times
            # (e.g., JFFS2 nodes)
            if r.id == self.one_of_many:
                r.display = False
            elif r.many:
                self.one_of_many = r.id
            else:
                self.one_of_many = None
223794
def validate_proof(self, proof, target_hash, merkle_root):
        
        return validate_proof(proof, target_hash, merkle_root, self.hash_f)
1033048
def authenticate_storage(client_secrets, read_only=False):
    """"""
    if read_only:
        scopes = ['https://www.googleapis.com/auth/devstorage.read_only']
    else:
        scopes = ['https://www.googleapis.com/auth/devstorage.read_write']

    credentials = service_account.Credentials.from_service_account_info(
            client_secrets)
    
    scoped_credentials = credentials.with_scopes(scopes)
    
    return scoped_credentials
396714
def ensure_cfn_bucket(self):
        """"""
        if self.bucket_name:
            ensure_s3_bucket(self.s3_conn,
                             self.bucket_name,
                             self.bucket_region)
30982
def validate(self, attrs):
        
        user = authenticate(**self.user_credentials(attrs))

        if user:
            if user.is_active:
                self.instance = user
            else:
                raise serializers.ValidationError(_("This account is currently inactive."))
        else:
            error = _("Invalid login credentials.")
            raise serializers.ValidationError(error)
        return attrs
1127936
def validate_proof(proof, target_hash, merkle_root, hash_f=sha256):
    

    if not proof:
        # no siblings, single item tree, so the hash should also be the root
        return target_hash == merkle_root

    target_hash = get_buffer(target_hash)
    merkle_root = get_buffer(merkle_root)

    proof_hash = target_hash
    for x in proof:
        if 'left' in x:
            # then the sibling is a left node
            proof_hash = get_buffer(hash_f(get_buffer(x['left']) + proof_hash))
        elif 'right' in x:
            # then the sibling is a right node
            proof_hash = get_buffer(hash_f(proof_hash + get_buffer(x['right'])))
        else:
            # no left or right designation exists, proof is invalid
            return False

    return hexlify(proof_hash) == hexlify(merkle_root)
913748
public boolean isAuthorizationRequired(int statusCode, Map<String, List<String>> headers) {

        if (headers.containsKey(WWW_AUTHENTICATE_HEADER_NAME)){
            String authHeader = headers.get(WWW_AUTHENTICATE_HEADER_NAME).get(0);
            return AuthorizationHeaderHelper.isAuthorizationRequired(statusCode, authHeader);
        } else {
            return false;
        }
    }
77622
def validate_account_id(sts_client, account_id):
    """"""
    resp = sts_client.get_caller_identity()
    if 'Account' in resp:
        if resp['Account'] == account_id:
            LOGGER.info('Verified current AWS account matches required '
                        'account id %s.',
                        account_id)
        else:
            LOGGER.error('Current AWS account %s does not match '
                         'required account %s in Runway config.',
                         resp['Account'],
                         account_id)
            sys.exit(1)
    else:
        LOGGER.error('Error checking current account ID')
        sys.exit(1)
650996
def failover_limitation(self):
        """"""
        if not self.reachable:
            return 'not reachable'
        if self.tags.get('nofailover', False):
            return 'not allowed to promote'
        if self.watchdog_failed:
            return 'not watchdog capable'
        return None
16962
def _validate_auths(self, path, obj, app):
        
        errs = []

        for k, v in six.iteritems(obj.authorizations or {}):
            if k not in app.raw.authorizations:
                errs.append('auth {0} not found in resource list'.format(k))

            if app.raw.authorizations[k].type in ('basicAuth', 'apiKey') and v != []:
                errs.append('auth {0} should be an empty list'.format(k))

        return path, obj.__class__.__name__, errs
849691
public boolean validate(OneKey cnKey) throws CoseException {
        CBORObject obj = CBORObject.NewArray();
        obj.Add(contextString);
        if (objProtected.size() > 0) obj.Add(rgbProtected);
        else obj.Add(CBORObject.FromObject(new byte[0]));
        obj.Add(externalData);
        obj.Add(rgbContent);
        return validateSignature(obj.EncodeToBytes(), rgbSignature, cnKey);
    }
1332571
private function validateDifferentPreviousOne(): bool
    {
        if ($this->options['require-different-than-previous-one'] === true) {
            if (isset($this->options['stored-passwords'][0])) {
                $passwordHash = (string)$this->value;
                if (PasswordEnctyption::compare($passwordHash, $this->options['stored-passwords'][0])) {
                    $this->setError(self::VALIDATOR_ERROR_PASSWORD_MUST_BE_DIFFERENT_THAN_PREVIOUS_ONE);
                    return false;
                }
            }
        }
        return true;
    }
464016
def _validate_auth(self, path, obj, _):
        
        errs = []

        if obj.type == 'apiKey':
            if not obj.passAs:
                errs.append('need "passAs" for apiKey')
            if not obj.keyname:
                errs.append('need "keyname" for apiKey')

        elif obj.type == 'oauth2':
            if not obj.grantTypes:
                errs.append('need "grantTypes" for oauth2')

        return path, obj.__class__.__name__, errs