Package com.nimbusds.jose.proc
Class JWSAlgorithmFamilyJWSKeySelector<C extends SecurityContext>
java.lang.Object
com.nimbusds.jose.proc.JWSAlgorithmFamilyJWSKeySelector<C>
- All Implemented Interfaces:
JWSKeySelector<C>
public class JWSAlgorithmFamilyJWSKeySelector<C extends SecurityContext>
extends Object
implements JWSKeySelector<C>
A
JWSKeySelector that expects an algorithm from a specified
algorithm family.- Since:
- 2019-07-12
- Author:
- Josh Cummings
-
Constructor Summary
ConstructorsConstructorDescriptionJWSAlgorithmFamilyJWSKeySelector(JWSAlgorithm.Family jwsAlgFamily, JWKSource<C> jwkSource) Creates aJWSKeySelectorthat matches any algorithm from the givenJWSAlgorithm.Family. -
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends SecurityContext>
JWSAlgorithmFamilyJWSKeySelector<C>fromJWKSetURL(URL jwkSetURL) Queries the given JWK SetURLfor keys, creating aJWSAlgorithmFamilyJWSKeySelectorbased on the RSA or EC key type, whichever comes back first.static <C extends SecurityContext>
JWSAlgorithmFamilyJWSKeySelector<C>fromJWKSource(JWKSource<C> jwkSource) Queries the givenJWKSourcefor keys, creating aJWSAlgorithmFamilyJWSKeySelectorbased on the RSA or EC key type, whichever comes back first.Returns the JWK source.selectJWSKeys(JWSHeader header, C context) Selects key candidates for verifying a JWS object.
-
Constructor Details
-
JWSAlgorithmFamilyJWSKeySelector
Creates aJWSKeySelectorthat matches any algorithm from the givenJWSAlgorithm.Family.- Parameters:
jwsAlgFamily- TheJWSAlgorithm.Familyto use.jwkSource- TheJWKSourcefrom which to draw the set ofJWKs.
-
-
Method Details
-
selectJWSKeys
Description copied from interface:JWSKeySelectorSelects key candidates for verifying a JWS object.- Specified by:
selectJWSKeysin interfaceJWSKeySelector<C extends SecurityContext>- Parameters:
header- The header of the JWS object. Must not benull.context- Optional context,nullif not required.- Returns:
- The key candidates in trial order, empty list if none.
- Throws:
KeySourceException- If a key sourcing exception is encountered, e.g. on remote JWK retrieval.
-
fromJWKSetURL
public static <C extends SecurityContext> JWSAlgorithmFamilyJWSKeySelector<C> fromJWKSetURL(URL jwkSetURL) throws KeySourceException Queries the given JWK SetURLfor keys, creating aJWSAlgorithmFamilyJWSKeySelectorbased on the RSA or EC key type, whichever comes back first.- Type Parameters:
C- TheSecurityContext- Parameters:
jwkSetURL- The JWK SetURLto query.- Returns:
- An instance of
JWSAlgorithmFamilyJWSKeySelector. - Throws:
KeySourceException- if the JWKs cannot be retrieved or no RSA or EC public JWKs are found.
-
fromJWKSource
public static <C extends SecurityContext> JWSAlgorithmFamilyJWSKeySelector<C> fromJWKSource(JWKSource<C> jwkSource) throws KeySourceException Queries the givenJWKSourcefor keys, creating aJWSAlgorithmFamilyJWSKeySelectorbased on the RSA or EC key type, whichever comes back first.- Type Parameters:
C- TheSecurityContext.- Parameters:
jwkSource- TheJWKSource.- Returns:
- An instance of
JWSAlgorithmFamilyJWSKeySelector. - Throws:
KeySourceException- If the JWKs cannot be retrieved or no RSA or EC public JWKs are found.
-
getJWKSource
Returns the JWK source.- Returns:
- The JWK source.
-