org.wildfly.security.manager.WildFlySecurityManager Java Examples

The following examples show how to use org.wildfly.security.manager.WildFlySecurityManager. 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: ServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static int getCorePoolSize(boolean forDomain) {
    String val = WildFlySecurityManager.getPropertyPrivileged(CONFIG_SYS_PROP, null);
    if (val != null) {
        try {
            int result = Integer.parseInt(val);
            if (result >= 0) {
                return result;
            } else {
                ServerLogger.ROOT_LOGGER.invalidPoolCoreSize(val, CONFIG_SYS_PROP);
            }
        } catch (NumberFormatException nfe) {
            ServerLogger.ROOT_LOGGER.invalidPoolCoreSize(val, CONFIG_SYS_PROP);
        }

    }
    return forDomain ? DEFAULT_DOMAIN_CORE_POOL_SIZE : DEFAULT_CORE_POOL_SIZE;
}
 
Example #2
Source File: BlockingTimeoutImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/** Allows testsuites to shorten the domain timeout adder */
private static int resolveDomainTimeoutAdder() {
    String propValue = WildFlySecurityManager.getPropertyPrivileged(DOMAIN_TEST_SYSTEM_PROPERTY, DEFAULT_DOMAIN_TIMEOUT_STRING);
    if (sysPropDomainValue == null || !sysPropDomainValue.equals(propValue)) {
        // First call or the system property changed
        sysPropDomainValue = propValue;
        int number = -1;
        try {
            number = Integer.valueOf(sysPropDomainValue);
        } catch (NumberFormatException nfe) {
            // ignored
        }

        if (number > 0) {
            defaultDomainValue = number; // this one is in ms
        } else {
            ControllerLogger.MGMT_OP_LOGGER.invalidDefaultBlockingTimeout(sysPropDomainValue, DOMAIN_TEST_SYSTEM_PROPERTY, DEFAULT_DOMAIN_TIMEOUT_ADDER);
            defaultDomainValue = DEFAULT_DOMAIN_TIMEOUT_ADDER;
        }
    }
    return defaultDomainValue;
}
 
Example #3
Source File: BlockingTimeoutImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static int resolveDefaultTimeout() {
    String propValue = WildFlySecurityManager.getPropertyPrivileged(SYSTEM_PROPERTY, DEFAULT_TIMEOUT_STRING);
    if (sysPropLocalValue == null || !sysPropLocalValue.equals(propValue)) {
        // First call or the system property changed
        sysPropLocalValue = propValue;
        int number = -1;
        try {
            number = Integer.valueOf(sysPropLocalValue);
        } catch (NumberFormatException nfe) {
            // ignored
        }

        if (number > 0) {
            defaultLocalValue = number * 1000; // seconds to ms
        } else {
            ControllerLogger.MGMT_OP_LOGGER.invalidDefaultBlockingTimeout(sysPropLocalValue, SYSTEM_PROPERTY, DEFAULT_TIMEOUT);
            defaultLocalValue = DEFAULT_TIMEOUT * 1000; // seconds to ms
        }
    }
    return defaultLocalValue;
}
 
Example #4
Source File: WildFlyAcmeClient.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void cleanupAfterChallenge(AcmeAccount account, AcmeChallenge challenge) throws AcmeException {
    Assert.checkNotNullParam("account", account);
    Assert.checkNotNullParam("challenge", challenge);
    // ensure the token is valid before proceeding
    String token = challenge.getToken();
    if (! token.matches(TOKEN_REGEX)) {
        throw ROOT_LOGGER.invalidCertificateAuthorityChallenge();
    }

    // delete the file that was created to prove identifier control
    String responseFilePath = WildFlySecurityManager.getPropertyPrivileged("jboss.home.dir", ".") + ACME_CHALLENGE_PREFIX + token;
    File responseFile = new File(responseFilePath);
    if (responseFile.exists()) {
        responseFile.delete();
    }
}
 
Example #5
Source File: LongOutputTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@After
public void tearDown() throws Exception {
    afterTest();
    readThreadActive.set(false);
    if (ctx != null) {
        ctx.terminateSession();
    }
    for (Thread thread : threads) {
        thread.join(5000);
        if (thread.isAlive()) {
            thread.interrupt();
        }
        waitFor(() -> !thread.isAlive(), 10000);
    }
    threads.removeAll(threads);
    IOUtil.close(consoleInput);
    IOUtil.close(consoleWriter);
    IOUtil.close(consoleOutput);
    IOUtil.close(consoleReader);

    // return back original value for jboss.cli.config property
    WildFlySecurityManager.setPropertyPrivileged("jboss.cli.config", originalCliConfig);
}
 
