Address destination = new Address(PROFILE);
destination.addSegment(SECURITY_RESOURCE_KEY);
String securityDomainId = TEST_DOMAIN + "2";
destination.addSegment(SECURITY_DOMAIN_RESOURCE_KEY + "=" + securityDomainId);
ASConnection connection = getDomainControllerASConnection();
Result result = new Result();
Operation op = null;
//delete old one if present to setup clean slate
op = new Operation("remove", destination);
result = connection.execute(op);
//build/rebuild hierarchy
op = new Operation("add", destination);
result = connection.execute(op);
assert result.getOutcome().equals("success") : "Add of Security Domain has failed: "
+ result.getFailureDescription();
//Ex. profile=standalone-ha,subsystem=security,security-domain
String addressPrefix = PROFILE + "," + SECURITY_RESOURCE_KEY + "," + SECURITY_DOMAIN_RESOURCE_KEY;
//loop over standard types and add base details for all of them to security domain
String address = "";
for (String attribute : jsonMap.keySet()) {
if (attribute.equals("policy-modules")) {
address = addressPrefix + "=" + securityDomainId + ",authorization=classic";
} else if (attribute.equals("acl-modules")) {
address = addressPrefix + "=" + securityDomainId + ",acl=classic";
} else if (attribute.equals("mapping-modules")) {
address = addressPrefix + "=" + securityDomainId + ",mapping=classic";
} else if (attribute.equals("trust-modules")) {
address = addressPrefix + "=" + securityDomainId + ",identity-trust=classic";
} else if (attribute.equals("provider-modules")) {
address = addressPrefix + "=" + securityDomainId + ",audit=classic";
} else if (attribute.equals("login-modules")) {
address = addressPrefix + "=" + securityDomainId + ",authentication=classic";
} else {
assert false : "An unknown attribute '" + attribute
+ "' was found. Is there a new type to be supported?";
}
//build the operation to add the component
////Load json map into ModuleOptionType
try {
// loading jsonMap contents for Ex. 'login-module'
JsonNode node = mapper.readTree(jsonMap.get(attribute));
Object obj = mapper.treeToValue(node, Object.class);
result.setResult(obj);
result.setOutcome("success");
} catch (JsonProcessingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//populate the Value component complete with module Options.
List<Value> moduleTypeValue = populateSecurityDomainModuleOptions(result, loadModuleOptionType(attribute));
op = createAddModuleOptionTypeOperation(new Address(address), attribute, moduleTypeValue);
//submit the command
result = connection.execute(op);
assert result.getOutcome().equals("success") : "Add ModuleOptionType has failed: "
+ result.getFailureDescription();
}
}