public void createNewDatabaseServerSecurityDomain72(String securityDomainName, String dsJndiName,
            String principalsQuery, String rolesQuery, String hashAlgorithm,
            String hashEncoding) throws Exception {

        Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, securityDomainName);
        ModelNode addTopNode = createRequest(ADD, addr);
        addTopNode.get(CACHE_TYPE).set("default");

        Address authAddr = addr.clone().add(AUTHENTICATION, CLASSIC);
        ModelNode addAuthNode = createRequest(ADD, authAddr);

        // Create the login module in a separate step
        Address loginAddr = authAddr.clone().add("login-module", "Database"); // name = code
        ModelNode loginModule = createRequest(ADD, loginAddr); //addAuthNode.get(LOGIN_MODULES);
        loginModule.get(CODE).set("Database");
        loginModule.get(FLAG).set("required");
        ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS);
        moduleOptions.setEmptyList();
        moduleOptions.add(DS_JNDI_NAME, dsJndiName);
        moduleOptions.add(PRINCIPALS_QUERY, principalsQuery);
        moduleOptions.add(ROLES_QUERY, rolesQuery);
        moduleOptions.add(HASH_ALGORITHM, (null == hashAlgorithm ? "MD5" : hashAlgorithm));
        moduleOptions.add(HASH_ENCODING, (null == hashEncoding ? "base64" : hashEncoding));

        ModelNode batch = createBatchRequest(addTopNode, addAuthNode, loginModule);
        ModelNode results = execute(batch);
        if (!isSuccess(results)) {
            throw new FailureException(results, "Failed to create security domain [" + securityDomainName + "]");
        }

        return;
    }
public void createNewDatabaseServerSecurityDomain72 ( String securityDomainName , String dsJndiName , String principalsQuery , String rolesQuery , String hashAlgorithm , String hashEncoding ) throws Exception { Address addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_SECURITY , SECURITY_DOMAIN , securityDomainName ) ; ModelNode addTopNode = createRequest ( ADD , addr ) ; addTopNode . get ( CACHE_TYPE ) . set ( "default" ) ; Address authAddr = addr . clone ( ) . add ( AUTHENTICATION , CLASSIC ) ; ModelNode addAuthNode = createRequest ( ADD , authAddr ) ; Address loginAddr = authAddr . clone ( ) . add ( "login-module" , "Database" ) ; ModelNode loginModule = createRequest ( ADD , loginAddr ) ; loginModule . get ( CODE ) . set ( "Database" ) ; loginModule . get ( FLAG ) . set ( "required" ) ; ModelNode moduleOptions = loginModule . get ( MODULE_OPTIONS ) ; moduleOptions . setEmptyList ( ) ; moduleOptions . add ( DS_JNDI_NAME , dsJndiName ) ; moduleOptions . add ( PRINCIPALS_QUERY , principalsQuery ) ; moduleOptions . add ( ROLES_QUERY , rolesQuery ) ; moduleOptions . add ( HASH_ALGORITHM , ( null == hashAlgorithm ? "MD5" : hashAlgorithm ) ) ; moduleOptions . add ( HASH_ENCODING , ( null == hashEncoding ? "base64" : hashEncoding ) ) ; ModelNode batch = createBatchRequest ( addTopNode , addAuthNode , loginModule ) ; ModelNode results = execute ( batch ) ; if ( ! isSuccess ( results ) ) { throw new FailureException ( results , "Failed to create security domain [" + securityDomainName + "]" ) ; } return ; }
Create a new security domain using the database server authentication method.
This is used when you want to directly authenticate against a db entry.
This is for AS 7.2+ (e.g. EAP 6.1) and works around https://issues.jboss.org/browse/AS7-6527

@param securityDomainName the name of the new security domain
@param dsJndiName the jndi name for the datasource to query against
@param principalsQuery the SQL query for selecting password info for a principal
@param rolesQuery the SQL query for selecting role info for a principal
@param hashAlgorithm if null defaults to "MD5"
@param hashEncoding if null defaults to "base64"
@throws Exception if failed to create security domain