Package org.opensaml.security.testing
Class SecurityProviderTestSupport
java.lang.Object
org.opensaml.security.testing.SecurityProviderTestSupport
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanhaveBC()Return whether the Bouncy Castle provider is currently available.booleanReturn whether the SunEC provider is currently available.booleanDetermine if we're running on OpenJDK.voidloadBC()Conditionally load the Bouncy Castle provider, if it isn't already loaded.voidunloadBC()Conditionally unload the Bouncy Castle provider, if it wasn't loaded originally (outside of this class), and if it is currently loaded.
-
Field Details
-
BC_PROVIDER_NAME
Name of Bouncy Castle JCE provider.- See Also:
-
SUNEC_PROVIDER_NAME
Name of Sun Elliptic Curve JCE provider.- See Also:
-
hadBCOriginally
private boolean hadBCOriginallyBC 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
-