/
WebTestsSecurityDomainSetup.java
65 lines (51 loc) · 2.5 KB
/
WebTestsSecurityDomainSetup.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package org.jboss.as.test.integration.web.security;
import java.util.ArrayList;
import java.util.List;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.security.Constants;
import org.jboss.as.test.integration.security.AbstractSecurityDomainSetup;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ALLOW_RESOURCE_SERVICE_RESTART;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_HEADERS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import static org.jboss.as.security.Constants.AUTHENTICATION;
import static org.jboss.as.security.Constants.CODE;
import static org.jboss.as.security.Constants.FLAG;
import static org.jboss.as.security.Constants.SECURITY_DOMAIN;
/**
* @author Stuart Douglas
*/
public class WebTestsSecurityDomainSetup extends AbstractSecurityDomainSetup {
private static final Logger log = Logger.getLogger(WebTestsSecurityDomainSetup.class);
protected static final String WEB_SECURITY_DOMAIN = "web-tests";
@Override
public void setup(final ManagementClient managementClient) {
log.debug("start of the domain creation");
final List<ModelNode> updates = new ArrayList<ModelNode>();
ModelNode op = new ModelNode();
op.get(OP).set(ADD);
op.get(OP_ADDR).add(SUBSYSTEM, "security");
op.get(OP_ADDR).add(SECURITY_DOMAIN, getSecurityDomainName());
updates.add(op);
op = new ModelNode();
op.get(OP).set(ADD);
op.get(OP_ADDR).add(SUBSYSTEM, "security");
op.get(OP_ADDR).add(SECURITY_DOMAIN, getSecurityDomainName());
op.get(OP_ADDR).add(AUTHENTICATION, Constants.CLASSIC);
ModelNode loginModule = op.get(Constants.LOGIN_MODULES).add();
loginModule.get(CODE).set("UsersRoles");
loginModule.get(FLAG).set("required");
op.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
updates.add(op);
applyUpdates(managementClient.getControllerClient(), updates);
log.debug("end of the domain creation");
}
@Override
protected String getSecurityDomainName() {
return WEB_SECURITY_DOMAIN;
}
}