public final class JWK extends Object implements Crypto
In a nutshell a JWK is a Key(Pair) encoded as JSON. This implementation follows the spec with some limitations:
* Supported algorithms are: "PS256", "PS384", "PS512", "RS256", "RS384", "RS512", "ES256", "ES256K", "ES384", "ES512", "HS256", "HS384", "HS512"
When working with COSE, then "RS1" is also a valid algorithm.
The rationale for this choice is to support the required algorithms for JWT.
The constructor takes a single JWK (the the KeySet) or a PEM encoded pair (used by Google and useful for importing standard PEM files from OpenSSL).
Certificate chains (x5c) are allowed and verified, certificate urls and fingerprints are not considered.
| Constructor and Description |
|---|
JWK(JsonObject json) |
JWK(PubSecKeyOptions options)
Creates a Key(Pair) from pem formatted strings.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAlgorithm() |
String |
getId()
The key id or null.
|
String |
getLabel()
A not null label for the key, labels are the same for same algorithm, kid objects
but not necessarily different internal keys/certificates
|
Mac |
getMac() |
PrivateKey |
getPrivateKey() |
PublicKey |
getPublicKey() |
Signature |
getSignature() |
String |
getType() |
int |
getUse() |
boolean |
isFor(int use) |
static List<JWK> |
load(KeyStore keyStore,
String keyStorePassword,
Map<String,String> passwordProtection) |
byte[] |
sign(byte[] payload) |
boolean |
verify(byte[] expected,
byte[] payload) |
public static final int USE_SIG
public static final int USE_ENC
public JWK(PubSecKeyOptions options)
options - PEM pub sec key options.public JWK(JsonObject json)
public static List<JWK> load(KeyStore keyStore, String keyStorePassword, Map<String,String> passwordProtection)
public String getAlgorithm()
public boolean verify(byte[] expected,
byte[] payload)
public boolean isFor(int use)
public int getUse()
public String getLabel()
Cryptopublic String getType()
public Signature getSignature()
public Mac getMac()
public PublicKey getPublicKey()
public PrivateKey getPrivateKey()
Copyright © 2021. All rights reserved.