Class SecureRandomFactoryBean


  • public class SecureRandomFactoryBean
    extends java.lang.Object
    A factory bean for a JCA SecureRandom generator.

    This object holds the configurable properties of a secure random generator and uses them to create and load a SecureRandom instance.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.security.SecureRandom createSecureRandom()
      Creates a new SecureRandom generator using the receiver's configuration.
      java.lang.String getAlgorithm()
      Gets the secure random generator algorithm name.
      java.lang.String getProvider()
      Gets the JCA provider name for the secure random generator.
      void setAlgorithm​(java.lang.String algorithm)
      Sets the secure random generator algorithm name.
      void setProvider​(java.lang.String provider)
      Sets the JCA provider name for the secure random generator.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SecureRandomFactoryBean

        public SecureRandomFactoryBean()
    • Method Detail

      • createSecureRandom

        public java.security.SecureRandom createSecureRandom()
                                                      throws java.security.NoSuchProviderException,
                                                             java.security.NoSuchAlgorithmException
        Creates a new SecureRandom generator using the receiver's configuration.
        Returns:
        secure random generator instance
        Throws:
        java.security.NoSuchProviderException - if the provider name specified by setProvider(String) is not known to the platform
        java.security.NoSuchAlgorithmException - if the algorithm name specified by setAlgorithm(String) is not recognized by the specified provider (or the platform's default provider if the provider isn't specified)
      • getAlgorithm

        public java.lang.String getAlgorithm()
        Gets the secure random generator algorithm name.
        Returns:
        an algorithm name (e.g. SHA1PRNG); the SSL.DEFAULT_SECURE_RANDOM_ALGORITHM is returned if no algorithm has been specified
      • setAlgorithm

        public void setAlgorithm​(java.lang.String algorithm)
        Sets the secure random generator algorithm name.
        Parameters:
        algorithm - an algorithm name, which must be recognized by the provider specified via setProvider(String) or by the platform's default provider if no provider is specified.
      • getProvider

        public java.lang.String getProvider()
        Gets the JCA provider name for the secure random generator.
        Returns:
        provider name
      • setProvider

        public void setProvider​(java.lang.String provider)
        Sets the JCA provider name for the secure random generator.
        Parameters:
        provider - name of the JCA provider to utilize in creating the secure random generator