java.lang.Object
com.irurueta.authserver.authorization.infrastructure.keys.SigningKeyJwkMapper

@Component public class SigningKeyJwkMapper extends Object
Maps the domain SigningKey onto Nimbus JSON Web Keys: the public set lists the public half of every key it is given, whereas the signing set holds the single active key with its private half, decrypted with the AesGcmKeyCipher.
  • Field Details

    • cipher

      private final AesGcmKeyCipher cipher
      Decrypts the private half of a key.
  • Constructor Details

    • SigningKeyJwkMapper

      public SigningKeyJwkMapper()
  • Method Details

    • toPublicJwkSet

      public com.nimbusds.jose.jwk.JWKSet toPublicJwkSet(List<SigningKey> keys)
      Builds the set of public keys.
      Parameters:
      keys - the keys to publish.
      Returns:
      the set, with the public half of each key only.
      Throws:
      IllegalStateException - if a stored key is not a valid JWK.
    • toSigningJwkSet

      public com.nimbusds.jose.jwk.JWKSet toSigningJwkSet(Optional<SigningKey> active)
      Builds the set holding the active key, with its private half.
      Parameters:
      active - the active key, if any.
      Returns:
      the set; empty before the first rotation has created an active key.
      Throws:
      IllegalStateException - if the stored key is not a valid JWK.
    • toJwk

      public com.nimbusds.jose.jwk.JWK toJwk(String json)
      Parses a JSON Web Key.
      Parameters:
      json - the key as JSON.
      Returns:
      the key.
      Throws:
      IllegalStateException - if the text is not a valid key.