Java Code Examples for org.wildfly.security.manager.WildFlySecurityManager#clearPropertyPrivileged()

The following examples show how to use org.wildfly.security.manager.WildFlySecurityManager#clearPropertyPrivileged() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemPropertyValueWriteAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
                                       ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<SysPropValue> handbackHolder) throws OperationFailedException {

    final String name = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue();
    String setValue = resolvedValue.isDefined() ? resolvedValue.asString() : null;
    // This method will only be called if systemPropertyUpdater != null (see requiresRuntime())
    final boolean applyToRuntime = systemPropertyUpdater.isRuntimeSystemPropertyUpdateAllowed(name, setValue, context.isBooting());

    if (applyToRuntime) {
        final String oldValue = WildFlySecurityManager.getPropertyPrivileged(name, null);
        if (setValue != null) {
            WildFlySecurityManager.setPropertyPrivileged(name, setValue);
        } else {
            WildFlySecurityManager.clearPropertyPrivileged(name);
        }
        systemPropertyUpdater.systemPropertyUpdated(name, setValue);

        handbackHolder.setHandback(new SysPropValue(name, oldValue));
    }

    return !applyToRuntime;
}
 
Example 2
Source File: CLIEmbedServerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void setProperties(final String newBaseDir) {
    if (newBaseDir == null) {
        for (String prop : SERVER_PROPS) {
            WildFlySecurityManager.clearPropertyPrivileged(prop);
        }
        return;
    }
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_SERVER_BASE_DIR, newBaseDir);
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_SERVER_CONFIG_DIR, newBaseDir + File.separator + "configuration");
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_SERVER_DATA_DIR, newBaseDir + File.separator + "data");
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_SERVER_LOG_DIR, newBaseDir + File.separator + "log");
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_SERVER_TEMP_DIR, newBaseDir + File.separator + "tmp");
}
 
Example 3
Source File: CLIEmbedHostControllerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void setProperties(final String newBaseDir) {
    if (newBaseDir == null) {
        for (String prop : DOMAIN_PROPS) {
            WildFlySecurityManager.clearPropertyPrivileged(prop);
        }
        return;
    }
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_DOMAIN_BASE_DIR, newBaseDir);
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_DOMAIN_CONFIG_DIR, newBaseDir + File.separator + "configuration");
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_DOMAIN_DATA_DIR, newBaseDir + File.separator + "data");
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_DOMAIN_LOG_DIR, newBaseDir + File.separator + "log");
    WildFlySecurityManager.setPropertyPrivileged(JBOSS_DOMAIN_TEMP_DIR, newBaseDir + File.separator + "tmp");
}
 
Example 4
Source File: CliBootOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@After
public void tearDown() {
    if (container.isStarted()) {
        container.stop(true);
    }
    if (originalJvmArgs != null) {
        WildFlySecurityManager.setPropertyPrivileged("jvm.args", originalJvmArgs);
    } else {
        WildFlySecurityManager.clearPropertyPrivileged("jvm.args");
    }
}
 
Example 5
Source File: BootCliHookTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void testNoMarkerDirWhenSkippingReload() throws Exception {
    WildFlySecurityManager.setPropertyPrivileged(AdditionalBootCliScriptInvoker.SKIP_RELOAD_PROPERTY, "true");
    WildFlySecurityManager.clearPropertyPrivileged(AdditionalBootCliScriptInvoker.MARKER_DIRECTORY_PROPERTY);
    createCliScript("One\nTwo");
    WildFlySecurityManager.setPropertyPrivileged(AdditionalBootCliScriptInvoker.CLI_SCRIPT_PROPERTY, cliFile.getAbsolutePath());
    startController();
}
 
Example 6
Source File: SystemPropertyAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void setProperty(String name, String value) {
    if (value != null) {
        WildFlySecurityManager.setPropertyPrivileged(name, value);
    } else {
        WildFlySecurityManager.clearPropertyPrivileged(name);
    }
    if (systemPropertyUpdater != null) {
        systemPropertyUpdater.systemPropertyUpdated(name, value);
    }
}
 
Example 7
Source File: SystemPropertyValueWriteAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
                                     ModelNode valueToRestore, ModelNode valueToRevert, SysPropValue handback) throws OperationFailedException {
    if (handback != null) {
        if (handback.value != null) {
            WildFlySecurityManager.setPropertyPrivileged(handback.name, handback.value);
        } else {
            WildFlySecurityManager.clearPropertyPrivileged(handback.name);
        }

        systemPropertyUpdater.systemPropertyUpdated(handback.name, handback.value);

    }
}
 
Example 8
Source File: EnvironmentRestorer.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
void restoreEnvironment() {
    final Iterator<Map.Entry<String, String>> iter = propertiesToReset.entrySet().iterator();
    while (iter.hasNext()) {
        final Map.Entry<String, String> entry = iter.next();
        final String value = entry.getValue();
        if (value == null) {
            WildFlySecurityManager.clearPropertyPrivileged(entry.getKey());
        } else {
            WildFlySecurityManager.setPropertyPrivileged(entry.getKey(), value);
        }
        iter.remove();
    }
    StdioContext.setStdioContextSelector(new SimpleStdioContextSelector(defaultContexts.getStdioContext()));
    restoreLogContextSelector();
}
 
Example 9
Source File: PropertyReplacementTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@AfterClass
public static void cleanup() {
    WildFlySecurityManager.clearPropertyPrivileged(NODE_TYPE_PROP_NAME);
    WildFlySecurityManager.clearPropertyPrivileged(NODE_NAME_PROP_NAME);
    WildFlySecurityManager.clearPropertyPrivileged(OP_PROP_NAME);
    WildFlySecurityManager.clearPropertyPrivileged(OP_PROP_PROP_NAME);

    WildFlySecurityManager.clearPropertyPrivileged(PROP_PART1_NAME);
    WildFlySecurityManager.clearPropertyPrivileged(PROP_PART2_NAME);

    WildFlySecurityManager.clearPropertyPrivileged(PROP_RECURSIVE_NAME);
    WildFlySecurityManager.clearPropertyPrivileged(EMPTY_PROP_NAME);
}
 
Example 10
Source File: AbstractControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void clearProperties() {
    WildFlySecurityManager.clearPropertyPrivileged(CLI_SCRIPT_PROPERTY);
    WildFlySecurityManager.clearPropertyPrivileged(SKIP_RELOAD_PROPERTY);
    WildFlySecurityManager.clearPropertyPrivileged(MARKER_DIRECTORY_PROPERTY);
}