Package org.gluu.oxtrust.util
Class KeystoreWrapper
- java.lang.Object
-
- org.gluu.oxtrust.util.KeystoreWrapper
-
public class KeystoreWrapper extends java.lang.ObjectProvides utility methods for JKS KeyStores.- Author:
- Dmitry Ognyannikov, 2016
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringKEYSTORE_JCEKSOracle JDK / OpenJDK specificstatic java.lang.StringKEYSTORE_JKSOracle JDK / OpenJDK specificstatic java.lang.StringKEYSTORE_PKCS12Every 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 voidaddCertificate(java.security.cert.X509Certificate cert, java.lang.String alias)voidaddKey(javax.crypto.SecretKey key, java.lang.String alias, java.lang.String password)Add key.voiddeleteCertificate(java.lang.String alias)java.util.List<X509CertificateShortInfo>listCertificates()voidsave()voidsaveAs(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.CertificateExceptionOpen existing keystore or create new if don't exist.- Parameters:
filepath-password-type-- Throws:
java.security.KeyStoreExceptionjava.io.IOExceptionjava.security.NoSuchAlgorithmExceptionjava.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.KeyStoreExceptionjava.io.IOExceptionjava.security.NoSuchAlgorithmExceptionjava.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.KeyStoreExceptionjava.io.IOExceptionjava.security.NoSuchAlgorithmExceptionjava.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.KeyStoreExceptionAdd key. Use JCEKS keystore type to add symmetric key.- Parameters:
key-alias-password-- Throws:
java.security.KeyStoreException
-
-