Class SecurityProviderTestSupport

java.lang.Object
org.opensaml.security.testing.SecurityProviderTestSupport

public class SecurityProviderTestSupport extends Object
Testing utility class which providers various support functionality related to security providers and Java version, useful for testing cryptographic components.

One major feature is the ability to check and load the Bouncy Castle security provider for tests which require advanced crypto capabilities, and unload it afterwards, if it wasn't loaded originally. The goal of this is to preserve the pre-test condition of whether BC was originally loaded or not, so we don't muck with the environment of JVM in which the tests are running. For example, the JVM may actually have been configured with BC deliberately, so we don't want to unload it by mistake.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name of Bouncy Castle JCE provider.
    private boolean
    BC flag.
    static final String
    Name of Sun Elliptic Curve JCE provider.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Return whether the Bouncy Castle provider is currently available.
    boolean
    Return whether the SunEC provider is currently available.
    boolean
    Determine if we're running on OpenJDK.
    void
    Conditionally load the Bouncy Castle provider, if it isn't already loaded.
    void
    Conditionally unload the Bouncy Castle provider, if it wasn't loaded originally (outside of this class), and if it is currently loaded.

    Methods inherited from class java.lang.Object

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

    • BC_PROVIDER_NAME

      @Nonnull @NotEmpty public static final String BC_PROVIDER_NAME
      Name of Bouncy Castle JCE provider.
      See Also:
    • SUNEC_PROVIDER_NAME

      @Nonnull @NotEmpty public static final String SUNEC_PROVIDER_NAME
      Name of Sun Elliptic Curve JCE provider.
      See Also:
    • hadBCOriginally

      private boolean hadBCOriginally
      BC flag.
  • Constructor Details

    • SecurityProviderTestSupport

      public SecurityProviderTestSupport()
      Constructor.
  • Method Details

    • loadBC

      public void loadBC()
      Conditionally load the Bouncy Castle provider, if it isn't already loaded.
    • unloadBC

      public void unloadBC()
      Conditionally unload the Bouncy Castle provider, if it wasn't loaded originally (outside of this class), and if it is currently loaded.
    • haveBC

      public boolean haveBC()
      Return whether the Bouncy Castle provider is currently available.
      Returns:
      true or false
    • haveSunEC

      public boolean haveSunEC()
      Return whether the SunEC provider is currently available.
      Returns:
      true or false
    • isOpenJDK

      public boolean isOpenJDK()
      Determine if we're running on OpenJDK.
      Returns:
      true or false