Class SecurityUtil
java.lang.Object
net.sourceforge.jnlp.security.SecurityUtil
-
Field Summary
Fields -
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 voidprivate static booleanisHexDigit(char ch) static voidloadKeyStore(KeyStore ks, File f) static voidsetKeyEntry(KeyStore ks, String alias, Key key, Certificate[] certChain) static voidstoreKeyStore(KeyStore ks, File f) private static RuntimeException
-
Field Details
-
LOG
-
-
Constructor Details
-
SecurityUtil
public SecurityUtil()
-
-
Method Details
-
getTrustedCertsFilename
-
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
-
isHexDigit
private static boolean isHexDigit(char ch) -
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
-
getCacertsKeyStore
-
getSystemCertStore
-
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 -
unexpectedException
-