Package net.sourceforge.jnlp.security
Class KeyStores
- java.lang.Object
-
- net.sourceforge.jnlp.security.KeyStores
-
public final class KeyStores extends java.lang.ObjectTheKeyStoresclass allows easily accessing the various KeyStores used.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeyStores.KeyStoreWithPathstatic classKeyStores.Levelstatic classKeyStores.Type
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringKEYSTORE_TYPEstatic java.util.Map<java.lang.Integer,java.lang.String>keystoresPathsprivate static LoggerLOG
-
Constructor Summary
Constructors Constructor Description KeyStores()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.security.KeyStorecreateKeyStoreFromFile(java.io.File file, boolean createIfNotFound)Reads the file (using the password) and uses it to create a newKeyStore.static java.util.List<java.security.KeyStore>getCAKeyStores()Returns an array of KeyStore that contain trusted CA certificates.static java.util.List<java.security.KeyStore>getCertKeyStores()Returns an array of KeyStore that contain certificates that are trusted.static java.util.List<java.security.KeyStore>getClientKeyStores()Returns KeyStores containing trusted client certificatesstatic KeyStores.KeyStoreWithPathgetKeyStore(KeyStores.Level level, KeyStores.Type type)Returns a KeyStore corresponding to the appropriate level level (user or system) and type.static InfrastructureFileDescriptorgetKeyStoreLocation(KeyStores.Level level, KeyStores.Type type)Returns the location of a KeyStore corresponding to the given level and type.static java.lang.StringgetPathToKeystore(java.security.KeyStore k)static java.lang.StringtoDisplayableString(KeyStores.Level level, KeyStores.Type type)Returns a human readable name for this KeyStorestatic java.lang.StringtoTranslatableString(KeyStores.Level level, KeyStores.Type type)Returns a String that can be used as a translation key to create a user-visible representation of this KeyStore.
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
keystoresPaths
public static final java.util.Map<java.lang.Integer,java.lang.String> keystoresPaths
-
KEYSTORE_TYPE
private static final java.lang.String KEYSTORE_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getKeyStore
public static KeyStores.KeyStoreWithPath getKeyStore(KeyStores.Level level, KeyStores.Type type)
Returns a KeyStore corresponding to the appropriate level level (user or system) and type.- Parameters:
level- whether the KeyStore desired is a user-level or system-level KeyStoretype- the type of KeyStore desired- Returns:
- a KeyStore containing certificates from the appropriate
-
getPathToKeystore
public static java.lang.String getPathToKeystore(java.security.KeyStore k)
-
getCertKeyStores
public static java.util.List<java.security.KeyStore> getCertKeyStores()
Returns an array of KeyStore that contain certificates that are trusted. The KeyStores contain certificates from different sources.- Returns:
- an array of KeyStore containing trusted Certificates
-
getCAKeyStores
public static java.util.List<java.security.KeyStore> getCAKeyStores()
Returns an array of KeyStore that contain trusted CA certificates.- Returns:
- an array of KeyStore containing trusted CA certificates
-
getClientKeyStores
public static java.util.List<java.security.KeyStore> getClientKeyStores()
Returns KeyStores containing trusted client certificates- Returns:
- an array of KeyStore objects that can be used to check client authentication certificates
-
getKeyStoreLocation
public static InfrastructureFileDescriptor getKeyStoreLocation(KeyStores.Level level, KeyStores.Type type)
Returns the location of a KeyStore corresponding to the given level and type.- Parameters:
level- the specified level of the key store to be returned.type- the specified type of the key store to be returned.- Returns:
- the location of the key store.
-
toTranslatableString
public static java.lang.String toTranslatableString(KeyStores.Level level, KeyStores.Type type)
Returns a String that can be used as a translation key to create a user-visible representation of this KeyStore. Creates a string by concatenating a level and type, converting everything to Title Case and removing the _'s. (USER,CA_CERTS) becomes UserCaCerts.- Parameters:
level- the level of the key store.type- the type of the key store.- Returns:
- the translation key.
-
toDisplayableString
public static java.lang.String toDisplayableString(KeyStores.Level level, KeyStores.Type type)
Returns a human readable name for this KeyStore- Parameters:
level- the level of the KeyStoretype- the type of KeyStore- Returns:
- a localized name for this KeyStore
-
createKeyStoreFromFile
private static java.security.KeyStore createKeyStoreFromFile(java.io.File file, boolean createIfNotFound) throws java.io.IOException, java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateExceptionReads the file (using the password) and uses it to create a newKeyStore. If the file does not exist and should not be created, it returns an empty but initialized KeyStore- Parameters:
file- the file to load information from- Returns:
- a KeyStore containing data from the file
- Throws:
java.io.IOExceptionjava.security.KeyStoreExceptionjava.security.NoSuchAlgorithmExceptionjava.security.cert.CertificateException
-
-