Class SecurityTools.RSAFiles

  • Enclosing class:
    SecurityTools

    public static final class SecurityTools.RSAFiles
    extends java.lang.Object
    Contains methods dealing with RSA key files.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.security.PrivateKey readPrivateKeyFromFile​(java.lang.String filename)
      Reads a private key from a filename.
      static java.security.PublicKey readPublicKeyFromFile​(java.lang.String filename)
      Reads a public key from a filename.
      static void saveKeyPairToFile​(java.security.KeyPair pair, java.lang.String filename)
      Saves specified key pair to filename.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • saveKeyPairToFile

        public static void saveKeyPairToFile​(java.security.KeyPair pair,
                                             java.lang.String filename)
                                      throws java.io.IOException
        Saves specified key pair to filename.
        Parameters:
        pair - Key pair to save
        filename - Filename to save to
        Throws:
        java.io.FileNotFoundException - if the file is a directory rather than a regular file, or for some other reason cannot be opened for writing
        java.io.IOException - if an I/O error occurs
      • readPublicKeyFromFile

        public static java.security.PublicKey readPublicKeyFromFile​(java.lang.String filename)
                                                             throws java.security.GeneralSecurityException,
                                                                    java.io.IOException
        Reads a public key from a filename.
        Parameters:
        filename - Filename to save to
        Returns:
        Public key as PublicKey object
        Throws:
        java.security.GeneralSecurityException - if error occurs
        java.io.FileNotFoundException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading
        java.io.IOException - if an I/O error occurs
      • readPrivateKeyFromFile

        public static java.security.PrivateKey readPrivateKeyFromFile​(java.lang.String filename)
                                                               throws java.security.GeneralSecurityException,
                                                                      java.io.IOException
        Reads a private key from a filename.
        Parameters:
        filename - Filename to save to
        Returns:
        Private key as PrivateKey object
        Throws:
        java.security.GeneralSecurityException - if error occurs
        java.io.FileNotFoundException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading
        java.io.IOException - if an I/O error occurs