OAM Java Authenticator and Utility Classes

This CMiC OAM Authentication Class helps developers quickly connect to CMiC's web service if the CMiC system uses OAM or Azure AD and OAM for authentication.

This helper class contains functions that assist your program in connecting to CMiC R12 systems. The class provides basic connectivity functions that programmers and integrators will need so they do not have to implement them repeatedly.

It is easy to implement by downloading the class and following this example.

 

try {

CmicAuthenticator cmicAuthenticator = new CmicAuthenticator(loginurl, username, password);

//Or if you want to debug the code

//CmicAuthenticator cmicAuthenticator = new CmicAuthenticator(loginurl, username, password, true);

String loginCookiesString = cmicAuthenticator.getLoginCookiesString();//Get the needed cookies for logging in

String pageSource = cmicAuthenticator.makeGetConnection(finalUrl, loginCookiesString);//Connect to the protected source

// Alternate methods

// HashMap<String, String> loginCookies = cmicAuthenticator.getLoginCookies();

// String pageSource = cmicAuthenticator.makeGetConnection(finalUrl, loginCookies);

 

// Alternate post method

// String pageSource = cmicAuthenticator.makePostConnection(parametersMap, finalUrl, loginCookies);

 

System.out.println(pageSource);

System.out.println(cmicAuthenticator.logout(loginCookiesString));//returns the logout pages source

} catch (CmicAuthenticatorException a) {

System.out.println("Caught CmicAuthenticatorException");

System.out.println("Error Message : " + a.getMessage());

System.out.println("Error StackTrace : ");

a.printStackTrace();

}

 

You can also check out the ReadMe file from this package.

Here are a few items you need to know:

  • You run CmicAuthenticator.bat without passing any parameters for the usage:

    Usage: CmicAuthenticator username password loginurl finalurl [debug: true|false]

  • You can also run this command from a cmd prompt using this Java 6 or higher:

    cmd>java -cp . ConnectionSimulator

    Picked up JAVA_TOOL_OPTIONS: -Djava.vendor="Sun Microsystems Inc."

    Usage: ConnectionSimulator username password loginurl finalurl

    Example:

    Cmd>java -cp . ConnectionSimulator mysecureusername password

    https://<CMiC_Server>/ https://CMiC_Server/<CMiC_Environment>/jc-rest-api/rest/1/jcjob