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 aJWSKeySelector
that matches any algorithm from the givenJWSAlgorithm.Family
. -
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends SecurityContext>
JWSAlgorithmFamilyJWSKeySelector<C>fromJWKSetURL
(URL jwkSetURL) Queries the given JWK SetURL
for keys, creating aJWSAlgorithmFamilyJWSKeySelector
based on the RSA or EC key type, whichever comes back first.static <C extends SecurityContext>
JWSAlgorithmFamilyJWSKeySelector<C>fromJWKSource
(JWKSource<C> jwkSource) Queries the givenJWKSource
for keys, creating aJWSAlgorithmFamilyJWSKeySelector
based 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 aJWSKeySelector
that matches any algorithm from the givenJWSAlgorithm.Family
.- Parameters:
jwsAlgFamily
- TheJWSAlgorithm.Family
to use.jwkSource
- TheJWKSource
from which to draw the set ofJWK
s.
-
-
Method Details
-
selectJWSKeys
Description copied from interface:JWSKeySelector
Selects key candidates for verifying a JWS object.- Specified by:
selectJWSKeys
in interfaceJWSKeySelector<C extends SecurityContext>
- Parameters:
header
- The header of the JWS object. Must not benull
.context
- Optional context,null
if 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 SetURL
for keys, creating aJWSAlgorithmFamilyJWSKeySelector
based on the RSA or EC key type, whichever comes back first.- Type Parameters:
C
- TheSecurityContext
- Parameters:
jwkSetURL
- The JWK SetURL
to 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 givenJWKSource
for keys, creating aJWSAlgorithmFamilyJWSKeySelector
based 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.
-