Package net.sourceforge.jnlp.security
Class SecurityUtil
java.lang.Object
net.sourceforge.jnlp.security.SecurityUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks the user's home directory to see if the trusted.certs file exists.static KeyStorestatic StringExtracts the CN field from a Certificate principal string.static Keystatic KeyStorestatic Stringstatic KeyStorestatic voidstatic voidloadKeyStore(KeyStore ks, File f) static voidsetKeyEntry(KeyStore ks, String alias, Key key, Certificate[] certChain) static voidstoreKeyStore(KeyStore ks, File f)
-
Constructor Details
-
SecurityUtil
public SecurityUtil()
-
-
Method Details
-
getTrustedCertsFilename
- Throws:
Exception
-
getCN
Extracts the CN field from a Certificate principal string. Or, if it can't find that, return the principal unmodified. This is a simple (and hence 'wrong') version. See http://www.ietf.org/rfc/rfc2253.txt for all the gory details.- Parameters:
principal- string, CN to be extracted from- Returns:
- extracted CN
-
checkTrustedCertsFile
Checks the user's home directory to see if the trusted.certs file exists. If it does not exist, it tries to create an empty keystore.- Returns:
- true if the trusted.certs file exists or a new trusted.certs was created successfully, otherwise false.
- Throws:
Exception- if check goes wrong
-
getUserKeyStore
- Returns:
- the keystore associated with the user's trusted.certs file, or null otherwise.
- Throws:
Exception- if getting fails
-
getCacertsKeyStore
- Returns:
- the keystore associated with the JDK cacerts file, or null otherwise.
- Throws:
Exception- if get fails
-
getSystemCertStore
- Returns:
- the keystore associated with the system certs file, or null otherwise.
- Throws:
Exception- if get goes wrong
-
initKeyManagerFactory
public static void initKeyManagerFactory(KeyManagerFactory kmf, KeyStore ks) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException -
setKeyEntry
public static void setKeyEntry(KeyStore ks, String alias, Key key, Certificate[] certChain) throws KeyStoreException - Throws:
KeyStoreException
-
getKey
public static Key getKey(KeyStore ks, String alias) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException -
loadKeyStore
public static void loadKeyStore(KeyStore ks, File f) throws IOException, NoSuchAlgorithmException, CertificateException -
storeKeyStore
public static void storeKeyStore(KeyStore ks, File f) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException
-