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>
AJWSKeySelectorthat expects an algorithm from a specified algorithm family.- Since:
- 2019-07-12
- Author:
- Josh Cummings
-
-
Constructor Summary
Constructors Constructor Description JWSAlgorithmFamilyJWSKeySelector(JWSAlgorithm.Family jwsAlgFamily, JWKSource<C> jwkSource)Creates aJWSKeySelectorthat matches any algorithm from the givenJWSAlgorithm.Family.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <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.JWKSource<C>getJWKSource()Returns the JWK source.List<? extends Key>selectJWSKeys(JWSHeader header, C context)Selects key candidates for verifying a JWS object.
-
-
-
Constructor Detail
-
JWSAlgorithmFamilyJWSKeySelector
public JWSAlgorithmFamilyJWSKeySelector(JWSAlgorithm.Family jwsAlgFamily, JWKSource<C> jwkSource)
Creates aJWSKeySelectorthat matches any algorithm from the givenJWSAlgorithm.Family.- Parameters:
jwsAlgFamily- TheJWSAlgorithm.Familyto use.jwkSource- TheJWKSourcefrom which to draw the set ofJWKs.
-
-
Method Detail
-
selectJWSKeys
public List<? extends Key> selectJWSKeys(JWSHeader header, C context) throws KeySourceException
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 of the JWS object,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
public JWKSource<C> getJWKSource()
Returns the JWK source.- Returns:
- The JWK source.
-
-