Class CredentialConversionUtil

java.lang.Object
net.shibboleth.oidc.security.CredentialConversionUtil

public final class CredentialConversionUtil extends Object
Generic tool methods related to converting Credential to JWK.
  • Constructor Details

    • CredentialConversionUtil

      private CredentialConversionUtil()
      Private constructor.
  • Method Details

    • resolveKid

      @Nullable public static String resolveKid(@Nullable Credential credential)
      Resolves kid from key name. If there is no key name and the credential is JWK, the kid is read from JWK.
      Parameters:
      credential - input key names
      Returns:
      key names or null if not found
    • resolveKeyUse

      @Nullable public static KeyUse resolveKeyUse(@Nullable Credential credential)
      Resolves KeyUse parameter from credential.
      Parameters:
      credential - credential to resolve KeyUse of
      Returns:
      KeyUse of credential
    • credentialToKey

      @Nullable public static JWK credentialToKey(@Nullable Credential credential)
      Converts credential to JWK with only *public* components. Only RSA and EC keys supported.
      Parameters:
      credential - to convert.
      Returns:
      credential as JWK.
    • copySymmetricCredentialWithNewSecret

      @Nonnull public static JWKCredential copySymmetricCredentialWithNewSecret(@Nonnull JWKCredential credential, @Nullable String newKid, @Nonnull SecretKey derivedKey)
      Create a shallow copy of the input credential, replacing the secrete key and keyID with those supplied. Only supports symmetric keys.
      Parameters:
      credential - the credential to copy and replace the secret key
      newKid - the new keyID to use
      derivedKey - the secret key to use
      Returns:
      the copied credential with the supplied secret key
    • keyToCredential

      @Nullable public static Credential keyToCredential(@Nullable JWK key) throws JOSEException
      Converts a JWK to an internal Credential. Only RSA and EC keys supported.
      Parameters:
      key - to convert.
      Returns:
      credential as Credential.
      Throws:
      JOSEException - on error converting the key
    • getUsageType

      @Nonnull public static UsageType getUsageType(@Nonnull JWK jwk)
      Converts JWK key usage type to OpenSAML usage type.
      Parameters:
      jwk - containing usage type. Must not be null.
      Returns:
      usage type.