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;
}
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;
}
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());
}
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;
}
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;
}
Aggregations