public final class ManagedKey extends Object implements Serializable
java.security.Key
that is managed by a KeyManager
.KeyManager
, Serialized FormModifier and Type | Class and Description |
---|---|
static class | ManagedKey.Builder A builder for ManagedKey . |
Modifier and Type | Method and Description |
---|---|
boolean | equals(Object obj) |
Instant | getActivatedOn() Returns the time when this key was activated. |
String | getAlgorithm() Returns the key algorithm. |
Instant | getDeactivatedOn() Returns the time when this key was deactivated, null if still active. |
<T extends Key> | getKey() Returns a type of java.security.Key , e.g. |
String | getKeyId() Returns the key ID. |
PublicKey | getPublicKey() Returns the java.security.PublicKey if this is a asymmetric key, null otherwise. |
int | hashCode() |
boolean | isActive() Returns true if this key is active, false otherwise. |
boolean | isAsymmetric() Returns true if this is a asymmetric key, false otherwise. |
boolean | isSymmetric() Returns true if this is a symmetric key, false otherwise. |
static ManagedKey.Builder | withAsymmetricKey(PublicKey publicKey, PrivateKey privateKey) Returns a new ManagedKey.Builder , initialized with the provided java.security.PublicKey and java.security.PrivateKey . |
static ManagedKey.Builder | withSymmetricKey(SecretKey secretKey) Returns a new ManagedKey.Builder , initialized with the provided javax.crypto.SecretKey . |
public boolean isSymmetric()
true
if this is a symmetric key, false
otherwise.true
if this is a symmetric key, false
otherwisepublic boolean isAsymmetric()
true
if this is a asymmetric key, false
otherwise.true
if this is a asymmetric key, false
otherwisepublic <T extends Key> T getKey()
java.security.Key
, e.g. javax.crypto.SecretKey
or java.security.PrivateKey
.T
- the type of java.security.Key
java.security.Key
public PublicKey getPublicKey()
java.security.PublicKey
if this is a asymmetric key, null
otherwise.java.security.PublicKey
if this is a asymmetric key, null
otherwisepublic String getKeyId()
public Instant getActivatedOn()
public Instant getDeactivatedOn()
null
if still active.null
if still activepublic boolean isActive()
true
if this key is active, false
otherwise.true
if this key is active, false
otherwisepublic String getAlgorithm()
public static ManagedKey.Builder withSymmetricKey(SecretKey secretKey)
ManagedKey.Builder
, initialized with the provided javax.crypto.SecretKey
.secretKey
- the javax.crypto.SecretKey
ManagedKey.Builder
public static ManagedKey.Builder withAsymmetricKey(PublicKey publicKey, PrivateKey privateKey)
ManagedKey.Builder
, initialized with the provided java.security.PublicKey
and java.security.PrivateKey
.publicKey
- the java.security.PublicKey
privateKey
- the java.security.PrivateKey
ManagedKey.Builder