Example #6
Source File: DomainServerCommunicationServices.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void activate(final ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {
    final ServiceTarget serviceTarget = serviceActivatorContext.getServiceTarget();
    final ServiceName endpointName = managementSubsystemEndpoint ? RemotingServices.SUBSYSTEM_ENDPOINT : ManagementRemotingServices.MANAGEMENT_ENDPOINT;
    final EndpointService.EndpointType endpointType = managementSubsystemEndpoint ? EndpointService.EndpointType.SUBSYSTEM : EndpointService.EndpointType.MANAGEMENT;
    try {
        ManagementWorkerService.installService(serviceTarget);
        // TODO see if we can figure out a way to work in the vault resolver instead of having to use ExpressionResolver.SIMPLE
        @SuppressWarnings("deprecation")
        final OptionMap options = EndpointConfigFactory.create(ExpressionResolver.SIMPLE, endpointConfig, DEFAULTS);
        ManagementRemotingServices.installRemotingManagementEndpoint(serviceTarget, endpointName, WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null), endpointType, options);

        // Install the communication services
        final ServiceBuilder<?> sb = serviceTarget.addService(HostControllerConnectionService.SERVICE_NAME);
        final Supplier<ExecutorService> esSupplier = Services.requireServerExecutor(sb);
        final Supplier<ScheduledExecutorService> sesSupplier = sb.requires(ServerService.JBOSS_SERVER_SCHEDULED_EXECUTOR);
        final Supplier<Endpoint> eSupplier = sb.requires(endpointName);
        final Supplier<ProcessStateNotifier> cpsnSupplier = sb.requires(ControlledProcessStateService.INTERNAL_SERVICE_NAME);
        sb.setInstance(new HostControllerConnectionService(managementURI, serverName, serverProcessName, authKey, initialOperationID, managementSubsystemEndpoint, sslContextSupplier, esSupplier, sesSupplier, eSupplier, cpsnSupplier));
        sb.install();
    } catch (OperationFailedException e) {
        throw new ServiceRegistryException(e);
    }
}
 
Example #7
Source File: DeferredExtensionContext.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private XMLStreamException loadModule(final String moduleName, final XMLMapper xmlMapper) throws XMLStreamException {
    // Register element handlers for this extension
    try {
        final Module module = moduleLoader.loadModule(ModuleIdentifier.fromString(moduleName));
        boolean initialized = false;
        for (final Extension extension : module.loadService(Extension.class)) {
            ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(extension.getClass());
            try {
                extensionRegistry.initializeParsers(extension, moduleName, xmlMapper);
            } finally {
                WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
            }
            if (!initialized) {
                initialized = true;
            }
        }
        if (!initialized) {
            throw ControllerLogger.ROOT_LOGGER.notFound("META-INF/services/", Extension.class.getName(), module.getName());
        }
        return null;
    } catch (final ModuleLoadException e) {
        throw ControllerLogger.ROOT_LOGGER.failedToLoadModule(e);
    }
}
 
Example #8
Source File: EmbedHostControllerHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private File getJBossHome(final ParsedCommandLine parsedCmd) throws CommandLineException {
    String jbossHome = this.jbossHome == null ? null : this.jbossHome.getValue(parsedCmd);
    if (jbossHome == null || jbossHome.length() == 0) {
        jbossHome = WildFlySecurityManager.getEnvPropertyPrivileged("JBOSS_HOME", null);
        if (jbossHome == null || jbossHome.length() == 0) {
            if (this.jbossHome != null) {
                throw new CommandLineException("Missing configuration value for --jboss-home and environment variable JBOSS_HOME is not set");
            } else {
                throw new CommandLineException("Environment variable JBOSS_HOME is not set");
            }
        }
        return validateJBossHome(jbossHome, "environment variable JBOSS_HOME");
    } else {
        return validateJBossHome(jbossHome, "argument --jboss-home");
    }
}
 
