/** * Initializer for this class. Logs whether the security manager is enabled or not. */ public CoreSpringModuleConfig() { LOGGER.debug("Security manager is " + (SecurityManagerHelper.isSecurityManagerEnabled() ? "ENABLED" : "DISABLED")); }
/** * Initializer for this class. Logs whether the security manager is enabled or not. */ public CoreSpringModuleConfig() { LOGGER.debug("Security manager is " + (SecurityManagerHelper.isSecurityManagerEnabled() ? "ENABLED" : "DISABLED")); }
/** * When {@link org.finra.herd.core.helper.SecurityManagerHelper#doPrivileged(PrivilegedAction)} is called which executes an action restricted by security manager, the method should * throw an {@link AccessControlException}. * If SecurityManager is disabled, this test asserts that no exception was thrown. */ @Test public void testDoPrivilegedWhenNoPermissionsRestrictedActionThrows() { Class<? extends Exception> expectedExceptionType = null; if (SecurityManagerHelper.isSecurityManagerEnabled()) { expectedExceptionType = AccessControlException.class; } testDoPrivileged(expectedExceptionType, new PrivilegedAction<Void>() { @Override public Void run() { System.getProperty("test"); return null; } }); }
/** * Asserts that an {@link AccessControlException} is thrown when a SecurityManager restricted action is taken under * {@link SecurityManagerHelper#doPrivileged(PrivilegedAction, Collection)} where a permission is given, but it does not match the action that is being * executed. * This test asserts that no exception is thrown when {@link SecurityManager} is disabled. */ @Test public void testDoPrivilegedWhenNoMatchingPermission() { Class<? extends Exception> expectedException = null; if (SecurityManagerHelper.isSecurityManagerEnabled()) { expectedException = AccessControlException.class; } testDoPrivileged(expectedException, new PrivilegedAction<Void>() { @Override public Void run() { System.getProperty("test"); return null; } }, Arrays.<Permission> asList(new PropertyPermission("anotherValue", "read"))); }