Package alpine.crypto

Class KeyManager


  • public final class KeyManager
    extends Object
    Class that manages Alpine-generated default private, public, and secret keys.
    Since:
    1.0.0
    Author:
    Steve Springett
    • Method Detail

      • getInstance

        public static KeyManager getInstance()
        Returns an INSTANCE of the KeyManager.
        Returns:
        an instance of the KeyManager
        Since:
        1.0.0
      • save

        public void save​(KeyPair keyPair)
                  throws IOException
        Saves a key pair.
        Parameters:
        keyPair - the key pair to save
        Throws:
        IOException - if the files cannot be written
        Since:
        1.0.0
      • save

        public void save​(SecretKey key)
                  throws IOException
        Saves a secret key.
        Parameters:
        key - the SecretKey to save
        Throws:
        IOException - if the file cannot be written
        Since:
        1.0.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

        public KeyPair getKeyPair()
        Returns the keypair.
        Returns:
        the KeyPair
        Since:
        1.0.0
      • getPublicKey

        public PublicKey getPublicKey()
        Returns only the public key.
        Returns:
        the PublicKey
        Since:
        1.0.0
      • getPrivateKey

        public PrivateKey getPrivateKey()
        Returns only the private key.
        Returns:
        the PrivateKey
        Since:
        1.0.0
      • getSecretKey

        public SecretKey getSecretKey()
        Returns the secret key.
        Returns:
        the SecretKey
        Since:
        1.0.0