Package com.jgcomptech.tools
Class SecurityTools.RSAFiles
- java.lang.Object
-
- com.jgcomptech.tools.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.
-
-
-
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 savefilename
- 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 writingjava.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 occursjava.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 readingjava.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 occursjava.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 readingjava.io.IOException
- if an I/O error occurs
-
-