Example #9
Source File: WildFlyAcmeClient.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public AcmeChallenge proveIdentifierControl(AcmeAccount account, List<AcmeChallenge> challenges) throws AcmeException {
    Assert.checkNotNullParam("account", account);
    Assert.checkNotNullParam("challenges", challenges);
    AcmeChallenge selectedChallenge = null;
    for (AcmeChallenge challenge : challenges) {
        if (challenge.getType() == AcmeChallenge.Type.HTTP_01) {
            selectedChallenge = challenge;
            break;
        }
    }

    // ensure the token is valid before proceeding
    String token = selectedChallenge.getToken();
    if (! token.matches(TOKEN_REGEX)) {
        throw ROOT_LOGGER.invalidCertificateAuthorityChallenge();
    }

    // respond to the http challenge
    String responseFilePath = WildFlySecurityManager.getPropertyPrivileged("jboss.home.dir", ".") + ACME_CHALLENGE_PREFIX + token;
    try (FileOutputStream fos = new FileOutputStream(responseFilePath)) {
        fos.write(selectedChallenge.getKeyAuthorization(account).getBytes(StandardCharsets.US_ASCII));
    } catch (IOException e) {
        throw ROOT_LOGGER.unableToRespondToCertificateAuthorityChallenge(e, e.getLocalizedMessage());
    }
    return selectedChallenge;
}
 
Example #10
Source File: SecurityActions.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static Configuration getGlobalJaasConfiguration() throws SecurityException {
    if (WildFlySecurityManager.isChecking() == false) {
        return internalGetGlobalJaasConfiguration();
    } else {

        try {
            return doPrivileged(new PrivilegedExceptionAction<Configuration>() {

                @Override
                public Configuration run() throws Exception {
                    return internalGetGlobalJaasConfiguration();
                }

            });
        } catch (PrivilegedActionException e) {
            throw (SecurityException) e.getCause();
        }

    }
}
 
Example #11
Source File: AccessAuditContext.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private AccessAuditContext(final boolean inflowed, final SecurityIdentity securityIdentity, final InetAddress remoteAddress, final AccessAuditContext previous) {
    // This can only be instantiated as part of the doAs call.
    this.securityIdentity = securityIdentity;
    // The address would be set on the first context in the stack so use it.
    if (previous != null) {
        domainUuid = previous.domainUuid;
        accessMechanism = previous.accessMechanism;
        domainRollout = previous.domainRollout;
        this.remoteAddress = previous.remoteAddress;
        this.inflowed = previous.inflowed;
    } else {
        this.inflowed = inflowed;
        this.remoteAddress = remoteAddress;
    }

    // This is checked here so code can not obtain a reference to an AccessAuditContext with an inflowed identity and then
    // use it swap in any arbitrary identity.
    if (this.inflowed && WildFlySecurityManager.isChecking()) {
        System.getSecurityManager().checkPermission(ControllerPermission.INFLOW_SECURITY_IDENTITY);
    }
}
 
Example #12
Source File: CliBootOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Before
public void setup() throws Exception {
    originalJvmArgs = WildFlySecurityManager.getPropertyPrivileged("jvm.args", null);
    timestamp = String.valueOf(System.currentTimeMillis());
    File target = new File("target").getAbsoluteFile();
    if (!Files.exists(target.toPath())) {
        throw new IllegalStateException("No target/ directory");
    }

    File parent = new File(target, "cli-boot-ops");
    if (!Files.exists(parent.toPath())) {
        Files.createDirectories(parent.toPath());
    }

    markerDirectory = new File(parent, timestamp);
    if (Files.exists(markerDirectory.toPath())) {
        throw new IllegalStateException(markerDirectory.getAbsolutePath() + " already exists");
    }

}
 
Example #13
Source File: SecurityActions.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static void setGlobalJaasConfiguration(final Configuration configuration) throws SecurityException {
    if (WildFlySecurityManager.isChecking() == false) {
        internalSetGlobalJaasConfiguration(configuration);
    } else {

        try {
            doPrivileged(new PrivilegedExceptionAction<Void>() {

                @Override
                public Void run() throws Exception {
                    internalSetGlobalJaasConfiguration(configuration);

                    return null;
                }

            });
        } catch (PrivilegedActionException e) {
            throw (SecurityException) e.getCause();
        }

    }
}
 
