Package org.forgerock.openig.util
Class KeyStoreUtil
- java.lang.Object
-
- org.forgerock.openig.util.KeyStoreUtil
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Key
getKey(KeyStore keyStore, String alias, String password)
static Key
getPublicKey(KeyStore keyStore, String alias, String password)
Retrieve the public key from the keystore: it could be a certificate or a symmetric key.static String
storeTypeFromKeyStore(String filename)
Get default keystore type based on the keystore filename.
-
-
-
Method Detail
-
getKey
public static Key getKey(KeyStore keyStore, String alias, String password)
- Parameters:
keyStore
- The storage facility for cryptographic keys and certificates to search for the given key.alias
- The alias associated with the key.password
- The password for recovering the key.- Returns:
- a
Key
or anIllegalArgumentException
if it fails. - Throws:
IllegalArgumentException
- If the key was not retrieved or if an exception occurred.
-
getPublicKey
public static Key getPublicKey(KeyStore keyStore, String alias, String password)
Retrieve the public key from the keystore: it could be a certificate or a symmetric key.- Parameters:
keyStore
- The keystore where to find the key.alias
- The alias associated with the key.password
- The keystore password, could benull
if the key is not symmetric. (Only symmetric key,SecretKey
will require a password).- Returns:
- The public key: certificate for asymmetric keys or SecretKey for symmetric keys, stored in the keystore.
-
-