Package org.gluu.oxtrust.util
Class KeystoreWrapper
- java.lang.Object
-
- org.gluu.oxtrust.util.KeystoreWrapper
-
public class KeystoreWrapper extends java.lang.Object
Provides utility methods for JKS KeyStores.- Author:
- Dmitry Ognyannikov, 2016
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEYSTORE_JCEKS
Oracle JDK / OpenJDK specificstatic java.lang.String
KEYSTORE_JKS
Oracle JDK / OpenJDK specificstatic java.lang.String
KEYSTORE_PKCS12
Every implementation of the Java platform is required to support the following standard KeyStore type: PKCS12
-
Constructor Summary
Constructors Constructor Description KeystoreWrapper(java.lang.String filepath, java.lang.String password, java.lang.String type)
Open existing keystore or create new if don't exist.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCertificate(java.security.cert.X509Certificate cert, java.lang.String alias)
void
addKey(javax.crypto.SecretKey key, java.lang.String alias, java.lang.String password)
Add key.void
deleteCertificate(java.lang.String alias)
java.util.List<X509CertificateShortInfo>
listCertificates()
void
save()
void
saveAs(java.lang.String filepath, java.lang.String password)
-
-
-
Field Detail
-
KEYSTORE_PKCS12
public static final java.lang.String KEYSTORE_PKCS12
Every implementation of the Java platform is required to support the following standard KeyStore type: PKCS12- See Also:
- Constant Field Values
-
KEYSTORE_JKS
public static final java.lang.String KEYSTORE_JKS
Oracle JDK / OpenJDK specific- See Also:
- Constant Field Values
-
KEYSTORE_JCEKS
public static final java.lang.String KEYSTORE_JCEKS
Oracle JDK / OpenJDK specific- See Also:
- Constant Field Values
-
-
Constructor Detail
-
KeystoreWrapper
public KeystoreWrapper(java.lang.String filepath, java.lang.String password, java.lang.String type) throws java.security.KeyStoreException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
Open existing keystore or create new if don't exist.- Parameters:
filepath
-password
-type
-- Throws:
java.security.KeyStoreException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
-
-
Method Detail
-
save
public void save() throws java.security.KeyStoreException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
- Throws:
java.security.KeyStoreException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
-
saveAs
public void saveAs(java.lang.String filepath, java.lang.String password) throws java.security.KeyStoreException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
- Throws:
java.security.KeyStoreException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
-
listCertificates
public java.util.List<X509CertificateShortInfo> listCertificates() throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
deleteCertificate
public void deleteCertificate(java.lang.String alias) throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
addCertificate
public void addCertificate(java.security.cert.X509Certificate cert, java.lang.String alias) throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
addKey
public void addKey(javax.crypto.SecretKey key, java.lang.String alias, java.lang.String password) throws java.security.KeyStoreException
Add key. Use JCEKS keystore type to add symmetric key.- Parameters:
key
-alias
-password
-- Throws:
java.security.KeyStoreException
-
-