Class CryptoFactoryBean

java.lang.Object
org.springframework.ws.soap.security.wss4j2.support.CryptoFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<org.apache.wss4j.common.crypto.Crypto>, org.springframework.beans.factory.InitializingBean

public class CryptoFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<org.apache.wss4j.common.crypto.Crypto>, org.springframework.beans.factory.InitializingBean
Spring factory bean for a WSS4J Crypto. Allows for strong-typed property configuration, or configuration through Properties.

Requires either individual properties, or the configuration property to be set.

Since:
2.3.0
Author:
Tareq Abed Rabbo, Arjen Poutsma, Jamin Hitchcock
See Also:
  • org.apache.ws.security.components.crypto.Crypto
  • Constructor Details

    • CryptoFactoryBean

      public CryptoFactoryBean()
  • Method Details

    • setConfiguration

      public void setConfiguration(Properties properties)
      Sets the configuration of the Crypto. Setting this property overrides all previously set configuration, through the type-safe properties
      See Also:
      • org.apache.ws.security.components.crypto.CryptoFactory#getInstance(java.util.Properties)
    • setCryptoProvider

      public void setCryptoProvider(Class<? extends org.apache.wss4j.common.crypto.Crypto> cryptoProviderClass)
      Sets the org.apache.ws.security.components.crypto.Crypto provider name. Defaults to org.apache.ws.security.components.crypto.Merlin.

      This property maps to the WSS4J org.apache.ws.security.crypto.provider property.

      Parameters:
      cryptoProviderClass - the crypto provider class
    • setKeyStoreLocation

      public void setKeyStoreLocation(org.springframework.core.io.Resource location) throws IOException
      Sets the location of the key store to be loaded in the org.apache.ws.security.components.crypto.Crypto instance.

      This property maps to the WSS4J org.apache.ws.security.crypto.merlin.file property.

      Parameters:
      location - the key store location
      Throws:
      IOException - when the resource cannot be opened
    • setKeyStoreProvider

      public void setKeyStoreProvider(String provider)
      Sets the key store provider.

      This property maps to the WSS4J org.apache.ws.security.crypto.merlin.keystore.provider property.

      Parameters:
      provider - the key store provider
    • setKeyStorePassword

      public void setKeyStorePassword(String password)
      Sets the key store password. Defaults to security.

      This property maps to the WSS4J org.apache.ws.security.crypto.merlin.keystore.password property.

      Parameters:
      password - the key store password
    • setKeyStoreType

      public void setKeyStoreType(String type)
      Sets the key store type. Defaults to KeyStore.getDefaultType().

      This property maps to the WSS4J org.apache.ws.security.crypto.merlin.keystore.type property.

      Parameters:
      type - the key store type
    • setTrustStorePassword

      public void setTrustStorePassword(String password)
      Sets the trust store password. Defaults to changeit.

      WSS4J crypto uses the standard J2SE trust store, i.e. $JAVA_HOME/lib/security/cacerts.

      This property maps to the WSS4J org.apache.ws.security.crypto.merlin.cacerts.password property.

      Parameters:
      password - the trust store password
    • setDefaultX509Alias

      public void setDefaultX509Alias(String defaultX509Alias)
      Sets the alias name of the default certificate which has been specified as a property. This should be the certificate that is used for signature and encryption. This alias corresponds to the certificate that should be used whenever KeyInfo is not present in a signed or an encrypted message.

      This property maps to the WSS4J org.apache.ws.security.crypto.merlin.keystore.alias property.

      Parameters:
      defaultX509Alias - alias name of the default X509 certificate
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • getObjectType

      public Class<org.apache.wss4j.common.crypto.Crypto> getObjectType()
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<org.apache.wss4j.common.crypto.Crypto>
    • isSingleton

      public boolean isSingleton()
      Specified by:
      isSingleton in interface org.springframework.beans.factory.FactoryBean<org.apache.wss4j.common.crypto.Crypto>
    • getObject

      public org.apache.wss4j.common.crypto.Crypto getObject() throws Exception
      Specified by:
      getObject in interface org.springframework.beans.factory.FactoryBean<org.apache.wss4j.common.crypto.Crypto>
      Throws:
      Exception