Search in sources :

Example 46 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class MixedDomainDeploymentTest method createDeploymentOperation.

private ModelNode createDeploymentOperation(ModelNode content, PathAddress... serverGroupAddressses) {
    ModelNode composite = createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    ModelNode steps = composite.get(STEPS);
    ModelNode step1 = steps.add();
    step1.set(createAddOperation(ROOT_DEPLOYMENT_ADDRESS));
    step1.get(CONTENT).add(content);
    for (PathAddress serverGroup : serverGroupAddressses) {
        ModelNode sg = steps.add();
        sg.set(createAddOperation(serverGroup));
        sg.get(ENABLED).set(true);
    }
    return composite;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 47 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class AbstractSecurityDomainsServerSetupTask method createJaspiAuthnNodes.

// Private methods -------------------------------------------------------
/**
     * Creates authenticaton=>jaspi node and its child nodes.
     *
     * @param securityConfigurations
     * @return
     */
private List<ModelNode> createJaspiAuthnNodes(JaspiAuthn securityConfigurations, String domainName) {
    if (securityConfigurations == null) {
        LOGGER.trace("No security configuration for JASPI module.");
        return null;
    }
    if (securityConfigurations.getAuthnModules() == null || securityConfigurations.getAuthnModules().length == 0 || securityConfigurations.getLoginModuleStacks() == null || securityConfigurations.getLoginModuleStacks().length == 0) {
        throw new IllegalArgumentException("Missing mandatory part of JASPI configuration in the security domain.");
    }
    final List<ModelNode> steps = new ArrayList<ModelNode>();
    PathAddress domainAddress = PathAddress.pathAddress().append(SUBSYSTEM, SUBSYSTEM_SECURITY).append(SECURITY_DOMAIN, domainName);
    PathAddress jaspiAddress = domainAddress.append(org.jboss.as.test.integration.security.common.Constants.AUTHENTICATION, org.jboss.as.test.integration.security.common.Constants.JASPI);
    steps.add(Util.createAddOperation(jaspiAddress));
    for (final AuthnModule config : securityConfigurations.getAuthnModules()) {
        LOGGER.trace("Adding auth-module: " + config);
        final ModelNode securityModuleNode = Util.createAddOperation(jaspiAddress.append(AUTH_MODULE, config.getName()));
        steps.add(securityModuleNode);
        securityModuleNode.get(ModelDescriptionConstants.CODE).set(config.getName());
        if (config.getFlag() != null) {
            securityModuleNode.get(FLAG).set(config.getFlag());
        }
        if (config.getModule() != null) {
            securityModuleNode.get(org.jboss.as.test.integration.security.common.Constants.MODULE).set(config.getModule());
        }
        if (config.getLoginModuleStackRef() != null) {
            securityModuleNode.get(org.jboss.as.test.integration.security.common.Constants.LOGIN_MODULE_STACK_REF).set(config.getLoginModuleStackRef());
        }
        Map<String, String> configOptions = config.getOptions();
        if (configOptions == null) {
            LOGGER.trace("No module options provided.");
            configOptions = Collections.emptyMap();
        }
        final ModelNode moduleOptionsNode = securityModuleNode.get(MODULE_OPTIONS);
        for (final Map.Entry<String, String> entry : configOptions.entrySet()) {
            final String optionName = entry.getKey();
            final String optionValue = entry.getValue();
            moduleOptionsNode.add(optionName, optionValue);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Adding module option [" + optionName + "=" + optionValue + "]");
            }
        }
    }
    for (final LoginModuleStack lmStack : securityConfigurations.getLoginModuleStacks()) {
        PathAddress lmStackAddress = jaspiAddress.append(org.jboss.as.test.integration.security.common.Constants.LOGIN_MODULE_STACK, lmStack.getName());
        steps.add(Util.createAddOperation(lmStackAddress));
        for (final SecurityModule config : lmStack.getLoginModules()) {
            final String code = config.getName();
            final ModelNode securityModuleNode = Util.createAddOperation(lmStackAddress.append(LOGIN_MODULE, code));
            final String flag = StringUtils.defaultIfEmpty(config.getFlag(), org.jboss.as.test.integration.security.common.Constants.REQUIRED);
            securityModuleNode.get(ModelDescriptionConstants.CODE).set(code);
            securityModuleNode.get(FLAG).set(flag);
            if (LOGGER.isInfoEnabled()) {
                LOGGER.trace("Adding JASPI login module stack [code=" + code + ", flag=" + flag + "]");
            }
            Map<String, String> configOptions = config.getOptions();
            if (configOptions == null) {
                LOGGER.trace("No module options provided.");
                configOptions = Collections.emptyMap();
            }
            final ModelNode moduleOptionsNode = securityModuleNode.get(MODULE_OPTIONS);
            for (final Map.Entry<String, String> entry : configOptions.entrySet()) {
                final String optionName = entry.getKey();
                final String optionValue = entry.getValue();
                moduleOptionsNode.add(optionName, optionValue);
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Adding module option [" + optionName + "=" + optionValue + "]");
                }
            }
            securityModuleNode.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
            steps.add(securityModuleNode);
        }
    }
    return steps;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) LoginModuleStack(org.jboss.as.test.integration.security.common.config.LoginModuleStack) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map) AuthnModule(org.jboss.as.test.integration.security.common.config.AuthnModule) SecurityModule(org.jboss.as.test.integration.security.common.config.SecurityModule)

