action.skip

Managing Model Variable Lists

The com.wrq.vhi.sconfig package contains methods for managing model variable lists on Host Integrator Servers. This makes it possible for you to update username/password lists for hosts that enforce regular expiration of usernames and passwords, hosts that only allow a credentialed user one concurrent host session, and so forth. Use the classes in the com.wrq.vhi.sconfig package to manage the model variable lists on any Host Integrator Server in your domain.

Code Samples

Show model variable lists

/* Example Program :
     NOTE: As of the 7.0 release AADS has been replaced with the Management Server. Although references to
     AADS still remain in the APIs the code samples will work with the Management Server.

     Display model variable lists and their contents.

     Compile: javac -classpath sconfig.jar;bc-fips-1.0.2.3.jar;bctls-fips-1.0.14.1.jar ShowMVLs.java

     Run: java -classpath .;sconfig.jar;wcp.jar;bc-fips-1.0.2.3.jar;bctls-fips-1.0.14.1.jar ShowMVLs <ManagementServerName> <ServerName>

     Before running this program, edit the username and password variables to provide credentials for a user that is
     part of the Administrator profile.
*/

import java.io.IOException;
import java.util.*;
import com.wrq.vhi.sconfig.*;
import java.security.Security;

import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
import org.bouncycastle.crypto.CryptoServicesRegistrar;

class ShowMVLs
{
    public static final String DIVIDER = "========================================";

    public static final String username = "";
    public static final String password = "";

    /* Display the contents of a single model variable list. */
    static void showMVL( IMvlBrowser mvlb, String mvlname )
    {
        VhiMvl mvl = mvlb.getMvl(mvlname);

        /* For each MVL entry */
        for(int i=0; i<mvl.size(); i++) {
            Map mvle = mvl.get(i);
            /* For each variable/value pair in the MVL entry */
            for(Iterator it=mvle.entrySet().iterator(); it.hasNext(); ) {
                Map.Entry item = (Map.Entry)it.next();
                String vname = (String)item.getKey();
                String vval = (String)item.getValue();
                System.out.println("   Entry " + (i+1) + " :  Variable : " + vname + "  Value : " + vval );
            }
            System.out.println("");
        }
    }

    /* Display all of the MVLs defined on a Host Integrator Server. */
    static void displayMVLs(String mgmtServerName, String serverName)
        throws SCException, IOException, ClassNotFoundException
    {
        IAADSConnection mgmtServerConn =
            ServerConfig.newAADSConnection( mgmtServerName);
        IServerAdminSession sas =
            ServerConfig.newServerAdminSession( serverName, mgmtServerConn, username, password );

        /* Register the Bouncy Castle providers */
        registerProviders();

        sas.open(); /* Connect to the Host Integrator Server */

        System.out.println( DIVIDER );
        System.out.println("Management Server: " + mgmtServerName);
        System.out.println("Server: " + serverName);

        IMvlBrowser mvlb = ServerConfig.newMvlBrowser( sas );

        /* Read the MVL configuration from the Host Integrator Server. */
        mvlb.readConfiguration();

        /* Get a list of the names of MVLs defined on this server. */
        List mvlnames = mvlb.getMvlNames();
        System.out.println("Number of MVLs : " + mvlnames.size() );

        /* Display the variables/values for each MVL */
        for(Iterator it1=mvlnames.iterator(); it1.hasNext(); ) {
            String mvlname = (String)it1.next();
            System.out.println( DIVIDER );
            System.out.println("MVL Name: " + mvlname);
            showMVL( mvlb, mvlname );
        }

        sas.close(); /* Disconnect from the Host Integrator Server. */
    }

    static void registerProviders()
    {
        // initialize a few properties used by BCFIPS and BCJSSE
        Security.setProperty("ssl.KeyManagerFactory.algorithm", "PKIX");
        System.setProperty("org.bouncycastle.ec.disable_mqv", "true");
        System.setProperty("org.bouncycastle.jsse.ec.disableChar2", "true");

        // the next line shows how to place BCFIPS in approved-only mode.
        // CryptoServicesRegistrar.setApprovedOnlyMode(true);
        Security.insertProviderAt(new BouncyCastleFipsProvider(), 1);
        Security.insertProviderAt(new BouncyCastleJsseProvider(), 2);
    }

    static public void main(String [] args)
    {
        if(args.length != 2) {
            System.out.println("Usage: ShowMVLs <ManagementServerName> <Servername>");
            return;
        }
        try {
            displayMVLs( args[0], args[1] );
        }
        catch(Exception e) {
            System.err.println("Exception caught: " + e);
            e.printStackTrace();
        }
    }
}

