public abstract class CryptoKey extends Secret
Modifier and Type | Method and Description |
---|---|
boolean |
allowsAlgorithm(String algorithm)
Checks whether this key is allowed to be used with the given algorithm.
|
void |
close() |
<T> T |
export(KeyFormat<T> format)
Exports the key material in the given format.
|
Optional<Certificate> |
getCertificate()
Returns any certificate associated with this key.
|
<T extends Certificate> |
getCertificate(Class<T> certificateType)
Returns the certificate of the given type if one is available.
|
String |
getKeyAlgorithm()
Returns the algorithm used by the underlying key, for instance "RSA" or "EC".
|
KeyType |
getKeyType()
Returns an indication of the type of key this is.
|
Set<KeyUsage> |
getKeyUsages()
Returns the key usages that the key can be used for.
|
Optional<PublicKey> |
getPublicKey()
Returns the public key associated with this secret, if one is available.
|
<T extends PublicKey> |
getPublicKey(Class<T> keyType)
Returns the public key associated with this secret, if one is available.
|
boolean |
isExtractable()
Indicates whether the raw key material can be extracted for this key.
|
equals, getExpiryTime, getStableId, hashCode, isExpired, toString
public KeyType getKeyType()
public String getKeyAlgorithm()
public <T> T export(KeyFormat<T> format) throws NoSuchSecretException
T
- the type of result returned.format
- the format to export the key material in.NoSuchSecretException
- if the secret could not be exported.public <T extends Certificate> Optional<T> getCertificate(Class<T> certificateType)
T
- the type of certificate.certificateType
- the type of certificate to get.public Optional<Certificate> getCertificate()
public <T extends PublicKey> Optional<T> getPublicKey(Class<T> keyType)
T
- the type of public key.keyType
- the type of public key to return.public Optional<PublicKey> getPublicKey()
public Set<KeyUsage> getKeyUsages()
public boolean allowsAlgorithm(String algorithm)
ES256
) or a Java Cipher algorithm name
(e.g., RSA/ECB/PKCS1Padding
).algorithm
- the algorithm to check if this key can be used with.public boolean isExtractable()
exported
even if the key itself is not extractable, for instance a public
certificate. The main reason why a key is not extractable is because it is stored in secure storage such as a
Hardware Security Module (HSM) or on a remote server.public void close()
close
in interface AutoCloseable
close
in class Secret
Copyright © 2010-2018, ForgeRock All Rights Reserved.