Appendix A. Sample Web Express Logon plug-in
This sample plug-in illustrates the directions in Create plug-ins for Web Express Logon for creating a Network Security or Credential Mapper plug-in. It uses the CMResponse object to return parameters and status. Use this sample as a guide for creating your own plug-ins. This sample does not retrieve information; it simply returns values that are coded as constants. Your plug-in must add logic to retrieve the needed information.
/////////////////////////////////////////////////////////////////// // CMPIHardCode -- "Hard-code" CM plugin for either NS or CM purposes // // (insert example-code copyright here) // // 5724-D34 // // Product: IBM HATS // // Component: Web Express Logon package com.ibm.hats.common.wel; import com.ibm.eNetwork.security.sso.*; import com.ibm.eNetwork.security.sso.cms.*; import com.ibm.eNetwork.HOD.common.PasswordCipher; import java.util.Properties; import java.util.Enumeration; public class CMPIHardCode implements CMInterface { private static final String className = "com.ibm.hats.common.wel.CMPIHardCode"; private static final String KEY_USERID = "CMPI_HARD_CODE_USERID"; private static final String KEY_PASSWORD = "CMPI_HARD_CODE_PASSWORD"; private static final String KEY_STATUS = "CMPI_HARD_CODE_STATUS"; private static final String KEY_TRACE_LEVEL = "CMPI_HARD_CODE_TRACE_LEVEL"; private static final int DEFAULT_TRACE_LEVEL = Ras.TRACE_NONE; // Configured parameters to this plugin private String userID; private String password; private int status; private int traceLevel; private boolean initOK = true; private String cmID = null; private Properties pInit = null; public int Init(Properties p, String id) { this.pInit = p; this.cmID = id; this.initOK = true; userID = getProperty(KEY_USERID); password = getProperty(KEY_PASSWORD); status = Integer.parseInt(getProperty(KEY_STATUS)); String traceStr = getProperty(KEY_TRACE_LEVEL); if (traceStr != null) traceLevel = Integer.parseInt(traceStr); else traceLevel = DEFAULT_TRACE_LEVEL; return (this.initOK ? SSOConstants.SSO_SUCCESS : SSOConstants. } /** * This sample plugin has no actions to take at destroy time */ public void Destroy() { } /** * Retrieve the requested credentials here, and return them to Credential Mapper */ public CMResponse CMSGetUserCredentials(CMRequest req) { // Perform whatever business logic is needed here to assign credentials. // This testing sample just returns the plugins configured values. CMResponse resp = new CMResponse(userID, password, status); return( resp ); } /** * Return plugin information to the Studio Web Express Logon Editor */ public String getName() {return "Fixed credentials (for testing)";} public String getDescription() {return "Hard-codes returned credentials based on parameters (for testing)";} public String getAuthor() {return "IBM Corporation";} /** * Return the list of parameters this plugin uses/allows to the Studio Web Express Logon Editor */ String strParms[] = { KEY_USERID, KEY_PASSWORD, KEY_STATUS }; public String[] getParameters() {return strParms;} /** * Return information about the requested parameter to the Studio Web Express Logon Editor */ public Properties getParameterInfo(String strParm) { Properties p = new Properties(); if( KEY_USERID.equals(strParm) ) { p.put(CMInterface.cmiRequired, "true"); } else if( KEY_PASSWORD.equals(strParm) ) { p.put(CMInterface.cmiRequired, "true"); p.put(CMInterface.cmiEncrypted, "true"); } else if( KEY_STATUS.equals(strParm) ) { p.put(CMInterface.cmiRequired, "true"); p.put(CMInterface.cmiDefaultValue, Integer.toString(SSOConstants.SSO_SUCCESS)); } else if( KEY_TRACE_LEVEL.equals(strParm) ) { p.put(CMInterface.cmiRequired, "false"); p.put(CMInterface.cmiDefaultValue, Integer.toString(DEFAULT_TRACE_LEVEL)); } return p; } /** * Retrieve the parameter value */ private String getProperty(String propName) { final String methodName = "getProperty"; if (traceLevel >= Ras.TRACE_MAXIMUM) Ras.traceEntry(className, methodName, propName); boolean requiredParm = "true".equals(getParameterInfo(propName).getProperty(CMInterface.cmiRequired)); boolean encryptedParm = "true".equals(getParameterInfo(propName).getProperty(CMInterface.cmiEncrypted)); String value = pInit.getProperty(cmID + propName); // must use cmID prefix !! if (value == null || value.trim().equals("")) value = pInit.getProperty(propName); if ((value == null || value.trim().equals("")) && requiredParm) { if (traceLevel >= Ras.TRACE_MINIMUM) Ras.logMessage(Ras.MSG_ERROR, className, methodName, "PARAMETER_ERROR", propName); initOK = false; } else if (encryptedParm) value = PasswordCipher.decrypt(value); if (traceLevel >= Ras.TRACE_MAXIMUM) Ras.traceExit(className, methodName, (encryptedParm ? "********" : value)); return value; } }Home