List of utility methods to do Key Public
PublicKey | getPublicKey(byte[] keyBytes, String algorithm) get Public Key PublicKey publicKey = null; try { KeyFactory kf = KeyFactory.getInstance(algorithm); EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes); publicKey = kf.generatePublic(keySpec); } catch (NoSuchAlgorithmException e) { System.out.println("Could not reconstruct the public key, the given algorithm could not be found."); } catch (InvalidKeySpecException e) { ... |
PublicKey | getPublicKey(final byte[] keyData) get Public Key final X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyData); final KeyFactory keyFactory = KeyFactory.getInstance("RSA"); return keyFactory.generatePublic(keySpec); |
RSAPublicKey | getPublicKey(final byte[] modulus, final byte[] exponent) get Public Key final RSAPublicKeySpec spec = new RSAPublicKeySpec(new BigInteger(modulus), new BigInteger(exponent)); try { final KeyFactory factory = KeyFactory.getInstance(EBICS_ENCRYPTION_KEY_ALGORITHM); return (RSAPublicKey) factory.generatePublic(spec); } catch (final GeneralSecurityException e) { throw new RuntimeException(e); |
PublicKey | getPublicKey(final String algorithm, final File publicKeyFile) get Public Key return getPublicKeyFromBytes(algorithm, readBytes(publicKeyFile));
|
PublicKey | getPublicKey(KeyPair keyPair) get Public Key if (keyPair == null) { return null; return keyPair.getPublic(); |
String | getPublicKey(KeyPair keyPair) get Public Key PublicKey publicKey = keyPair.getPublic();
return toHexString(publicKey.getEncoded());
|
Key | getPublicKey(KeyPair kp) get Public Key return (kp != null) ? kp.getPublic() : null;
|
PublicKey | getPublicKey(KeyStore keyStore, String alias) get Public Key return getCertificate(keyStore, alias).getPublicKey();
|
PublicKey | getPublicKey(KeyStore keyStore, String alias) get Public Key return keyStore.getCertificate(alias).getPublicKey();
|
PublicKey | getPublicKey(KeyStore keyStore, String alias, char[] password) get Public Key PublicKey publicKey = null; Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { Certificate cert = keyStore.getCertificate(alias); publicKey = cert.getPublicKey(); if (publicKey == null) { Certificate cert = keyStore.getCertificate(alias); ... |