Example 48 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class AbstractSecurityDomainsServerSetupTask method setup.

// Public methods --------------------------------------------------------
/**
     * Adds a security domain represented by this class to the AS configuration.
     *
     * @param managementClient
     * @param containerId
     * @throws Exception
     * @see org.jboss.as.arquillian.api.ServerSetupTask#setup(org.jboss.as.arquillian.container.ManagementClient,
     *      java.lang.String)
     */
public final void setup(final ManagementClient managementClient, String containerId) throws Exception {
    this.managementClient = managementClient;
    securityDomains = getSecurityDomains();
    if (securityDomains == null || securityDomains.length == 0) {
        LOGGER.warn("Empty security domain configuration.");
        return;
    }
    // TODO remove this once security domains expose their own capability
    // Currently subsystem=security-domain exposes one, but the individual domains don't
    // which with WFCORE-1106 has the effect that any individual sec-domain op that puts
    // the server in reload-required means all ops for any sec-domain won't execute Stage.RUNTIME
    // So, for now we preemptively reload if needed
    ServerReload.BeforeSetupTask.INSTANCE.setup(managementClient, containerId);
    final List<ModelNode> updates = new LinkedList<ModelNode>();
    for (final SecurityDomain securityDomain : securityDomains) {
        final String securityDomainName = securityDomain.getName();
        if (LOGGER.isInfoEnabled()) {
            LOGGER.trace("Adding security domain " + securityDomainName);
        }
        final ModelNode compositeOp = new ModelNode();
        compositeOp.get(OP).set(COMPOSITE);
        compositeOp.get(OP_ADDR).setEmptyList();
        ModelNode steps = compositeOp.get(STEPS);
        PathAddress opAddr = PathAddress.pathAddress().append(SUBSYSTEM, SUBSYSTEM_SECURITY).append(SECURITY_DOMAIN, securityDomainName);
        ModelNode op = Util.createAddOperation(opAddr);
        if (StringUtils.isNotEmpty(securityDomain.getCacheType())) {
            op.get(org.jboss.as.test.integration.security.common.Constants.CACHE_TYPE).set(securityDomain.getCacheType());
        }
        steps.add(op);
        //only one can occur - authenticationType or authenticationJaspiType
        final boolean authNodeAdded = createSecurityModelNode(org.jboss.as.test.integration.security.common.Constants.AUTHENTICATION, LOGIN_MODULE, FLAG, org.jboss.as.test.integration.security.common.Constants.REQUIRED, securityDomain.getLoginModules(), securityDomainName, steps);
        if (!authNodeAdded) {
            final List<ModelNode> jaspiAuthnNodes = createJaspiAuthnNodes(securityDomain.getJaspiAuthn(), securityDomain.getName());
            if (jaspiAuthnNodes != null) {
                for (ModelNode node : jaspiAuthnNodes) {
                    steps.add(node);
                }
            }
        }
        createSecurityModelNode(org.jboss.as.test.integration.security.common.Constants.AUTHORIZATION, org.jboss.as.test.integration.security.common.Constants.POLICY_MODULE, FLAG, org.jboss.as.test.integration.security.common.Constants.REQUIRED, securityDomain.getAuthorizationModules(), securityDomainName, steps);
        createSecurityModelNode(org.jboss.as.test.integration.security.common.Constants.MAPPING, org.jboss.as.test.integration.security.common.Constants.MAPPING_MODULE, TYPE, ROLE, securityDomain.getMappingModules(), securityDomainName, steps);
        final ModelNode jsseNode = createJSSENode(securityDomain.getJsse(), securityDomain.getName());
        if (jsseNode != null) {
            steps.add(jsseNode);
        }
        updates.add(compositeOp);
    }
    CoreUtils.applyUpdates(updates, managementClient.getControllerClient());
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) LinkedList(java.util.LinkedList) SecurityDomain(org.jboss.as.test.integration.security.common.config.SecurityDomain)

