java.lang.Object
org.seppiko.commons.utils.crypto.KeyUtil
Key generator util
- Author:
- Leonard Woo
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]keyAgreement(String algorithm, Provider provider, Key privateKey, Key publicKey) Returns aKeyAgreementobject that implements the specified key agreement algorithm.static KeyFactorykeyFactory(String algorithm, Provider provider) Returns a KeyFactory object that converts public/private keys of the specified algorithm.static KeyStorekeyStore(KeyStoreAlgorithms type, InputStream is, char[] password) KeyStore utilstatic KeyStorekeyStore(KeyStoreAlgorithms type, KeyStore.LoadStoreParameter loadStore) KeyStore utilstatic SecretKeyFactorysecretKeyFactory(String algorithm, Provider provider) Returns a SecretKeyFactory object that converts secret keys of the specified algorithm.static byte[]secretKeyFactory(String algorithm, Provider provider, KeySpec keySpec) Returns a SecretKeyFactory object that converts secret keys of the specified algorithm.
-
Method Details
-
secretKeyFactory
public static byte[] secretKeyFactory(String algorithm, Provider provider, KeySpec keySpec) throws NoSuchAlgorithmException, InvalidKeySpecException, NullPointerException Returns a SecretKeyFactory object that converts secret keys of the specified algorithm.- Parameters:
algorithm- Secret Key Factory algorithm.provider- an instance of the provider.keySpec- KeySpec impl e.g.PBEKeySpec.- Returns:
- Secret Key Factory instance.
- Throws:
NoSuchAlgorithmException- if no Provider supports a SecretKeyFactorySpi implementation for the specified algorithm.InvalidKeySpecException- if the given key specification is inappropriate for this secret-key factory to produce a secret key.NullPointerException- if algorithm is null.- See Also:
-
secretKeyFactory
public static SecretKeyFactory secretKeyFactory(String algorithm, Provider provider) throws NoSuchAlgorithmException, NullPointerException Returns a SecretKeyFactory object that converts secret keys of the specified algorithm.- Parameters:
algorithm- Secret Key Factory algorithm.provider- an instance of the provider.- Returns:
- Secret Key Factory instance.
- Throws:
NoSuchAlgorithmException- if no Provider supports a SecretKeyFactorySpi implementation for the specified algorithm.NullPointerException- if algorithm is null.- See Also:
-
keyFactory
public static KeyFactory keyFactory(String algorithm, Provider provider) throws NullPointerException, NoSuchAlgorithmException, IllegalArgumentException Returns a KeyFactory object that converts public/private keys of the specified algorithm.- Parameters:
algorithm- key algorithm.provider- an instance of the provider.- Returns:
- KeyFactory instance.
- Throws:
NullPointerException- if algorithm is null.NoSuchAlgorithmException- if a KeyFactorySpi implementation for the specified algorithm is not available from the specified provider.IllegalArgumentException- See Also:
-
keyAgreement
public static byte[] keyAgreement(String algorithm, Provider provider, Key privateKey, Key publicKey) throws NoSuchAlgorithmException, NullPointerException, InvalidKeyException Returns aKeyAgreementobject that implements the specified key agreement algorithm.- Parameters:
algorithm- the standard name of the requested key agreement algorithm.provider- the provider.privateKey- the party's private information.publicKey- the key for this phase.- Returns:
- the new buffer with the shared secret.
- Throws:
NoSuchAlgorithmException- if no Provider supports a KeyAgreementSpi implementation for the specified algorithm.NullPointerException- if algorithm is null.InvalidKeyException- if the given key is inappropriate for this key agreement or phase.- See Also:
-
keyStore
public static KeyStore keyStore(KeyStoreAlgorithms type, InputStream is, char[] password) throws KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException KeyStore util- Parameters:
type- KeyStore type.is- the input stream from which the keystore is loaded, ornull.password- the password used to check the integrity of the keystore, the password used to unlock the keystore, ornull.- Returns:
- KeyStore instance.
- Throws:
KeyStoreException- if no Provider supports a KeyStoreSpi implementation for the specified type.CertificateException- if any of the certificates in the keystore could not be loaded.IOException- if there is an I/O or format problem with the keystore data, if a password is required but not given, or if the given password was incorrect.NoSuchAlgorithmException- if the algorithm used to check the integrity of the keystore cannot be found.- See Also:
-
keyStore
public static KeyStore keyStore(KeyStoreAlgorithms type, KeyStore.LoadStoreParameter loadStore) throws KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException KeyStore util- Parameters:
type- KeyStore type.loadStore- theKeyStore.LoadStoreParameterthat specifies how to load the keystore, which may benull- Returns:
- KeyStore instance.
- Throws:
KeyStoreException- if no Provider supports a KeyStoreSpi implementation for the specified type.CertificateException- if any of the certificates in the keystore could not be loaded.IOException- if there is an I/O or format problem with the keystore data, if a password is required but not given, or if the given password was incorrect.NoSuchAlgorithmException- if the algorithm used to check the integrity of the keystore cannot be found.- See Also:
-