Source:
void configureUser(final ModelControllerClient client, final CompositeOperationBuilder compositeOp) throws IOException { String securityRealm = "ManagementRealm"; ModelNode op = Operations.createReadResourceOperation(Operations.createAddress("core-service", "management", "management-interface", "http-interface")); ModelNode result = executeForSuccess(client, OperationBuilder.create(op).build()); if (result.hasDefined("security-realm")) { securityRealm = result.get("security-realm").asString(); } else if (result.hasDefined("http-upgrade")) { final ModelNode httpUpgrade = result.get("http-upgrade"); if (httpUpgrade.hasDefined("sasl-authentication-factory")) { elytronEnabled = true; } } if (elytronEnabled) { userAuthAddress = Operations.createAddress("subsystem", "elytron", "configurable-sasl-server-factory", "configured"); op = Operations.createOperation("map-remove", userAuthAddress); op.get("name").set("properties"); op.get("key").set(defaultUserKey); compositeOp.addStep(op.clone()); op = Operations.createOperation("map-put", userAuthAddress); op.get("name").set("properties"); op.get("key").set(defaultUserKey); op.get("value").set("IAmAdmin"); compositeOp.addStep(op.clone()); userIdentRealmAddress = Operations.createAddress("subsystem", "elytron", "identity-realm", "local"); compositeOp.addStep(Operations.createWriteAttributeOperation(userIdentRealmAddress, "identity", "IAmAdmin")); } else { userAuthAddress = Operations.createAddress(CORE_SERVICE, MANAGEMENT, SECURITY_REALM, securityRealm, AUTHENTICATION, LOCAL); compositeOp.addStep(Operations.createWriteAttributeOperation(userAuthAddress, "default-user", "IAmAdmin")); } }

Target:
void configureUser(final ModelControllerClient client, final CompositeOperationBuilder compositeOp) throws IOException { String securityRealm = "ManagementRealm"; ModelNode op = Operations.createReadResourceOperation(Operations.createAddress("core-service", "management", "management-interface", "http-interface")); ModelNode result = executeForSuccess(client, OperationBuilder.create(op).build()); if (result.hasDefined("security-realm")) { securityRealm = result.get("security-realm").asString(); } else if (result.hasDefined("http-upgrade")) { final ModelNode httpUpgrade = result.get("http-upgrade"); if (httpUpgrade.hasDefined("sasl-authentication-factory")) { elytronEnabled = true; } } if (elytronEnabled) { userAuthAddress = Operations.createAddress("subsystem", "elytron", "configurable-sasl-server-factory", "configured"); op = Operations.createOperation("map-remove", userAuthAddress); op.get("name").set("properties"); op.get("key").set(DEFAULT_USER_KEY); compositeOp.addStep(op.clone()); op = Operations.createOperation("map-put", userAuthAddress); op.get("name").set("properties"); op.get("key").set(DEFAULT_USER_KEY); op.get("value").set("IAmAdmin"); compositeOp.addStep(op.clone()); userIdentRealmAddress = Operations.createAddress("subsystem", "elytron", "identity-realm", "local"); compositeOp.addStep(Operations.createWriteAttributeOperation(userIdentRealmAddress, "identity", "IAmAdmin")); } else { userAuthAddress = Operations.createAddress(CORE_SERVICE, MANAGEMENT, SECURITY_REALM, securityRealm, AUTHENTICATION, LOCAL); compositeOp.addStep(Operations.createWriteAttributeOperation(userAuthAddress, "default-user", "IAmAdmin")); } }