Writing LogonLogoff classes

LogonLogoff classes are specified at deployment and used to logon to sign-on capable terminals, or to terminals that install as sign-on unknown.

It is recommended that you use sign-on incapable terminals, in which case you do not need the LogonLogoff classes.

If you choose to use the classes, implement the com.ibm.connector2.cci.LogonLogoff interface which has the following interface definition:
public interface LogonLogoff {
  public void logoff(javax.resource.cci.Connection conn);
  public void logon(javax.resource.cci.Connection conn, 
                    javax.security.auth.Subject security);
}
This class is only required for the EPI resource adapter. You do not need to implement the logoff method because this is never called. However, you must provide a dummy implementation so that the class can be compiled. You are passed a connection and a security subject with the logon method signature. The logon is driven in the same way as for applications that communicate with CICS® using the EPI resource adapter. You create interactions using this connection and, when finished, you close the interaction. For example:
Interaction epiInt = (Interaction)(conn.createInteraction());
EPIInteractionSpec spec = new EPIInteractionSpec();

//------------------------------------------------------------------
// configure the spec to perform a CESN, and execute the call
//------------------------------------------------------------------
spec.setAID(AIDKey.enter);
spec.setFunctionName("CESN");
spec.setInteractionVerb(EPIInteractionSpec.SYNC_SEND_RECEIVE);
EPIScreenRecord screen = new EPIScreenRecordImpl();
epiInt.execute(spec,null,screen);
Close the interaction when you have finished with it. For example:
epiInt.close();
Note: Do not close the connection within the LogonLogoff class.
The credentials with which you logon are held as Subject object. To retrieve this information you need to get an iterator from the private credentials. There is a single entry within the private credentials of type PasswordCredential. You can obtain the userid and password from this entry as follows:
Iterator it = security.getPrivateCredentials().iterator();
PasswordCredential pc = null;
if (it.hasNext()) {
  pc = (PasswordCredential)it.next();
}
if (pc == null) {
  throw new javax.resource.spi.SecurityException("
    Unable to logon, No Security Information Provided");
}
String user = pc.getUserName();
String pass = new String(pc.getPassword());

If there are any problems, throw a javax.resource.spi.SecurityException.