Class JWSTokenSigner

java.lang.Object
net.shibboleth.oidc.security.impl.JWSTokenSigner

public class JWSTokenSigner extends Object
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 Details

    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • params

      @Nonnull private final SignatureSigningParameters params
      The signature signing parameters.
  • Constructor Details

    • JWSTokenSigner

      public JWSTokenSigner(@Nonnull SignatureSigningParameters signingParams)
      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 sign
      typeHeader - the optional JOSE object type to add to the JWS JOSE header
      Returns:
      a signed JWT or null if 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 the JWSSigner based on the algorithm type and credential given.
      Parameters:
      jwsAlgorithm - the JWS algorithm
      credential - 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 claims
      algorithmString - the JWS algorithm as a string
      Returns:
      JWS algorithm