@staticmethod
    def verify(encoded, allowed_users):
        """
        Verify that `encoded` is a valid encoded credentials object and that
        its public key matches the public key we've already seen, if any.

        encoded: tuple
            Encoded credentials.

        allowed_users: dict
            Dictionary of users and corresponding public keys allowed access.
            If None, any user may access. If empty, no user may access.

        Returns :class:`Credentials` object from `encoded`.
        """
        data, signature, client_creds = encoded
        key = (data, signature)
        try:
            credentials = _VERIFY_CACHE[key]
        except __HOLE__:
            credentials = Credentials(encoded)
            user = credentials.user
            for cred in _VERIFY_CACHE.values():
                if cred.user == user:
                    raise CredentialsError('Public key mismatch for %r' % user)
            else:
                _VERIFY_CACHE[key] = credentials

        if allowed_users is not None:
            try:
                pubkey = allowed_users[credentials.user]
            except KeyError:
                raise CredentialsError('User %r not in allowed_users' \
                                       % credentials.user)
            else:
                if (credentials.public_key.e != pubkey.e) or \
                   (credentials.public_key.n != pubkey.n):
                    raise CredentialsError('Allowed user mismatch for %r' \
                                           % credentials.user)

        credentials.client_creds = client_creds
        credentials.remote = True
        return credentials
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/rbac.py/Credentials.verify