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>
AJWSKeySelector
that 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 aJWSKeySelector
that 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 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.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 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 Detail
-
selectJWSKeys
public List<? extends Key> selectJWSKeys(JWSHeader header, C context) throws KeySourceException
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 of the JWS object,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
public JWKSource<C> getJWKSource()
Returns the JWK source.- Returns:
- The JWK source.
-
-