Reverse model variable list value strings

/* Example Program :
     NOTE: As of the 7.0 release AADS has been replaced with the Management Server. Although references to
     AADS still remain in the APIs the code samples will work with the Management Server.

     Reverse the model variable list value strings, of each MVL on a Host Integrator Server.

     Compile: javac -classpath sconfig.jar;bc-fips-1.0.2.3.jar;bctls-fips-1.0.14.1.jar ReverseMVLs.java

     Run: java -classpath .;sconfig.jar;wcp.jar;bc-fips-1.0.2.3.jar;bctls-fips-1.0.14.1.jar ReverseMVLs <ManagementServerName> <ServerName>

     Use with care!  This program changes the Host Integrator Server's configuration.

     Before running this program, edit the username and password variables to provide credentials for a user that is
     part of the Administrator profile.
*/
import com.wrq.vhi.sconfig.*;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.security.Security;

import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
import org.bouncycastle.crypto.CryptoServicesRegistrar;

class ReverseMVLs
{
    public static final String DIVIDER = "========================================";
    public static final String username = "";
    public static final String password = "";

    /* Display the contents of a single model variable list. */
    static void reverseMvlValues( IMvlBrowser mvlb, String mvlname )
        throws SCException
    {
        VhiMvl mvl = mvlb.getMvl(mvlname);
        for(int i=0; i<mvl.size(); i++) {
            Map mvle = mvl.get(i);

            for(Iterator it=mvle.entrySet().iterator(); it.hasNext(); ) {
                Map.Entry item = (Map.Entry)it.next();
                String vname = (String)item.getKey();
                String vval = (String)item.getValue();

                /* Reverse the characters in the value string. */
                String newval = new StringBuffer(vval).reverse().toString();

                /* Change the value of an MVL entry. */
                mvle.put( vname, newval );
                System.out.println("   Entry " + (i+1) + " :  Variable : " + vname + "  Old Value : " + vval + "  New Value : " + newval);
            }
            System.out.println("");

            mvl.set(i, mvle); /* Update the MVL entry. */
        }

        mvlb.setMvl(mvl); /* Update the MVL with our changes. */
    }

    /* Display all of the MVLs defined on a Host Integrator Server. */
    static void reverseMVLs(String mgmtServerName, String serverName)
        throws SCException, IOException, ClassNotFoundException
    {
        IAADSConnection mgmtServerConn =
            ServerConfig.newAADSConnection( mgmtServerName);
        IServerAdminSession sas =
            ServerConfig.newServerAdminSession( serverName, mgmtServerConn, username, password );

        /* Register the Bouncy Castle providers */
        registerProviders();

        sas.open(); /* Connect to the Host Integrator Server. */

        System.out.println("Management Server: " + mgmtServerName);
        System.out.println("Server: " + serverName);

        IMvlBrowser mvlb = ServerConfig.newMvlBrowser( sas );

        mvlb.readConfiguration(); /* Read the MVLs from the Host Integrator Server. */

        List mvlnames = mvlb.getMvlNames();

        for(Iterator it1=mvlnames.iterator(); it1.hasNext(); ) {
            String mvlname = (String)it1.next();
            System.out.println( DIVIDER );
            System.out.println("MVL Name: " + mvlname);
            reverseMvlValues( mvlb, mvlname );
        }

        mvlb.updateConfiguration(); /* Write the updated MVLs to the Host Integrator Server. */

        sas.close(); /* Disconnect from the Host Integrator Server. */
    }

    static void registerProviders()
    {
        // initialize a few properties used by BCFIPS and BCJSSE
        Security.setProperty("ssl.KeyManagerFactory.algorithm", "PKIX");
        System.setProperty("org.bouncycastle.ec.disable_mqv", "true");
        System.setProperty("org.bouncycastle.jsse.ec.disableChar2", "true");

        // the next line shows how to place BCFIPS in approved-only mode.
        // CryptoServicesRegistrar.setApprovedOnlyMode(true);
        Security.insertProviderAt(new BouncyCastleFipsProvider(), 1);
        Security.insertProviderAt(new BouncyCastleJsseProvider(), 2);
    }

    static public void main(String [] args)
    {
        if(args.length != 2) {
            System.out.println("Usage: ReverseMVLs <ManagementServerName><Servername>");
            return;
        }

        try {
            reverseMVLs( args[0], args[1] );
        }
        catch(Exception e) {
            System.err.println("Exception caught: " + e);
            e.printStackTrace();
        }
    }
}