Example #14
Source File: PluggableMBeanServerImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private ClassLoader pushClassLoader(final ObjectName name) throws InstanceNotFoundException {
    ClassLoader mbeanCl;
    try {
        mbeanCl = doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
            public ClassLoader run() throws InstanceNotFoundException {
                return delegate.getClassLoaderFor(name);
            }
        });
    } catch (PrivilegedActionException e) {
        try {
            throw e.getCause();
        } catch (RuntimeException r) {
            throw r;
        } catch (InstanceNotFoundException ie) {
            throw ie;
        } catch (Error error) {
            throw error;
        } catch (Throwable throwable) {
            throw new UndeclaredThrowableException(throwable);
        }
    }
    return WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(mbeanCl);
}
 
Example #15
Source File: PluggableMBeanServerImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private ClassLoader pushClassLoaderByName(final ObjectName loaderName) throws InstanceNotFoundException {
    ClassLoader mbeanCl;
    try {
        mbeanCl = doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
            public ClassLoader run() throws Exception {
                return delegate.getClassLoader(loaderName);
            }
        });
    } catch (PrivilegedActionException e) {
        try {
            throw e.getCause();
        } catch (RuntimeException r) {
            throw r;
        } catch (InstanceNotFoundException ie) {
            throw ie;
        } catch (Error error) {
            throw error;
        } catch (Throwable throwable) {
            throw new UndeclaredThrowableException(throwable);
        }
    }
    return WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(mbeanCl);
}
 
Example #16
Source File: CommandLineArgumentUsage.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected static String usage(String executableBaseName) {
    boolean isWindows = (WildFlySecurityManager.getPropertyPrivileged("os.name", null)).toLowerCase(Locale.ENGLISH).contains("windows");
    String executableName = isWindows ? executableBaseName : executableBaseName + ".sh";

    if (USAGE == null) {
        final StringBuilder sb = new StringBuilder();
        sb.append(NEW_LINE).append(ProcessLogger.ROOT_LOGGER.argUsage(executableName)).append(NEW_LINE);

        for (int i = 0; i < arguments.size(); i++) {
            sb.append(getCommand(i)).append(NEW_LINE);
        }
        USAGE = sb.toString();
    }
    return USAGE;

}
 
Example #17
Source File: ServerEnvironment.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Determine the number of threads to use for the bootstrap service container. This reads
 * the {@link #BOOTSTRAP_MAX_THREADS} system property and if not set, defaults to 2*cpus.
 * @see Runtime#availableProcessors()
 * @return the maximum number of threads to use for the bootstrap service container.
 */
public static int getBootstrapMaxThreads() {
    // Base the bootstrap thread on proc count if not specified
    int cpuCount = ProcessorInfo.availableProcessors();
    int defaultThreads = cpuCount * 2;
    String maxThreads = WildFlySecurityManager.getPropertyPrivileged(BOOTSTRAP_MAX_THREADS, null);
    if (maxThreads != null && maxThreads.length() > 0) {
        try {
            int max = Integer.decode(maxThreads);
            defaultThreads = Math.max(max, 1);
        } catch(NumberFormatException ex) {
            ServerLogger.ROOT_LOGGER.failedToParseCommandLineInteger(BOOTSTRAP_MAX_THREADS, maxThreads);
        }
    }
    return defaultThreads;
}
 
Example #18
Source File: EmbedServerHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private File getJBossHome(final ParsedCommandLine parsedCmd) throws CommandLineException {
    String jbossHome = this.jbossHome == null ? null : this.jbossHome.getValue(parsedCmd);
    if (jbossHome == null || jbossHome.length() == 0) {
        jbossHome = WildFlySecurityManager.getEnvPropertyPrivileged("JBOSS_HOME", null);
        if (jbossHome == null || jbossHome.length() == 0) {
            if (this.jbossHome != null) {
                throw new CommandLineException("Missing configuration value for --jboss-home and environment variable JBOSS_HOME is not set");
            } else {
                throw new CommandLineException("Environment variable JBOSS_HOME is not set");
            }
        }
        return validateJBossHome(jbossHome, "environment variable JBOSS_HOME");
    } else {
        return validateJBossHome(jbossHome, "argument --jboss-home");
    }
}
 
Example #19
Source File: HelpSupport.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static String printHelp(CommandContext ctx, String filename) {
    InputStream helpInput = WildFlySecurityManager.getClassLoaderPrivileged(CommandHandlerWithHelp.class).getResourceAsStream(filename);
    if (helpInput != null) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(helpInput));
        try {
            /*                String helpLine = reader.readLine();
            while(helpLine != null) {
                ctx.printLine(helpLine);
                helpLine = reader.readLine();
            }
             */
            return format(ctx, reader);
        } catch (java.io.IOException e) {
            return "Failed to read " + filename + ". " + e.getLocalizedMessage();
        } finally {
            StreamUtils.safeClose(reader);
        }
    } else {
        return "Failed to locate command description " + filename;
    }
}
 
