Class KeystoreUtils

java.lang.Object
org.wso2.carbon.utils.security.KeystoreUtils

public class KeystoreUtils extends Object
A collection of key store and trust store related utility methods.
  • Constructor Details

    • KeystoreUtils

      public KeystoreUtils()
  • Method Details

    • getExtensionByFileType

      public static String getExtensionByFileType(String fileType)
      Get the file extension for give store file type (ex: .jks, .p12).
      Returns:
      File extension.
    • getFileTypeByExtension

      public static String getFileTypeByExtension(String extension) throws CarbonException
      Get the file type for give store file extension (ex: JKS, PKCS12).
      Returns:
      File type.
      Throws:
      CarbonException
    • getKeyStoreFileLocation

      public static String getKeyStoreFileLocation(String tenantDomain)
      Retrieve keystore file location.
      Returns:
      File location.
    • getKeyStoreFileLocation

      public static String getKeyStoreFileLocation(String ksName, String tenantDomain)
      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

      public static String getKeyStoreFileType(String tenantDomain)
      Retrieve keystore file type (ex: JKS, PKCS12).
      Parameters:
      tenantDomain - Tenant domain the keystore need to be resolved.
      Returns:
      File type.
    • getKeyStoreFileType

      public static String getKeyStoreFileType(String ksName, String tenantDomain)
      Retrieve keystore file type (ex: JKS, PKCS12).
      Parameters:
      tenantDomain - Tenant domain the keystore need to be resolved.
      Returns:
      File type.
    • getKeyStoreFileExtension

      public static String getKeyStoreFileExtension(String tenantDomain)
      Retrieve keystore file extension (ex: .jks, .p12).
      Returns:
      File extension.
    • getKeyStoreFileExtension

      public static String getKeyStoreFileExtension(String ksName, String tenantDomain)
      Retrieve keystore file extension (ex: .jks, .p12).
      Returns:
      File extension.
    • getTrustStoreFileLocation

      public static String getTrustStoreFileLocation()
      Retrieve truststore file location.
      Returns:
      File location.
    • getTrustStoreFileType

      public static String getTrustStoreFileType()
      Retrieve truststore file type (ex: JKS, PKCS12).
      Returns:
      File type.
    • getTrustStoreFileExtension

      public static String getTrustStoreFileExtension()
      Retrieve truststore file extension (ex: .jks, .p12).
      Returns:
      File extension.
    • getKeystoreInstance

      public static KeyStore getKeystoreInstance(String keyStoreType) throws KeyStoreException, NoSuchProviderException
      Returns a KeyStore instance 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:
      KeyStore instance.
      Throws:
      KeyStoreException - If the keystore type is unavailable.
      NoSuchProviderException - If the security provider is unavailable.