Get keys from this key jar based on information in a JWS. These keys
        should be usable to verify the signed JWT.

        :param jwt: A cryptojwt.jwt.JWT instance
        :param kwargs: Other key word arguments
        :return: list of usable keys
196801
def get_jwt_verify_keys(self, jwt, **kwargs):
        

        try:
            allow_missing_kid = kwargs['allow_missing_kid']
        except KeyError:
            allow_missing_kid = False

        try:
            _key_type = jws_alg2keytype(jwt.headers['alg'])
        except KeyError:
            _key_type = ''

        try:
            _kid = jwt.headers['kid']
        except KeyError:
            logger.info('Missing kid')
            _kid = ''

        try:
            nki = kwargs['no_kid_issuer']
        except KeyError:
            nki = {}

        _payload = jwt.payload()

        try:
            _iss = _payload['iss']
        except KeyError:
            try:
                _iss = kwargs['iss']
            except KeyError:
                _iss = ''

        if _iss:
            # First extend the key jar iff allowed
            if "jku" in jwt.headers and _iss:
                if not self.find(jwt.headers["jku"], _iss):
                    # This is really questionable
                    try:
                        if kwargs["trusting"]:
                            self.add_url(_iss, jwt.headers["jku"])
                    except KeyError:
                        pass

            keys = self._add_key([], _iss, 'sig', _key_type,
                                 _kid, nki, allow_missing_kid)

            if _key_type == 'oct':
                keys.extend(self.get(key_use='sig', owner='',
                                     key_type=_key_type))
        else:  # No issuer, just use all keys I have
            keys = self.get(key_use='sig', owner='', key_type=_key_type)

        # Only want the appropriate keys.
        keys = [k for k in keys if k.appropriate_for('verify')]
        return keys
287138
def _get_signature(self):
        

        keys = list(self.params.keys())

        keys.sort()

        string = ""

        for name in keys:
            string += name
            string += self.params[name]

        string += self.api_secret

        return md5(string)
72010
def unsign_jwt(token, secret_key, salt=None, **kw):
    
    s = itsdangerous.TimedJSONWebSignatureSerializer(secret_key, salt=salt, **kw)
    return s.loads(token)
884802
public static String getJwt(JwtClaims claims) throws JoseException {
        String jwt;
        RSAPrivateKey privateKey = (RSAPrivateKey) getPrivateKey(
                jwtConfig.getKey().getFilename(), (String)secretConfig.get(JWT_PRIVATE_KEY_PASSWORD), jwtConfig.getKey().getKeyName());

        // A JWT is a JWS and/or a JWE with JSON claims as the payload.
        // In this example it is a JWS nested inside a JWE
        // So we first create a JsonWebSignature object.
        JsonWebSignature jws = new JsonWebSignature();

        // The payload of the JWS is JSON content of the JWT Claims
        jws.setPayload(claims.toJson());

        // The JWT is signed using the sender's private key
        jws.setKey(privateKey);

        // Get provider from security config file, it should be two digit
        // And the provider id will set as prefix for keyid in the token header, for example: 05100
        // if there is no provider id, we use "00" for the default value
        String provider_id = "";
        if (jwtConfig.getProviderId() != null) {
            provider_id = jwtConfig.getProviderId();
            if (provider_id.length() == 1) {
                provider_id = "0" + provider_id;
            } else if (provider_id.length() > 2) {
                logger.error("provider_id defined in the security.yml file is invalid; the length should be 2");
                provider_id = provider_id.substring(0, 2);
            }
        }
        jws.setKeyIdHeaderValue(provider_id + jwtConfig.getKey().getKid());

        // Set the signature algorithm on the JWT/JWS that will integrity protect the claims
        jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.RSA_USING_SHA256);

        // Sign the JWS and produce the compact serialization, which will be the inner JWT/JWS
        // representation, which is a string consisting of three dot ('.') separated
        // base64url-encoded parts in the form Header.Payload.Signature
        jwt = jws.getCompactSerialization();
        return jwt;
    }
892990
def get_keys(self, models, key=None):
        
        return list(set(map(lambda value: value.get_attribute(key) if key else value.get_key(), models)))
891006
def _jws_header(keyid, algorithm):
    """"""
    data = {
        'typ': 'JWT',
        'alg': algorithm.name,
        # 'kid' is used to indicate the public part of the key
        # used during signing.
        'kid': keyid
    }

    datajson = json.dumps(data, sort_keys=True).encode('utf8')
    return base64url_encode(datajson)
976991
async def get_signing_key(self, verkey: str) -> KeyInfo:
        

        LOGGER.debug('Wallet.get_signing_key >>> seed: [SEED], verkey: %s', verkey)

        if not self.handle:
            LOGGER.debug('Wallet.get_signing_key <!< Wallet %s is closed', self.name)
            raise WalletState('Wallet {} is closed'.format(self.name))

        try:
            metadata = await crypto.get_key_metadata(self.handle, verkey)
        except IndyError as x_indy:
            if x_indy.error_code == ErrorCode.WalletItemNotFound:
                LOGGER.debug('Wallet.get_signing_key <!< Verification key %s not in wallet %s', verkey, self.name)
                raise AbsentRecord('Verification key not in wallet {}'.format(self.name))
            LOGGER.debug('Wallet.get_signing_key <!< indy-sdk raised error %s', x_indy.error_code)
            raise

        rv = KeyInfo(verkey, json.loads(metadata) if metadata else {})
        LOGGER.debug('Wallet.get_signing_key <<< %s', rv)
        return rv
