Source:
<code>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")) { <START> securityRealm = result.get("security-realm").asString(); <END> } 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")); } }</code><technical_language>a tiny bit concerned this mechanism check if elytron is enabled not, if legacy elyton mixed (Don't if this is realistic.) I this is OK though, whats in configs</technical_language>

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")); } }