This commit is contained in:
Lucio Lelii 2016-02-10 14:08:16 +00:00
parent 18a1c04d8f
commit c612694ed6
1 changed files with 2 additions and 18 deletions

View File

@ -1,7 +1,7 @@
package org.gcube.common.encryption.keytool;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.Key;
import java.security.KeyStore;
import java.security.KeyStoreException;
@ -12,6 +12,7 @@ import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPublicKey;
import javax.crypto.Cipher;
@ -73,23 +74,6 @@ public class KeyTool {
return result;
}
/*
* Get public key from keystore.
* The public key is in the certificate.
*/
private static Key getPublicKey(String keyname, String keystore)
throws IOException, KeyStoreException, NoSuchAlgorithmException,
CertificateException {
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(keystore), KEYSTORE_PASS.toCharArray());
X509Certificate cert = (X509Certificate) ks.getCertificate(keyname);
if (cert != null) {
return cert.getPublicKey();
}
return null;
}
/*
* Encrypt a message using the public key