K - The type of PrivateKey represented by this JWKL - The type of PublicKey represented by the JWK's corresponding public JWK.M - The type of PublicJwk reflected by the JWK's public properties.public interface PrivateJwk<K extends PrivateKey,L extends PublicKey,M extends PublicJwk<L>> extends AsymmetricJwk<K>
PrivateKey.
JWK Private Key vs Java PrivateKey differences
Unlike the Java cryptography APIs, the JWK specification requires all public key and private key
properties to be contained within every private JWK. As such, a PrivateJwk indeed represents
private key values as its name implies, but it is probably more similar to the Java JCA concept of a
KeyPair since it contains everything for both keys.
Consequently a PrivateJwk is capable of providing two additional convenience methods:
toPublicJwk() - a method to obtain a PublicJwk instance that contains only the JWK public
key properties, andtoKeyPair() - a method to obtain both Java PublicKey and PrivateKeys in aggregate
as a KeyPair instance if desired.| Modifier and Type | Method and Description |
|---|---|
KeyPair<L,K> |
toKeyPair()
Returns the key's corresponding Java
PrivateKey and PublicKey in aggregate as a
type-safe KeyPair instance. |
M |
toPublicJwk()
Returns the private JWK's corresponding
PublicJwk, containing only the key's public properties. |
getPublicKeyUsegetAlgorithm, getOperations, getType, thumbprint, thumbprint, toKeygetIdclear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, valuesgetX509Chain, getX509Sha1Thumbprint, getX509Sha256Thumbprint, getX509UrlM toPublicJwk()
PublicJwk, containing only the key's public properties.PublicJwk, containing only the key's public properties.KeyPair<L,K> toKeyPair()
PrivateKey and PublicKey in aggregate as a
type-safe KeyPair instance.PrivateKey and PublicKey in aggregate as a
type-safe KeyPair instance.Copyright © 2014–2025 jsonwebtoken.io. All rights reserved.