Package com.nimbusds.jose.jwk
Class KeyUse
- java.lang.Object
-
- com.nimbusds.jose.jwk.KeyUse
-
- All Implemented Interfaces:
Serializable
public final class KeyUse extends Object implements Serializable
Enumeration of public key uses. Represents theuse
parameter 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 KeyUse
ENCRYPTION
Encryption.static KeyUse
SIGNATURE
Signature.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static KeyUse
from(X509Certificate cert)
Infers the use of the public key in the specified X.509 certificate.String
getValue()
int
hashCode()
String
identifier()
Returns the identifier of this public key use.static KeyUse
parse(String s)
Parses a public key use from the specified JWKuse
parameter value.String
toString()
-
-
-
Field Detail
-
ENCRYPTION
public static final KeyUse ENCRYPTION
Encryption.
-
-
Method Detail
-
identifier
public String identifier()
Returns the identifier of this public key use.- Returns:
- The identifier.
-
getValue
public String getValue()
- See Also:
identifier()
-
toString
public String toString()
- Overrides:
toString
in classObject
- See Also:
identifier()
-
parse
public static KeyUse parse(String s) throws ParseException
Parses a public key use from the specified JWKuse
parameter value.- Parameters:
s
- The string to parse. May benull
.- 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 benull
.- 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 bothSIGNATURE
andENCRYPTION
.
-
-