public class RSAKeys extends Object
| Modifier and Type | Method and Description |
|---|---|
static RSAKeys |
fromKeyFiles(String publicKeyResource,
String privateKeyResource)
Creates an instance with the given key pair.
|
static RSAKeys |
generate()
Generates a random RSA keypair.
|
PrivateKey |
getPrivate() |
PublicKey |
getPublic() |
static PrivateKey |
loadPrivateKey(String privateKeyResource)
Loads the private key from the given file.
|
static PublicKey |
loadPublicKey(String publicKeyResource)
Loads the public key from the given file.
|
public static RSAKeys generate()
public static RSAKeys fromKeyFiles(String publicKeyResource, String privateKeyResource) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException
loadPublicKey(String) and
loadPrivateKey(String).publicKeyResource - the resource path to the key file, e.g. "/publicKey.txt"privateKeyResource - the resource path to the key file, e.g. "/privateKey.txt"IOException - in case the files could not be read.NoSuchAlgorithmException - see KeyFactory.getInstance(java.lang.String).InvalidKeySpecException - see
KeyFactory.generatePublic(java.security.spec.KeySpec).public static PublicKey loadPublicKey(String publicKeyResource) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException
publicKeyResource - the resource path to the key file.PublicKey instance.IOException - in case the file could not be read.NoSuchAlgorithmException - see KeyFactory.getInstance(java.lang.String).InvalidKeySpecException - see
KeyFactory.generatePublic(java.security.spec.KeySpec).public static PrivateKey loadPrivateKey(String privateKeyResource) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException
privateKeyResource - the resource path to the key file.PrivateKey instance.IOException - in case the file could not be read.NoSuchAlgorithmException - see KeyFactory.getInstance(java.lang.String).InvalidKeySpecException - see
KeyFactory.generatePublic(java.security.spec.KeySpec).public PublicKey getPublic()
public PrivateKey getPrivate()
Copyright © 2020. All rights reserved.