Example #20
Source File: LdapConnectionManagerService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private DirContext getConnection(final Hashtable<String, String> properties, final SSLContext sslContext) throws NamingException {
    ClassLoader old = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(LdapConnectionManagerService.class);
    try {
        if (sslContext != null) {
            ThreadLocalSSLSocketFactory.setSSLSocketFactory(sslContext.getSocketFactory());
            properties.put("java.naming.ldap.factory.socket", ThreadLocalSSLSocketFactory.class.getName());
        }
        if (SECURITY_LOGGER.isTraceEnabled()) {
            Hashtable<String, String> logProperties;
            if (properties.containsKey(Context.SECURITY_CREDENTIALS)) {
                logProperties = new Hashtable<String, String>(properties);
                logProperties.put(Context.SECURITY_CREDENTIALS, "***");
            } else {
                logProperties = properties;
            }
            SECURITY_LOGGER.tracef("Connecting to LDAP with properties (%s)", logProperties.toString());
        }

        return new InitialDirContext(properties);
    } finally {
        if (sslContext != null) {
            ThreadLocalSSLSocketFactory.removeSSLSocketFactory();
        }
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
    }
}
 
Example #21
Source File: ConfigurationFile.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private int getInteger(final String name, final int defaultValue) {
    final String val = WildFlySecurityManager.getPropertyPrivileged(name, null);
    try {
        return val == null ? defaultValue : Integer.parseInt(val);
    } catch (NumberFormatException ignored) {
        return defaultValue;
    }
}
 
Example #22
Source File: SecurityActions.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void addShutdownHook(Thread hook) {
    if (! WildFlySecurityManager.isChecking()) {
        getRuntime().addShutdownHook(hook);
    } else {
        doPrivileged(new AddShutdownHookAction(hook));
    }
}
 
Example #23
Source File: JvmElement.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void determinateJVMParams() {
    String vendor = WildFlySecurityManager.getPropertyPrivileged("java.vendor", "oracle").toLowerCase();
    if (vendor.contains("ibm")) {
        type = JvmType.IBM;
    } else {
        type = JvmType.ORACLE; //default to oracle
    }
}
 
Example #24
Source File: Main.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private PCSocketConfig() {
    boolean preferIPv6 = Boolean.valueOf(WildFlySecurityManager.getPropertyPrivileged("java.net.preferIPv6Addresses", "false"));
    this.defaultBindAddress = preferIPv6 ? "::1" : "127.0.0.1";
    UnknownHostException toCache = null;
    try {
        bindAddress = InetAddress.getByName(defaultBindAddress);
    } catch (UnknownHostException e) {
        try {
            bindAddress = InetAddressUtil.getLocalHost();
        } catch (UnknownHostException uhe) {
            toCache = uhe;
        }
    }
    uhe = toCache;
}
 
Example #25
Source File: JvmType.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static JvmType createFromEnvironmentVariable(boolean forLaunch) {
    final String envJavaHome = WildFlySecurityManager.getEnvPropertyPrivileged(JAVA_HOME_ENV_VAR, null);
    if (envJavaHome != null && !"".equals(envJavaHome.trim())) {
        return createFromJavaHome(envJavaHome, forLaunch);
    } else {
        return createFromSystemProperty(forLaunch);
    }
}
 
Example #26
Source File: LoggingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testLegacyConfigurations() throws Exception {
    // Get a list of all the logging_x_x.xml files
    final Pattern pattern = Pattern.compile("(logging|expressions)_\\d+_\\d+\\.xml");
    // Using the CP as that's the standardSubsystemTest will use to find the config file
    final String cp = WildFlySecurityManager.getPropertyPrivileged("java.class.path", ".");
    final String[] entries = cp.split(Pattern.quote(File.pathSeparator));
    final List<String> configs = new ArrayList<>();
    for (String entry : entries) {
        final Path path = Paths.get(entry);
        if (Files.isDirectory(path)) {
            Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
                    final String name = file.getFileName().toString();
                    if (pattern.matcher(name).matches()) {
                        configs.add("/" + name);
                    }
                    return FileVisitResult.CONTINUE;
                }
            });
        }
    }

    // The paths shouldn't be empty
    Assert.assertFalse("No configs were found", configs.isEmpty());

    for (String configId : configs) {
        // Run the standard subsystem test, but don't compare the XML as it should never match
        standardSubsystemTest(configId, false);
    }
}
 