444749
def load(jwks):
    """"""
    sign_keys = {}
    verify_keys = {}
    try:
        keyset = json.loads(jwks)
        for key in keyset['keys']:
            for op in key['key_ops']:
                if op == 'sign':
                    k = sign_keys
                elif op == 'verify':
                    k = verify_keys
                else:
                    raise JWKError("Unsupported key operation: {}".format(op))
                if key['kty'] == 'oct':
                    k[key['kid']] = _Key(alg=key['alg'], key=base64.urlsafe_b64decode(key['k']))
                elif key['kty'] == 'EC':
                    alg, ec_key = _load_ecdsa(key, op == 'verify')
                    k[key['kid']] = _Key(alg=alg, key=ec_key)
                else:
                    raise JWKError("Unsupported key type: {}".format(key['kty']))
    except (KeyError, json.JSONDecodeError) as e:
        raise JWKError() from e
    keys = _KeySet(signers=MappingProxyType(sign_keys), verifiers=MappingProxyType(verify_keys))
    return keys
225110
def get_jwt_key_data():
    
    global __jwt_data

    if __jwt_data:
        return __jwt_data

    from cloud_inquisitor import config_path
    from cloud_inquisitor.config import dbconfig

    jwt_key_file = dbconfig.get('jwt_key_file_path', default='ssl/private.key')
    if not os.path.isabs(jwt_key_file):
        jwt_key_file = os.path.join(config_path, jwt_key_file)

    with open(os.path.join(jwt_key_file), 'r') as f:
        __jwt_data = f.read()

    return __jwt_data
423263
def info(self, token):
        
        verifier = JWT(key_jar=self.key_jar, allowed_sign_algs=[self.alg])
        _payload = verifier.unpack(token)
        if is_expired(_payload['exp']):
            raise ToOld('Token has expired')
        return _payload['sid'], _payload['ttype']
659214
def get_jwt(self, request):
        
        try:
            authorization = request.authorization
        except ValueError:
            return None
        if authorization is None:
            return None
        authtype, token = authorization
        if authtype.lower() != self.auth_header_prefix.lower():
            return None
        return token
642690
Key getSigningKey(JwtConsumerConfig config, JwtContext jwtContext, Map properties) throws KeyException {
		Key signingKey = null;
		if (config == null) {
			if (tc.isDebugEnabled()) {
				Tr.debug(tc, "JWT consumer config object is null");
			}
			return null;
		}
		signingKey = getSigningKeyBasedOnSignatureAlgorithm(config, jwtContext, properties);
		if (signingKey == null) {
			if (tc.isDebugEnabled()) {
				Tr.debug(tc, "A signing key could not be found");
			}
		}
		return signingKey;
	}
241145
def sign(jwk, jws = nil, header = nil)
      plain_text = to_binary
      if jws.nil?
        jwk = JOSE::JWK.from(jwk)
        jws = jwk.signer
      end
      jws = JOSE::JWS.from(jws).to_map
      if not jws.has_key?('typ')
        jws = jws.put('typ', 'JWT')
      end
      return JOSE::JWK.sign(plain_text, jws, jwk, header)
    end
881261
def to_jwt(self, algorithm=None, ttl=None):
        

        if not self.secret_key:
            raise ValueError('JWT does not have a signing key configured.')

        headers = self.headers.copy()
        if algorithm:
            headers['alg'] = algorithm
        algorithm = algorithm or self.algorithm

        payload = self.payload.copy()
        if ttl:
            payload['exp'] = int(time.time()) + ttl

        return jwt_lib.encode(payload, self.secret_key, algorithm=algorithm, headers=headers)
1023792
def getAPIKey(self, keyID=None):
        
        kcfg = self.getKeyConfig(keyID)
        if 'key' not in kcfg:
            raise ConfigException('invalid config: missing api key')
        return kcfg['key']
21534
def jwt_decode_token(token):
    
    try:
        return decode(
            token,
            current_app.config['ACCOUNTS_JWT_SECRET_KEY'],
            algorithms=[
                current_app.config['ACCOUNTS_JWT_ALOGORITHM']
            ]
        )
    except DecodeError as exc:
        raise_from(JWTDecodeError(), exc)
    except ExpiredSignatureError as exc:
        raise_from(JWTExpiredToken(), exc)
197616
def get_payload_data(self, token, key):
        """"""
        if self.get_settings('OIDC_ALLOW_UNSECURED_JWT', False):
            header, payload_data, signature = token.split(b'.')
            header = json.loads(smart_text(b64decode(header)))

            # If config allows unsecured JWTs check the header and return the decoded payload
            if 'alg' in header and header['alg'] == 'none':
                return b64decode(payload_data)

        # By default fallback to verify JWT signatures
        return self._verify_jws(token, key)