Package org.wso2.carbon.utils.security
Class KeystoreUtils
java.lang.Object
org.wso2.carbon.utils.security.KeystoreUtils
A collection of key store and trust store related utility methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA collection of file type extensions against the store file type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetExtensionByFileType(String fileType) Get the file extension for give store file type (ex: .jks, .p12).static StringgetFileTypeByExtension(String extension) Get the file type for give store file extension (ex: JKS, PKCS12).static StringgetKeyStoreFileExtension(String tenantDomain) Retrieve keystore file extension (ex: .jks, .p12).static StringgetKeyStoreFileExtension(String ksName, String tenantDomain) Retrieve keystore file extension (ex: .jks, .p12).static StringgetKeyStoreFileLocation(String tenantDomain) Retrieve keystore file location.static StringgetKeyStoreFileLocation(String ksName, String tenantDomain) Retrieve keystore file location for a given context.static StringgetKeyStoreFileType(String tenantDomain) Retrieve keystore file type (ex: JKS, PKCS12).static StringgetKeyStoreFileType(String ksName, String tenantDomain) Retrieve keystore file type (ex: JKS, PKCS12).static KeyStoregetKeystoreInstance(String keyStoreType) Returns aKeyStoreinstance for the given type.static StringRetrieve truststore file extension (ex: .jks, .p12).static StringRetrieve truststore file location.static StringRetrieve truststore file type (ex: JKS, PKCS12).
-
Constructor Details
-
KeystoreUtils
public KeystoreUtils()
-
-
Method Details
-
getExtensionByFileType
Get the file extension for give store file type (ex: .jks, .p12).- Returns:
- File extension.
-
getFileTypeByExtension
Get the file type for give store file extension (ex: JKS, PKCS12).- Returns:
- File type.
- Throws:
CarbonException
-
getKeyStoreFileLocation
Retrieve keystore file location.- Returns:
- File location.
-
getKeyStoreFileLocation
Retrieve keystore file location for a given context. This won't consider the server configuration for super tenant as the context is provided.- Returns:
- File location.
-
getKeyStoreFileType
Retrieve keystore file type (ex: JKS, PKCS12).- Parameters:
tenantDomain- Tenant domain the keystore need to be resolved.- Returns:
- File type.
-
getKeyStoreFileType
Retrieve keystore file type (ex: JKS, PKCS12).- Parameters:
tenantDomain- Tenant domain the keystore need to be resolved.- Returns:
- File type.
-
getKeyStoreFileExtension
Retrieve keystore file extension (ex: .jks, .p12).- Returns:
- File extension.
-
getKeyStoreFileExtension
Retrieve keystore file extension (ex: .jks, .p12).- Returns:
- File extension.
-
getTrustStoreFileLocation
Retrieve truststore file location.- Returns:
- File location.
-
getTrustStoreFileType
Retrieve truststore file type (ex: JKS, PKCS12).- Returns:
- File type.
-
getTrustStoreFileExtension
Retrieve truststore file extension (ex: .jks, .p12).- Returns:
- File extension.
-
getKeystoreInstance
public static KeyStore getKeystoreInstance(String keyStoreType) throws KeyStoreException, NoSuchProviderException Returns aKeyStoreinstance for the given type. Uses the BouncyCastle provider for the p12 file type, otherwise the default JCE provider.- Parameters:
keyStoreType- The type of the keystore.- Returns:
KeyStoreinstance.- Throws:
KeyStoreException- If the keystore type is unavailable.NoSuchProviderException- If the security provider is unavailable.
-