The example logon authenticator shows how to implement the three methods: activateMaster(), activateSlave(), and slaveResponse().
It has a base class, examples.attributes.LogonAuthenticator, and three subclasses, one for the NTAuthenticator, one for the UnixAuthenticator, and one for the UseridAuthenticator. The base class provides common functionality and the subclasses provide functionality that is specific to the type of authenticator, that is NT, Unix, or Userid.
public byte[] activateMaster(boolean local) throws Exception { MQeFields fields = new MQeFields(); /* for request fields */ this.prompt(fields); /* put up the dialog prompt */ return (fields.dump()); /* return ID */ }
public byte[] activateSlave(boolean local, byte data[]) throws Exception { MQeFields fields = new MQeFields(data); /* work object */ try { authID = this.validate(fields); /* get the auth ID value */ setAuthenticatedID(authID); /* is it allowed ? */ super.activateSlave(local, data); /* call ancestor */ trace("_:Logon " + authID); /* trace */ MQeFields result = new MQeFields(); /* reply object */ result.putAscii(Authentic_ID, authID);/* send id */ return (result.dump()); /* send back as response */ } catch (Exception e) { /* error occured */ authID = null; /* make sure authID is null */ setAuthenticatedID(null); /* invalidate */ throw e; /* re-throw the exception */ } }If the user name is valid, the activateSlave() method calls setAuthenticatedID() to register the user name and the calls super.activateSlave() which puts out a log message. It issues a trace message, adds the user name to an MQeFields object, dumps this to a byte array and returns it. If the user name is not valid, validate() throws an exception. The activateSlave() method catches the exception, ensures the authenticated id is null and re-throws the exception.
public void slaveResponse(boolean local, byte data[]) throws Exception { super.slaveResponse(local, data); /* call ancestor*/ MQeFields fields = new MQeFields(data); /* work object*/ setAuthenticatedID(fields.getAscii(Authentic_ID)); /* id to check */ }These authenticators behave the same for both local and remote accesses, so they ignore the local parameter to these methods.