Package com.nimbusds.jose.jwk
Class KeyUse
- java.lang.Object
-
- com.nimbusds.jose.jwk.KeyUse
-
- All Implemented Interfaces:
java.io.Serializable
public final class KeyUse extends java.lang.Object implements java.io.SerializableEnumeration of public key uses. Represents theuseparameter in a JSON Web Key (JWK).Public JWK use values:
- Version:
- 2019-10-03
- Author:
- Vladimir Dzhuvinov
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static KeyUseENCRYPTIONEncryption.static KeyUseSIGNATURESignature.
-
Constructor Summary
Constructors Constructor Description KeyUse(java.lang.String identifier)Creates a new public key use with the specified identifier.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)static KeyUsefrom(java.security.cert.X509Certificate cert)Infers the use of the public key in the specified X.509 certificate.java.lang.StringgetValue()inthashCode()java.lang.Stringidentifier()Returns the identifier of this public key use.static KeyUseparse(java.lang.String s)Parses a public key use from the specified JWKuseparameter value.java.lang.StringtoString()
-
-
-
Method Detail
-
identifier
public java.lang.String identifier()
Returns the identifier of this public key use.- Returns:
- The identifier.
-
getValue
public java.lang.String getValue()
- See Also:
identifier()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
identifier()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
parse
public static KeyUse parse(java.lang.String s) throws java.text.ParseException
Parses a public key use from the specified JWKuseparameter value.- Parameters:
s- The string to parse. May benull.- Returns:
- The public key use,
nullif none. - Throws:
java.text.ParseException- If the string couldn't be parsed to a valid public key use.
-
from
public static KeyUse from(java.security.cert.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 benull.- Returns:
- The inferred public key use,
nullif the use of the public key is not specified by the X.509 certificate or the use maps to bothSIGNATUREandENCRYPTION.
-
-