Example 49 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class DomainAdjuster640 method replaceActiveMqWithMessaging.

private Collection<? extends ModelNode> replaceActiveMqWithMessaging(PathAddress subsystem) throws Exception {
    final List<ModelNode> list = new ArrayList<>();
    //messaging-activemq does not exist, remove it and the extension
    list.add(createRemoveOperation(subsystem));
    list.add(createRemoveOperation(PathAddress.pathAddress(EXTENSION, "org.wildfly.extension.messaging-activemq")));
    //Add legacy messaging extension
    list.add(createAddOperation(PathAddress.pathAddress(EXTENSION, "org.jboss.as.messaging")));
    //Get the subsystem add operations (since the subsystem is huge, and there is a template, use the util)
    LegacySubsystemConfigurationUtil util = new LegacySubsystemConfigurationUtil(new org.jboss.as.messaging.MessagingExtension(), "messaging", "ha", "subsystem-templates/messaging.xml");
    list.addAll(util.getSubsystemOperations());
    //Now adjust the things from the template which are not available in the legacy server
    //http acceptors and connectors are not available
    PathAddress messaging = PathAddress.pathAddress(PROFILE, "full-ha").append(SUBSYSTEM, "messaging");
    PathAddress server = messaging.append("hornetq-server", "default");
    list.add(createRemoveOperation(server.append("http-acceptor", "http-acceptor")));
    list.add(createRemoveOperation(server.append("http-acceptor", "http-acceptor-throughput")));
    list.add(createRemoveOperation(server.append("http-connector", "http-connector")));
    list.add(createRemoveOperation(server.append("http-connector", "http-connector-throughput")));
    //TODO here we should add a remote connector, for now use the in-vm one
    list.add(getWriteAttributeOperation(server.append("broadcast-group", "bg-group1"), "connectors", new ModelNode().add("in-vm")));
    return list;
}
Also used : LegacySubsystemConfigurationUtil(org.jboss.as.test.integration.domain.mixed.LegacySubsystemConfigurationUtil) PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode)

Example 50 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class DomainAdjuster640 method replaceUndertowWithWeb.

private Collection<? extends ModelNode> replaceUndertowWithWeb(final PathAddress subsystem) {
    final List<ModelNode> list = new ArrayList<>();
    //Undertow does not exist, remove it and the extension
    list.add(createRemoveOperation(subsystem));
    list.add(createRemoveOperation(PathAddress.pathAddress(EXTENSION, "org.wildfly.extension.undertow")));
    //Add JBoss Web extension and subsystem
    list.add(createAddOperation(PathAddress.pathAddress(EXTENSION, "org.jboss.as.web")));
    final PathAddress web = subsystem.getParent().append(SUBSYSTEM, "web");
    final ModelNode addWeb = Util.createAddOperation(web);
    addWeb.get("default-virtual-server").set("default-host");
    addWeb.get("native").set("false");
    list.add(addWeb);
    list.add(createAddOperation(web.append("configuration", "container")));
    list.add(createAddOperation(web.append("configuration", "static-resources")));
    list.add(createAddOperation(web.append("configuration", "jsp-configuration")));
    ModelNode addHttp = Util.createAddOperation(web.append("connector", "http"));
    addHttp.get("protocol").set("HTTP/1.1");
    addHttp.get("scheme").set("http");
    addHttp.get("socket-binding").set("http");
    list.add(addHttp);
    ModelNode addAjp = Util.createAddOperation(web.append("connector", "ajp"));
    addAjp.get("protocol").set("AJP/1.3");
    addAjp.get("scheme").set("http");
    addAjp.get("socket-binding").set("ajp");
    list.add(addAjp);
    ModelNode addVirtualServer = Util.createAddOperation(web.append("virtual-server", "default-host"));
    addVirtualServer.get("enable-welcome-root").set(true);
    addVirtualServer.get("alias").add("localhost").add("example.com");
    list.add(addVirtualServer);
    return list;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)473 ModelNode (org.jboss.dmr.ModelNode)345 PathElement (org.jboss.as.controller.PathElement)54 Resource (org.jboss.as.controller.registry.Resource)53 ServiceName (org.jboss.msc.service.ServiceName)53 OperationFailedException (org.jboss.as.controller.OperationFailedException)48 Test (org.junit.Test)36 ServiceTarget (org.jboss.msc.service.ServiceTarget)32 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)29 OperationContext (org.jboss.as.controller.OperationContext)28 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)25 KernelServices (org.jboss.as.subsystem.test.KernelServices)24 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)23 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)23 Map (java.util.Map)22 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)19 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)19 ArrayList (java.util.ArrayList)18 TransformationContext (org.jboss.as.controller.transform.TransformationContext)17 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)15