Class KeyStoreUtils

java.lang.Object
nl.altindag.ssl.util.KeyStoreUtils

public final class KeyStoreUtils extends Object
  • Field Details

    • LOGGER

      private static final nl.altindag.sude.Logger LOGGER
    • DUMMY_PASSWORD

      public static final String DUMMY_PASSWORD
      See Also:
    • KEYSTORE_TYPE

      private static final String KEYSTORE_TYPE
      See Also:
    • EMPTY_INPUT_STREAM_EXCEPTION_MESSAGE

      private static final String EMPTY_INPUT_STREAM_EXCEPTION_MESSAGE
      See Also:
    • KEYSTORE_NOT_FOUND_EXCEPTION_MESSAGE

      private static final UnaryOperator<String> KEYSTORE_NOT_FOUND_EXCEPTION_MESSAGE
    • EMPTY_TRUST_MANAGER_FOR_TRUSTSTORE_EXCEPTION

      private static final String EMPTY_TRUST_MANAGER_FOR_TRUSTSTORE_EXCEPTION
      See Also:
    • EMPTY_CERTIFICATES_EXCEPTION

      private static final String EMPTY_CERTIFICATES_EXCEPTION
      See Also:
  • Constructor Details

    • KeyStoreUtils

      private KeyStoreUtils()
  • Method Details

    • loadKeyStore

      public static KeyStore loadKeyStore(String keystorePath, char[] keystorePassword)
    • loadKeyStore

      public static KeyStore loadKeyStore(String keystorePath, char[] keystorePassword, String keystoreType)
    • loadKeyStore

      public static KeyStore loadKeyStore(String keystorePath, char[] keystorePassword, String keystoreType, String providerName)
    • loadKeyStore

      public static KeyStore loadKeyStore(String keystorePath, char[] keystorePassword, String keystoreType, Provider provider)
    • loadKeyStore

      private static KeyStore loadKeyStore(String keystorePath, KeyStoreUtils.KeyStoreFunction<InputStream,KeyStore> keyStoreKeyStoreFunction)
    • loadKeyStore

      public static KeyStore loadKeyStore(Path keystorePath, char[] keystorePassword)
    • loadKeyStore

      public static KeyStore loadKeyStore(Path keystorePath, char[] keystorePassword, String keystoreType)
    • loadKeyStore

      public static KeyStore loadKeyStore(Path keystorePath, char[] keystorePassword, String keystoreType, String providerName)
    • loadKeyStore

      public static KeyStore loadKeyStore(Path keystorePath, char[] keystorePassword, String keystoreType, Provider provider)
    • loadKeyStore

      private static KeyStore loadKeyStore(Path keystorePath, KeyStoreUtils.KeyStoreFunction<InputStream,KeyStore> mapper)
    • loadKeyStore

      public static KeyStore loadKeyStore(InputStream keystoreInputStream, char[] keystorePassword)
    • loadKeyStore

      public static KeyStore loadKeyStore(InputStream keystoreInputStream, char[] keystorePassword, String keystoreType)
    • loadKeyStore

      public static KeyStore loadKeyStore(InputStream keystoreInputStream, char[] keystorePassword, String keystoreType, String providerName)
    • loadKeyStore

      public static KeyStore loadKeyStore(InputStream keystoreInputStream, char[] keystorePassword, String keystoreType, Provider provider)
    • loadKeyStore

      private static KeyStore loadKeyStore(InputStream keystoreInputStream, char[] keystorePassword, KeyStoreUtils.KeyStoreSupplier keyStoreSupplier)
    • createIdentityStore

      public static KeyStore createIdentityStore(Key privateKey, char[] privateKeyPassword, String alias, List<? extends Certificate> certificateChain)
    • createIdentityStore

      public static KeyStore createIdentityStore(Key privateKey, char[] privateKeyPassword, List<? extends Certificate> certificateChain)
    • createIdentityStore

      @SafeVarargs public static <T extends Certificate> KeyStore createIdentityStore(Key privateKey, char[] privateKeyPassword, T... certificateChain)
    • createIdentityStore

      @SafeVarargs public static <T extends Certificate> KeyStore createIdentityStore(Key privateKey, char[] privateKeyPassword, String alias, T... certificateChain)
    • createKeyStore

      public static KeyStore createKeyStore()
    • createKeyStore

      public static KeyStore createKeyStore(char[] keyStorePassword)
    • createKeyStore

      public static KeyStore createKeyStore(String keyStoreType, char[] keyStorePassword)
    • createTrustStore

      @SafeVarargs public static <T extends X509TrustManager> KeyStore createTrustStore(T... trustManagers)
    • createTrustStore

      @SafeVarargs public static <T extends Certificate> KeyStore createTrustStore(T... certificates)
    • createTrustStore

      public static <T extends Certificate> KeyStore createTrustStore(List<T> certificates)
    • loadJdkKeyStore

      public static KeyStore loadJdkKeyStore()
    • loadSystemKeyStores

      public static List<KeyStore> loadSystemKeyStores()
    • loadSystemPropertyDerivedKeyStore

      public static KeyStore loadSystemPropertyDerivedKeyStore()
    • loadSystemPropertyDerivedTrustStore

      public static KeyStore loadSystemPropertyDerivedTrustStore()
    • loadSystemPropertyDerivedKeyStore

      private static KeyStore loadSystemPropertyDerivedKeyStore(String keyStorePathProperty, String keyStorePasswordProperty, String keyStoreTypeProperty, String keyStoreProviderProperty)
    • getCertificates

      public static List<Certificate> getCertificates(KeyStore keyStore)
    • getAliasToCertificate

      public static Map<String,Certificate> getAliasToCertificate(KeyStore keyStore)
    • getAliases

      public static List<String> getAliases(KeyStore keyStore)
    • containsCertificate

      public static <T extends Certificate> boolean containsCertificate(KeyStore keyStore, T certificate)
    • write

      public static void write(Path destination, KeyStore keyStore, char[] password)
    • add

      public static <T extends Certificate> void add(Path keystorePath, char[] password, String keystoreType, List<T> certificates)
      Adds the provides list of certificates to the given keystore path on the filesystem if exists. If the keystore is absent it will create it with the given password and also add the certificates.
    • add

      public static <T extends Certificate> void add(KeyStore keyStore, List<T> certificates)
    • countAmountOfTrustMaterial

      public static int countAmountOfTrustMaterial(KeyStore keyStore)
    • countAmountOfIdentityMaterial

      public static int countAmountOfIdentityMaterial(KeyStore keyStore)
    • containsTrustMaterial

      public static boolean containsTrustMaterial(KeyStore keyStore)
    • containsIdentityMaterial

      public static boolean containsIdentityMaterial(KeyStore keyStore)
    • amountOfSpecifiedMaterial

      private static int amountOfSpecifiedMaterial(KeyStore keyStore, KeyStoreUtils.KeyStoreBiPredicate<KeyStore,String> predicate, int upperBoundaryForMaterialCounter)