Example #27
Source File: TransactionalProtocolClientImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public <T extends Operation> AsyncFuture<OperationResponse> execute(TransactionalOperationListener<T> listener, T operation) throws IOException {
    AccessAuditContext accessAuditContext = WildFlySecurityManager.isChecking()
            ? doPrivileged((PrivilegedAction<AccessAuditContext>) AccessAuditContext::currentAccessAuditContext)
            : AccessAuditContext.currentAccessAuditContext();
    final ExecuteRequestContext context = new ExecuteRequestContext(new OperationWrapper<>(listener, operation),
            accessAuditContext != null ? accessAuditContext.getSecurityIdentity() : null,
            accessAuditContext != null ? accessAuditContext.getRemoteAddress() : null,
            tempDir,
            InVmAccess.isInVmCall());
    final ActiveOperation<OperationResponse, ExecuteRequestContext> op = channelAssociation.initializeOperation(context, context);
    final AtomicBoolean cancelSent = new AtomicBoolean();
    final AsyncFuture<OperationResponse> result = new AbstractDelegatingAsyncFuture<OperationResponse>(op.getResult()) {
        @Override
        public synchronized void asyncCancel(boolean interruptionDesired) {
            if (!cancelSent.get()) {
                try {
                    // Execute
                    channelAssociation.executeRequest(op, new CompleteTxRequest(ModelControllerProtocol.PARAM_ROLLBACK, channelAssociation));
                    cancelSent.set(true);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    };
    context.initialize(result);
    channelAssociation.executeRequest(op, new ExecuteRequest());
    return result;
}
 
Example #28
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 #29
Source File: LoggingExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static boolean getBooleanProperty(final String property, final boolean dft) {
    final String value = WildFlySecurityManager.getPropertyPrivileged(property, null);
    if (value == null) {
        return dft;
    }
    return value.isEmpty() || Boolean.parseBoolean(value);
}
 
Example #30
Source File: Main.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * The main method.
 *
 * @param args the command-line arguments
 */
public static void main(String[] args) {
    try {
        if (java.util.logging.LogManager.getLogManager().getClass().getName().equals("org.jboss.logmanager.LogManager")) {
            // Make sure our original stdio is properly captured.
            try {
                Class.forName(org.jboss.logmanager.handlers.ConsoleHandler.class.getName(), true, org.jboss.logmanager.handlers.ConsoleHandler.class.getClassLoader());
            } catch (Throwable ignored) {
            }
            // Install JBoss Stdio to avoid any nasty crosstalk, after command line arguments are processed.
            StdioContext.install();
            final StdioContext context = StdioContext.create(
                    new NullInputStream(),
                    new LoggingOutputStream(org.jboss.logmanager.Logger.getLogger("stdout"), org.jboss.logmanager.Level.INFO),
                    new LoggingOutputStream(org.jboss.logmanager.Logger.getLogger("stderr"), org.jboss.logmanager.Level.ERROR)
            );
            StdioContext.setStdioContextSelector(new SimpleStdioContextSelector(context));
        }

        Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule("org.jboss.vfs"));
        ServerEnvironmentWrapper serverEnvironmentWrapper = determineEnvironment(args, WildFlySecurityManager.getSystemPropertiesPrivileged(),
                WildFlySecurityManager.getSystemEnvironmentPrivileged(), ServerEnvironment.LaunchType.STANDALONE,
                Module.getStartTime());
        if (serverEnvironmentWrapper.getServerEnvironment() == null) {
            if (serverEnvironmentWrapper.getServerEnvironmentStatus() == ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR) {
                abort(null);
            } else {
                SystemExiter.safeAbort();
            }
        } else {
            final Bootstrap bootstrap = Bootstrap.Factory.newInstance();
            final Bootstrap.Configuration configuration = new Bootstrap.Configuration(serverEnvironmentWrapper.getServerEnvironment());
            configuration.setModuleLoader(Module.getBootModuleLoader());
            bootstrap.bootstrap(configuration, Collections.<ServiceActivator>emptyList()).get();
            return;
        }
    } catch (Throwable t) {
        abort(t);
    }
}