use of org.jboss.as.test.integration.security.common.config.SecurityDomain in project wildfly by wildfly.
the class AbstractSecurityDomainsServerSetupTask method tearDown.
/**
* Removes the security domain from the AS configuration.
*
* @param managementClient
* @param containerId
* @see org.jboss.as.test.integration.security.common.AbstractSecurityDomainSetup#tearDown(org.jboss.as.arquillian.container.ManagementClient,
* java.lang.String)
*/
public final void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (securityDomains == null || securityDomains.length == 0) {
LOGGER.warn("Empty security domain configuration.");
return;
}
final List<ModelNode> updates = new ArrayList<ModelNode>();
for (final SecurityDomain securityDomain : securityDomains) {
final String domainName = securityDomain.getName();
if (LOGGER.isInfoEnabled()) {
LOGGER.trace("Removing security domain " + domainName);
}
final ModelNode op = new ModelNode();
op.get(OP).set(REMOVE);
op.get(OP_ADDR).add(SUBSYSTEM, "security");
op.get(OP_ADDR).add(SECURITY_DOMAIN, domainName);
// Don't rollback when the AS detects the war needs the module
op.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(false);
op.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
updates.add(op);
}
CoreUtils.applyUpdates(updates, managementClient.getControllerClient());
this.managementClient = null;
}
use of org.jboss.as.test.integration.security.common.config.SecurityDomain 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());
}
Aggregations