Friday, February 19, 2016

Oracle Applications ERP Ebiz Authentication

Validate user/password for Ebiz Session

import oracle.apps.cz.common.CZWebAppsContext;
import oracle.apps.fnd.common.Const;


public class AppsAuth {
    public AppsAuth() {
        super();
    }

    public static void main(String[] args) {
        //debug("Java System Properites : " + System.getProperties());
        String dbcFileName = System.getProperty(Const.DBCFILE);
        if (dbcFileName == null) {
            dbcFileName = System.getProperty(Const.JTFDBCFILE);
        }
        debug("DBCFILE found : " + dbcFileName);
        if (dbcFileName == null) {
            dbcFileName = "/u02/VIS1213/inst/apps/VIS1213_ebs/appl/fnd/12.0.0/secure/VIS1213.dbc";
            System.setProperty(Const.DBCFILE, dbcFileName);
            System.setProperty(Const.JTFDBCFILE, dbcFileName);
            debug("DBCFILE set to : " + dbcFileName);
        }


        CZWebAppsContext context = null;
        long startTime = System.currentTimeMillis();

        try {
            debug("Creating context");
            context = new CZWebAppsContext(dbcFileName);
            boolean valid = context.getSessionManager().validateLogin(args[0], args[1]);
            System.out.println("is valid : " + valid);
        } catch (Exception e) {
            debug("Error " + e.getStackTrace());
            e.printStackTrace();
        } finally {
            if (context != null) {
                context.freeContext();
                debug("Context Released");
            }
            debug("Time taken to for the process : " + (System.currentTimeMillis() - startTime) + " ms");
        }
    }

    private static void debug(String message) {
        System.out.println(message);
    }
}