Class KeyStoreFactoryBean


  • public class KeyStoreFactoryBean
    extends java.lang.Object
    A factory bean for a JCA KeyStore.

    This object holds the configurable properties of a key store and uses them to create and load a KeyStore instance.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String location  
      private java.lang.String password  
      private java.lang.String provider  
      private java.lang.String type  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.security.KeyStore createKeyStore()
      Creates a new KeyStore using the receiver's configuration.
      java.lang.String getLocation()
      Gets the location of the key store resource.
      java.lang.String getPassword()
      Gets the password to use to access the key store.
      java.lang.String getProvider()
      Gets the JCA key store provider name.
      java.lang.String getType()
      Gets the type of key store to load.
      private java.security.KeyStore newKeyStore()
      Invokes the appropriate JCE factory method to obtain a new KeyStore object.
      void setLocation​(java.lang.String location)
      Sets the location of the key store resource.
      void setPassword​(java.lang.String password)
      Sets the password to use to access the keystore.
      void setProvider​(java.lang.String provider)
      Sets the JCA key store provider name.
      void setType​(java.lang.String type)
      Sets the type of key store to load.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • location

        private java.lang.String location
      • provider

        private java.lang.String provider
      • type

        private java.lang.String type
      • password

        private java.lang.String password
    • Constructor Detail

      • KeyStoreFactoryBean

        public KeyStoreFactoryBean()
    • Method Detail

      • createKeyStore

        public java.security.KeyStore createKeyStore()
                                              throws java.security.NoSuchProviderException,
                                                     java.security.NoSuchAlgorithmException,
                                                     java.security.KeyStoreException
        Creates a new KeyStore using the receiver's configuration.
        Returns:
        key store
        Throws:
        java.security.NoSuchProviderException - if the provider specified by setProvider(String) is not known to the platform
        java.security.NoSuchAlgorithmException - if the key store type specified by setType(String) is not known to the specified provider (or the platform's default provider if the provider isn't specified)
        java.security.KeyStoreException - if some other error occurs in loading the key store from the resource specified by setLocation(String)
      • newKeyStore

        private java.security.KeyStore newKeyStore()
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.NoSuchProviderException,
                                                   java.security.KeyStoreException
        Invokes the appropriate JCE factory method to obtain a new KeyStore object.
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.NoSuchProviderException
        java.security.KeyStoreException
      • getLocation

        public java.lang.String getLocation()
        Gets the location of the key store resource.
        Returns:
        a String containing a URL for the resource
      • setLocation

        public void setLocation​(java.lang.String location)
        Sets the location of the key store resource.
        Parameters:
        location - a String containing a URL for the resource; if the URL string isn't prefixed by a scheme, the path is assumed to be relative to the root of the classpath.
      • getType

        public java.lang.String getType()
        Gets the type of key store to load.
        Returns:
        a key store type name (e.g. JKS); the SSL.DEFAULT_KEYSTORE_TYPE is returned if no type has been configured
      • setType

        public void setType​(java.lang.String type)
        Sets the type of key store to load.
        Parameters:
        type - a key store type name (e.g. JKS, PKCS12); the type specified must be supported by the provider specified by setProvider(String) or by the platform's default provider if no provider is specified
      • getProvider

        public java.lang.String getProvider()
        Gets the JCA key store provider name.
        Returns:
        provider name or null if no provider has been configured
      • setProvider

        public void setProvider​(java.lang.String provider)
        Sets the JCA key store provider name.
        Parameters:
        provider - name of the JCA provider to utilize in creating the key store
      • getPassword

        public java.lang.String getPassword()
        Gets the password to use to access the key store.
        Returns:
        password string; the SSL.DEFAULT_KEYSTORE_PASSWORD is returned if no password has been configured
      • setPassword

        public void setPassword​(java.lang.String password)
        Sets the password to use to access the keystore.
        Parameters:
        password - the password to set