Class KeyLoader


  • public class KeyLoader
    extends java.lang.Object
    This class simplifies the process of loading Keys from files
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyLoader()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static dev.netcode.util.Result<java.security.PrivateKey> loadPrivateKeyFromEncryptedFile​(java.nio.file.Path file, java.lang.String password)
      Loads a Base64 encoded RSA private key from an encrypted file
      static java.security.PrivateKey loadPrivateKeyFromFile​(java.nio.file.Path file)
      Loads a Base64 encoded RSA private key from file
      static dev.netcode.util.Result<java.security.PublicKey> loadPublicKeyFromEncryptedFile​(java.nio.file.Path file, java.lang.String password)
      Loads a Base64 encoded RSA public key from an encrypted file
      static java.security.PublicKey loadPublicKeyFromFile​(java.nio.file.Path file)
      Loads a Base64 encoded RSA public key from file
      • Methods inherited from class java.lang.Object

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

      • KeyLoader

        public KeyLoader()
    • Method Detail

      • loadPublicKeyFromFile

        public static java.security.PublicKey loadPublicKeyFromFile​(java.nio.file.Path file)
                                                             throws java.io.IOException
        Loads a Base64 encoded RSA public key from file
        Parameters:
        file - Path of the file containing the Base64 encoded public key
        Returns:
        the public key
        Throws:
        java.io.IOException - if the file can not be read
      • loadPrivateKeyFromFile

        public static java.security.PrivateKey loadPrivateKeyFromFile​(java.nio.file.Path file)
                                                               throws java.io.IOException
        Loads a Base64 encoded RSA private key from file
        Parameters:
        file - Path of the file containing the Base64 encoded private key
        Returns:
        the private key
        Throws:
        java.io.IOException - if the file can not be read
      • loadPublicKeyFromEncryptedFile

        public static dev.netcode.util.Result<java.security.PublicKey> loadPublicKeyFromEncryptedFile​(java.nio.file.Path file,
                                                                                                      java.lang.String password)
                                                                                               throws java.io.IOException
        Loads a Base64 encoded RSA public key from an encrypted file
        Parameters:
        file - Path of the file containing the Base64 encoded public key
        password - used to decrypt the file
        Returns:
        the public key
        Throws:
        java.io.IOException - if the file can not be read
      • loadPrivateKeyFromEncryptedFile

        public static dev.netcode.util.Result<java.security.PrivateKey> loadPrivateKeyFromEncryptedFile​(java.nio.file.Path file,
                                                                                                        java.lang.String password)
                                                                                                 throws java.io.IOException
        Loads a Base64 encoded RSA private key from an encrypted file
        Parameters:
        file - Path of the file containing the Base64 encoded private key
        password - used to decrypt the file
        Returns:
        the private key
        Throws:
        java.io.IOException - if the file can not be read