Class KeyUse

  • All Implemented Interfaces:
    Serializable

    public final class KeyUse
    extends Object
    implements Serializable
    Enumeration of public key uses. Represents the use parameter in a JSON Web Key (JWK).

    Public JWK use values:

    Version:
    2019-10-03
    Author:
    Vladimir Dzhuvinov
    See Also:
    Serialized Form
    • Constructor Detail

      • KeyUse

        public KeyUse​(String identifier)
        Creates a new public key use with the specified identifier.
        Parameters:
        identifier - The public key use identifier. Must not be null.
    • Method Detail

      • identifier

        public String identifier()
        Returns the identifier of this public key use.
        Returns:
        The identifier.
      • parse

        public static KeyUse parse​(String s)
                            throws ParseException
        Parses a public key use from the specified JWK use parameter value.
        Parameters:
        s - The string to parse. May be null.
        Returns:
        The public key use, null if none.
        Throws:
        ParseException - If the string couldn't be parsed to a valid public key use.
      • from

        public static KeyUse from​(X509Certificate cert)
        Infers the use of the public key in the specified X.509 certificate. Note that there is no standard algorithm for mapping PKIX key usage to JWK use. See RFC 2459, section 4.2.1.3, as well as the underlying code for the chosen algorithm to infer JWK use.
        Parameters:
        cert - The X.509 certificate. Must not be null.
        Returns:
        The inferred public key use, null if the use of the public key is not specified by the X.509 certificate or the use maps to both SIGNATURE and ENCRYPTION.