Class JWSTokenSigner
java.lang.Object
net.shibboleth.oidc.security.impl.JWSTokenSigner
Supports signing a JSON Web Token (JWT) claims set using the JSON Web Signature standard using the algorithm and
credential contained inside the
SignatureSigningParameters. Any error that occurs signing the JWT will
throw an SignatureException.
A signer will need to be created for each new signing operation.
- Since:
- 3.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.slf4j.LoggerClass logger.private final SignatureSigningParametersThe signature signing parameters. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected JWSSignergetSigner(Algorithm jwsAlgorithm, Credential credential) Returns the correct implementation of theJWSSignerbased on the algorithm type and credential given.protected JWSAlgorithmresolveAlgorithm(Credential credential, String algorithmString) Resolves JWS algorithm from signature signing parameters.sign(JWTClaimsSet jwtClaims, String typeHeader) Sign the given JWT claims set using the signing parameters.
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
params
The signature signing parameters.
-
-
Constructor Details
-
JWSTokenSigner
Constructor.- Parameters:
signingParams- the algorithm and credential to use during signing
-
-
Method Details
-
sign
@Nonnull public SignedJWT sign(@Nonnull JWTClaimsSet jwtClaims, @Nullable String typeHeader) throws SignatureException Sign the given JWT claims set using the signing parameters.- Parameters:
jwtClaims- the claims to signtypeHeader- the optional JOSE object type to add to the JWS JOSE header- Returns:
- a signed JWT or
nullif an error occurs - Throws:
SignatureException- if an error occurs
-
getSigner
@Nonnull protected JWSSigner getSigner(@Nonnull Algorithm jwsAlgorithm, @Nonnull Credential credential) throws JOSEException Returns the correct implementation of theJWSSignerbased on the algorithm type and credential given.- Parameters:
jwsAlgorithm- the JWS algorithmcredential- the credential- Returns:
- signer for the given algorithm and credential
- Throws:
JOSEException- if algorithm and credential combinations is not supported
-
resolveAlgorithm
@Nonnull protected JWSAlgorithm resolveAlgorithm(@Nonnull Credential credential, @Nonnull String algorithmString) Resolves JWS algorithm from signature signing parameters. Warns if an unsuitable credential and algorithm are found, but the algorithm is still returned.- Parameters:
credential- the credential used to sign the JWT claimsalgorithmString- the JWS algorithm as a string- Returns:
- JWS algorithm
-