public class SecurityUtil
extends java.lang.Object
Constructor and Description |
---|
SecurityUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkTrustedCertsFile()
Checks the user's home directory to see if the trusted.certs file exists.
|
static java.security.KeyStore |
getCacertsKeyStore() |
static java.lang.String |
getCN(java.lang.String principal)
Extracts the CN field from a Certificate principal string.
|
static java.security.Key |
getKey(java.security.KeyStore ks,
java.lang.String alias) |
static java.security.KeyStore |
getSystemCertStore() |
static java.lang.String |
getTrustedCertsFilename() |
static java.security.KeyStore |
getUserKeyStore() |
static void |
initKeyManagerFactory(javax.net.ssl.KeyManagerFactory kmf,
java.security.KeyStore ks) |
static void |
loadKeyStore(java.security.KeyStore ks,
java.io.File f) |
static void |
setKeyEntry(java.security.KeyStore ks,
java.lang.String alias,
java.security.Key key,
java.security.cert.Certificate[] certChain) |
static void |
storeKeyStore(java.security.KeyStore ks,
java.io.File f) |
public static java.lang.String getTrustedCertsFilename() throws java.lang.Exception
java.lang.Exception
public static java.lang.String getCN(java.lang.String principal)
principal
- string, CN to be extracted frompublic static boolean checkTrustedCertsFile() throws java.lang.Exception
java.lang.Exception
- if check goes wrongpublic static java.security.KeyStore getUserKeyStore() throws java.lang.Exception
java.lang.Exception
- if getting failspublic static java.security.KeyStore getCacertsKeyStore() throws java.lang.Exception
java.lang.Exception
- if get failspublic static java.security.KeyStore getSystemCertStore() throws java.lang.Exception
java.lang.Exception
- if get goes wrongpublic static void initKeyManagerFactory(javax.net.ssl.KeyManagerFactory kmf, java.security.KeyStore ks) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.UnrecoverableKeyException
java.security.KeyStoreException
java.security.NoSuchAlgorithmException
java.security.UnrecoverableKeyException
public static void setKeyEntry(java.security.KeyStore ks, java.lang.String alias, java.security.Key key, java.security.cert.Certificate[] certChain) throws java.security.KeyStoreException
java.security.KeyStoreException
public static java.security.Key getKey(java.security.KeyStore ks, java.lang.String alias) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.UnrecoverableKeyException
java.security.KeyStoreException
java.security.NoSuchAlgorithmException
java.security.UnrecoverableKeyException
public static void loadKeyStore(java.security.KeyStore ks, java.io.File f) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
public static void storeKeyStore(java.security.KeyStore ks, java.io.File f) throws java.security.KeyStoreException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
java.security.KeyStoreException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException