public final class KeyUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static EnumMap<KeyEncryptionAlgorithm,Integer> |
KEY_ENCRYPTION_BITS |
protected static EnumMap<SignatureAlgorithm,Integer> |
SIGNATURE_ALGORITHM_BITS |
protected static final EnumMap<KeyEncryptionAlgorithm,Integer> KEY_ENCRYPTION_BITS
protected static final EnumMap<SignatureAlgorithm,Integer> SIGNATURE_ALGORITHM_BITS
public static PrivateKey readPrivateKey(String pemResName) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static PrivateKey readPrivateKey(String pemResName, SignatureAlgorithm algo) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static PrivateKey readDecryptionPrivateKey(String pemResName) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static PrivateKey readDecryptionPrivateKey(String pemResName, KeyEncryptionAlgorithm algo) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static PublicKey readPublicKey(String pemResName) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static PublicKey readPublicKey(String pemResName, SignatureAlgorithm algo) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static PublicKey readEncryptionPublicKey(String pemResName) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static PublicKey readEncryptionPublicKey(String pemResName, KeyEncryptionAlgorithm algo) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static KeyPair generateKeyPair(int keySize, SignatureAlgorithm algo) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static PrivateKey decodePrivateKey(String pemEncoded) throws GeneralSecurityException
pemEncoded - - pem string for keyGeneralSecurityException - - on failure to decode and create keypublic static PrivateKey decodePrivateKey(String pemEncoded, SignatureAlgorithm algo) throws GeneralSecurityException
pemEncoded - - pem string for keyalgo - - signature algorithmGeneralSecurityException - - on failure to decode and create keypublic static PrivateKey decodeDecryptionPrivateKey(String pemEncoded) throws GeneralSecurityException
pemEncoded - - pem string for keyGeneralSecurityException - - on failure to decode and create keypublic static PrivateKey decodeDecryptionPrivateKey(String pemEncoded, KeyEncryptionAlgorithm algo) throws GeneralSecurityException
pemEncoded - - pem string for keyalgo - - key encryption algorithmGeneralSecurityException - - on failure to decode and create keypublic static PublicKey decodePublicKey(String pemEncoded) throws GeneralSecurityException
pemEncoded - - PEM string for public keyGeneralSecurityException - on decode failurepublic static SecretKey createSecretKeyFromEncodedSecret(String secret)
public static SecretKey generateSecretKey(KeyEncryptionAlgorithm algo) throws InvalidAlgorithmParameterException
algo - key encryption algorithm.InvalidAlgorithmParameterException - algorithm not found.public static SecretKey generateSecretKey(SignatureAlgorithm algo) throws InvalidAlgorithmParameterException
algo - signature algorithm.InvalidAlgorithmParameterException - algorithm not found.public static PublicKey decodePublicKey(String pemEncoded, SignatureAlgorithm algo) throws GeneralSecurityException
pemEncoded - - PEM string for public keyalgo - signature algorithmGeneralSecurityException - on decode failurepublic static PublicKey decodeEncryptionPublicKey(String pemEncoded, KeyEncryptionAlgorithm algo) throws GeneralSecurityException
GeneralSecurityExceptionpublic static PublicKey decodeCertificate(String pemEncoded) throws GeneralSecurityException
pemEncoded - - PEM string for certificateGeneralSecurityException - on decode failurepublic static X509Certificate getCertificate(String pemEncoded) throws GeneralSecurityException
pemEncoded - - PEM string for certificateGeneralSecurityException - on decode failurepublic static String removePemKeyBeginEnd(String pem)
pem - encoded string with option header/footerpublic static String readKeyContent(String keyLocation) throws IOException
IOExceptionpublic static PrivateKey tryAsPemSigningPrivateKey(String content, SignatureAlgorithm alg)
public static PublicKey tryAsPemEncryptionPublicKey(String content, KeyEncryptionAlgorithm alg)
public static Key readEncryptionKey(String location, String kid) throws IOException
IOExceptionpublic static Key readEncryptionKey(String location, String kid, KeyEncryptionAlgorithm alg) throws IOException
IOExceptionpublic static Key getPublicOrSecretEncryptingKey(org.jose4j.jwk.JsonWebKey currentJwk, KeyEncryptionAlgorithm alg)
public static Key readSigningKey(String location, String kid) throws IOException
IOExceptionpublic static Key readSigningKey(String location, String kid, SignatureAlgorithm alg) throws IOException
IOExceptionpublic static org.jose4j.jwk.JsonWebKey getJwkKeyFromJwkSet(String kid, String keyContent)
public static Key getPrivateOrSecretSigningKey(org.jose4j.jwk.JsonWebKey currentJwk, SignatureAlgorithm alg)
Copyright © 2018–2021. All rights reserved.