Enum KeyStoreFileType
- All Implemented Interfaces:
Serializable
,Comparable<KeyStoreFileType>
This enum represents the file type of a KeyStore or TrustStore. Currently, JKS (Java keystore),
PEM, PKCS12, and BCFKS types are supported.
This file has been copied from the Apache ZooKeeper project.
- See Also:
-
Enum Constant Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic KeyStoreFileType
fromFilename
(String filename) Detects the type of KeyStore / TrustStore file from the file extension.static KeyStoreFileType
fromPropertyValue
(String propertyValue) Converts a property value to a StoreFileType enum.static KeyStoreFileType
fromPropertyValueOrFileName
(String propertyValue, String filename) IfpropertyValue
is not null or empty, returns the result ofKeyStoreFileType.fromPropertyValue(propertyValue)
.The file extension that is associated with this file type.The property string that specifies that a key store or trust store should use this store file type.static KeyStoreFileType
Returns the enum constant of this type with the specified name.static KeyStoreFileType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
JKS
-
PEM
-
PKCS12
-
BCFKS
-
-
Field Details
-
defaultFileExtension
-
-
Constructor Details
-
KeyStoreFileType
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getPropertyValue
The property string that specifies that a key store or trust store should use this store file type. -
getDefaultFileExtension
The file extension that is associated with this file type. -
fromPropertyValue
Converts a property value to a StoreFileType enum. If the property value isnull
or an empty string, returnsnull
.- Parameters:
propertyValue
- the property value.- Returns:
- the KeyStoreFileType, or
null
ifpropertyValue
isnull
or empty. - Throws:
IllegalArgumentException
- ifpropertyValue
is not one of "JKS", "PEM", "BCFKS", "PKCS12", or empty/null.
-
fromFilename
Detects the type of KeyStore / TrustStore file from the file extension. If the file name ends with ".jks", returnsStoreFileType.JKS
. If the file name ends with ".pem", returnsStoreFileType.PEM
. If the file name ends with ".p12", returnsStoreFileType.PKCS12
. If the file name ends with ".bckfs", returnsStoreFileType.BCKFS
. Otherwise, throws an IllegalArgumentException.- Parameters:
filename
- the filename of the key store or trust store file.- Returns:
- a KeyStoreFileType.
- Throws:
IllegalArgumentException
- if the filename does not end with ".jks", ".pem", "p12" or "bcfks".
-
fromPropertyValueOrFileName
IfpropertyValue
is not null or empty, returns the result ofKeyStoreFileType.fromPropertyValue(propertyValue)
. Else, returns the result ofKeyStoreFileType.fromFileName(filename)
.- Parameters:
propertyValue
- property value describing the KeyStoreFileType, or null/empty to auto-detect the type from the file name.filename
- file name of the key store file. The file extension is used to auto-detect the KeyStoreFileType whenpropertyValue
is null or empty.- Returns:
- a KeyStoreFileType.
- Throws:
IllegalArgumentException
- ifpropertyValue
is not one of "JKS", "PEM", "PKCS12", "BCFKS", or empty/null.IllegalArgumentException
- ifpropertyValue
is empty or null and the type could not be determined from the file name.
-