Package org.opensaml.security
Class SecurityProviderTestSupport
- java.lang.Object
-
- org.opensaml.security.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 StringBC_PROVIDER_NAMEprivate booleanhadBCOriginallystatic StringSUNEC_PROVIDER_NAME
-
Constructor Summary
Constructors Constructor Description SecurityProviderTestSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhaveBC()Return whether the Bouncy Castle provider is currently available.booleanhaveSunEC()Return whether the SunEC provider is currently available.booleanisOpenJDK()Determine 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 Detail
-
BC_PROVIDER_NAME
public static final String BC_PROVIDER_NAME
- See Also:
- Constant Field Values
-
SUNEC_PROVIDER_NAME
public static final String SUNEC_PROVIDER_NAME
- See Also:
- Constant Field Values
-
hadBCOriginally
private boolean hadBCOriginally
-
-
Method Detail
-
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
-
-