Package alpine.security.crypto
Class KeyManager
java.lang.Object
alpine.security.crypto.KeyManager
Class that manages Alpine-generated default private, public, and secret keys.
- Since:
- 1.0.0
- Author:
- Steve Springett
-
Method Summary
Modifier and TypeMethodDescriptionclone()Generates a key pair.Generates a secret key.static KeyManagerReturns an INSTANCE of the KeyManager.Returns the keypair.Returns only the private key.Returns only the public key.Returns the secret key.booleanChecks to see if the key pair exists.voidSaves a key pair.voidDeprecated, for removal: This API element is subject to removal in a future version.voidsaveEncoded(SecretKey key) Saves a secret key in encoded format.booleanChecks to see if the secret key exists.
-
Method Details
-
getInstance
Returns an INSTANCE of the KeyManager.- Returns:
- an instance of the KeyManager
- Since:
- 1.0.0
-
generateKeyPair
Generates a key pair.- Returns:
- a KeyPair (public / private keys)
- Throws:
NoSuchAlgorithmException- if the algorithm cannot be found- Since:
- 1.0.0
-
generateSecretKey
Generates a secret key.- Returns:
- a SecretKey
- Throws:
NoSuchAlgorithmException- if the algorithm cannot be found- Since:
- 1.0.0
-
save
Saves a key pair.- Parameters:
keyPair- the key pair to save- Throws:
IOException- if the files cannot be written- Since:
- 1.0.0
-
save
Deprecated, for removal: This API element is subject to removal in a future version.UsesaveEncoded(SecretKey)insteadSaves a secret key.- Parameters:
key- the SecretKey to save- Throws:
IOException- if the file cannot be written- Since:
- 1.0.0
-
saveEncoded
Saves a secret key in encoded format.- Parameters:
key- the SecretKey to save- Throws:
IOException- if the file cannot be written- Since:
- 2.2.0
-
keyPairExists
public boolean keyPairExists()Checks to see if the key pair exists. Both (public and private) need to exist to return true.- Returns:
- true if keypair exists, false if not
- Since:
- 1.0.0
-
secretKeyExists
public boolean secretKeyExists()Checks to see if the secret key exists.- Returns:
- true if secret key exists, false if not
- Since:
- 1.0.0
-
getKeyPair
Returns the keypair.- Returns:
- the KeyPair
- Since:
- 1.0.0
-
getPublicKey
Returns only the public key.- Returns:
- the PublicKey
- Since:
- 1.0.0
-
getPrivateKey
Returns only the private key.- Returns:
- the PrivateKey
- Since:
- 1.0.0
-
getSecretKey
Returns the secret key.- Returns:
- the SecretKey
- Since:
- 1.0.0
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
saveEncoded(SecretKey)instead