Class KeyStoreUtil
- java.lang.Object
-
- com.github.toolarium.security.keystore.util.KeyStoreUtil
-
public final class KeyStoreUtil extends java.lang.ObjectKeyStoreutil class.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.security.KeyStorecreateKeyStore(java.lang.String password)Create a new keystorejava.security.KeyStorecreateKeyStore(java.lang.String fileName, java.lang.String password)Create a new keystorejava.security.KeyStorecreatePKCS12KeyStore(java.lang.String provider, java.lang.String alias, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certificates, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password)Create a PKCS12 key storejavax.net.ssl.TrustManager[]getDefaultTrustManager()Get defaultTrustManager.javax.net.ssl.X509TrustManagergetDefaultX509TrustManager()Get defaultTrustManager.static KeyStoreUtilgetInstance()Get the instancejavax.net.ssl.TrustManager[]getTrustAllCertificateManager()Get aTrustManagerwhich trust all certificatesjava.security.KeyStorereadKeyStore(java.lang.String fileName, java.lang.String type, java.lang.String provider, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password)Read a file as key storeCertificateStorereadPKCS12KeyPair(java.lang.String fileName, java.lang.String provider, java.lang.String alias, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password)Read a PKCS12 file as key storejava.security.KeyStorereadPKCS12KeyStore(java.lang.String fileName, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password)Read a PKCS12 file as key storejava.security.KeyStorereadPKCS12KeyStore(java.lang.String fileName, java.lang.String provider, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password)Read a PKCS12 file as key storejava.security.KeyStorewritePKCS12KeyStore(java.lang.String fileName, java.lang.String provider, java.lang.String alias, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certificates, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password)Writes a PKCS12 file as key storejava.security.KeyStorewritePKCS12KeyStore(java.lang.String fileName, java.lang.String alias, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certificates, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password)Writes a PKCS12 file as key store
-
-
-
Method Detail
-
getInstance
public static KeyStoreUtil getInstance()
Get the instance- Returns:
- the instance
-
createKeyStore
public java.security.KeyStore createKeyStore(java.lang.String password) throws java.security.GeneralSecurityException, java.io.IOExceptionCreate a new keystore- Parameters:
password- the password or null- Returns:
- the new keystore
- Throws:
java.io.IOException- in case of a file read errorjava.security.GeneralSecurityException- in case of error
-
createKeyStore
public java.security.KeyStore createKeyStore(java.lang.String fileName, java.lang.String password) throws java.security.GeneralSecurityException, java.io.IOExceptionCreate a new keystore- Parameters:
fileName- the filenamepassword- the password or null- Returns:
- the new keystore
- Throws:
java.io.IOException- in case of a file read errorjava.security.GeneralSecurityException- in case of error
-
readPKCS12KeyStore
public java.security.KeyStore readPKCS12KeyStore(java.lang.String fileName, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password) throws java.security.GeneralSecurityException, java.io.IOExceptionRead a PKCS12 file as key store- Parameters:
fileName- the file to readpassword- the password or null- Returns:
- the key pairs
- Throws:
java.io.IOException- in case of a file read errorjava.security.GeneralSecurityException- in case of error
-
readPKCS12KeyStore
public java.security.KeyStore readPKCS12KeyStore(java.lang.String fileName, java.lang.String provider, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password) throws java.security.GeneralSecurityException, java.io.IOExceptionRead a PKCS12 file as key store- Parameters:
fileName- the file to readprovider- the provider or nullpassword- the password or null- Returns:
- the key pairs
- Throws:
java.io.IOException- in case of a file read errorjava.security.GeneralSecurityException- in case of error
-
readKeyStore
public java.security.KeyStore readKeyStore(java.lang.String fileName, java.lang.String type, java.lang.String provider, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password) throws java.security.GeneralSecurityException, java.io.IOExceptionRead a file as key store- Parameters:
fileName- the file to readtype- the key store typeprovider- the provider or nullpassword- the password or null- Returns:
- the key pairs
- Throws:
java.io.IOException- in case of a file read errorjava.security.GeneralSecurityException- in case of error
-
readPKCS12KeyPair
public CertificateStore readPKCS12KeyPair(java.lang.String fileName, java.lang.String provider, java.lang.String alias, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password) throws java.security.GeneralSecurityException, java.io.IOException
Read a PKCS12 file as key store- Parameters:
fileName- the file to readprovider- the provider or nullalias- the alias in the PKCS12 filepassword- the password or null- Returns:
- the certificate store
- Throws:
java.security.GeneralSecurityException- in case of errorjava.io.IOException- in case of error
-
writePKCS12KeyStore
public java.security.KeyStore writePKCS12KeyStore(java.lang.String fileName, java.lang.String alias, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certificates, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password) throws java.security.GeneralSecurityException, java.io.IOExceptionWrites a PKCS12 file as key store- Parameters:
fileName- the file to readalias- the alias in the PKCS12 file or nullprivateKey- the private keycertificates- the certificate chainpassword- the password or null- Returns:
- the written key store
- Throws:
java.security.GeneralSecurityException- in case of errorjava.io.IOException- in case of error
-
writePKCS12KeyStore
public java.security.KeyStore writePKCS12KeyStore(java.lang.String fileName, java.lang.String provider, java.lang.String alias, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certificates, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password) throws java.security.GeneralSecurityException, java.io.IOExceptionWrites a PKCS12 file as key store- Parameters:
fileName- the file to readprovider- the provider or nullalias- the alias in the PKCS12 file or nullprivateKey- the private keycertificates- the certificate chainpassword- the password or null- Returns:
- the written key store
- Throws:
java.security.GeneralSecurityException- in case of errorjava.io.IOException- in case of error
-
createPKCS12KeyStore
public java.security.KeyStore createPKCS12KeyStore(java.lang.String provider, java.lang.String alias, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certificates, com.github.toolarium.common.security.ISecuredValue<java.lang.String> password) throws java.security.GeneralSecurityException, java.io.IOExceptionCreate a PKCS12 key store- Parameters:
provider- the provider or nullalias- the alias in the PKCS12 file or nullprivateKey- the private keycertificates- the certificate chainpassword- the password or null- Returns:
- the written key store
- Throws:
java.security.GeneralSecurityException- in case of errorjava.io.IOException- in case of error
-
getDefaultX509TrustManager
public javax.net.ssl.X509TrustManager getDefaultX509TrustManager() throws java.security.GeneralSecurityExceptionGet defaultTrustManager.- Returns:
- the default trust manager or null
- Throws:
java.security.GeneralSecurityException- in case of error
-
getDefaultTrustManager
public javax.net.ssl.TrustManager[] getDefaultTrustManager() throws java.security.GeneralSecurityExceptionGet defaultTrustManager.- Returns:
- the default trust managers
- Throws:
java.security.GeneralSecurityException- in case of error
-
getTrustAllCertificateManager
public javax.net.ssl.TrustManager[] getTrustAllCertificateManager()
Get aTrustManagerwhich trust all certificates- Returns:
TrustManagerwhich trust all certificates
-
-