Class KeyStoreParameters

    • Field Detail

      • password

        protected String password
        The optional password for reading/opening/verifying the key store.
      • provider

        protected String provider
        The optional provider identifier for instantiating the key store.
      • keyStore

        protected KeyStore keyStore
        The optional key store, which has higher priority then value in resource below. If keyStore is non-null, resource isn't taken into account. This is helpful say for in-memory KeyStore composed by the user "on the fly".
      • resource

        protected String resource
        The optional file path, class path resource, or URL of the resource used to load the key store.
    • Constructor Detail

      • KeyStoreParameters

        public KeyStoreParameters()
    • Method Detail

      • setPassword

        public void setPassword​(String value)
        Set the optional password for reading/opening/verifying the key store.
        Parameters:
        value - the password value (may be null)
      • setProvider

        public void setProvider​(String value)
        Sets the optional provider identifier for instantiating the key store.
        Parameters:
        value - the provider identifier (may be null)
        See Also:
        Security.getProviders()
      • setResource

        public void setResource​(String value)
        Sets the optional file path, class path resource, or URL of the resource used to load the key store.
        Parameters:
        value - the resource (may be null)
      • setKeyStore

        public void setKeyStore​(KeyStore keyStore)
        Sets the optional key store, which has higher priority then value in resource. NB Don't forget to call setPassword() for password of this KeyStore.
        Parameters:
        keyStore - the KeyStore (may be null)
      • createKeyStore

        public KeyStore createKeyStore()
                                throws GeneralSecurityException,
                                       IOException
        Creates a KeyStoreParameters instance based off of the configuration state of this instance. If getType() returns null, the default key store type is loaded, otherwise the type will be of that specified.

        The created instance will always be loaded, but if the type requires an input stream and getResource() returns null, the instance will be empty. The loading of the resource, if not null, is attempted by treating the resource as a file path, a class path resource, and a URL in that order. An exception is thrown if the resource cannot be resolved to readable input stream using any of the above methods.

        Returns:
        a configured and loaded key store
        Throws:
        GeneralSecurityException - if there is an error creating an instance with the given configuration
        IOException - if there is an error resolving the configured resource to an input stream