@Override public Mono<List<JWK>> get(JWKSelector jwkSelector) { return Mono.fromCallable(() -> this.source.get(jwkSelector, null)); } }
@Override public Mono<List<JWK>> get(JWKSelector jwkSelector) { return Mono.fromCallable(() -> this.source.get(jwkSelector, null)); } }
@Override public List<Key> selectJWSKeys(final JWSHeader jwsHeader, final C context) throws KeySourceException { if (! jwsAlg.equals(jwsHeader.getAlgorithm())) { // Unexpected JWS alg return Collections.emptyList(); } JWKMatcher jwkMatcher = createJWKMatcher(jwsHeader); if (jwkMatcher == null) { return Collections.emptyList(); } List<JWK> jwkMatches = getJWKSource().get(new JWKSelector(jwkMatcher), context); List<Key> sanitizedKeyList = new LinkedList<>(); for (Key key: KeyConverter.toJavaKeys(jwkMatches)) { if (key instanceof PublicKey || key instanceof SecretKey) { sanitizedKeyList.add(key); } // skip asymmetric private keys } return sanitizedKeyList; } }
@Override public List<Key> selectJWEKeys(final JWEHeader jweHeader, final C context) throws KeySourceException { if (! jweAlg.equals(jweHeader.getAlgorithm()) || ! jweEnc.equals(jweHeader.getEncryptionMethod())) { // Unexpected JWE alg or enc return Collections.emptyList(); } JWKMatcher jwkMatcher = createJWKMatcher(jweHeader); List<JWK> jwkMatches = getJWKSource().get(new JWKSelector(jwkMatcher), context); List<Key> sanitizedKeyList = new LinkedList<>(); for (Key key: KeyConverter.toJavaKeys(jwkMatches)) { if (key instanceof PrivateKey || key instanceof SecretKey) { sanitizedKeyList.add(key); } // skip public keys } return sanitizedKeyList; } }