com.businesslink.sgi.api.hsm
Class HsmServer

java.lang.Object
  |
  +--com.businesslink.sgi.api.hsm.HsmServer

public abstract class HsmServer
extends java.lang.Object
implements HsmConstants

Abstract superclass for all HSM servers. The simplest HSM server must implement four methods: 1) a default constructor (which must call the super constructor), 2) startHsmServer, 3) processHsmRequest, and 4) endHsmServer. The lifetime of most HSM servers will be spent waiting for processHsmRequest to be invoked by the HSM support layer.


Fields inherited from interface com.businesslink.sgi.api.hsm.HsmConstants
CCS_ASCII, CCS_HEX, CCS_JOB, CCS_MSG, CCS_STRATEGI, CCS_UNICODE, CCS_USEBC, CCS_UTF8, HSM_CLC_LOCAL, HSM_CTP_CONTROL, HSM_CTP_HSTUSR, HSM_CTP_SERVER, HSM_CTP_SGI, HSM_OPC_ECHO, HSM_OPC_ERROR, HSM_OPC_NO_SVR, HSM_OPC_PING, HSM_OPC_STOP, HSM_OPC_STOPPED, HSM_OPC_TIMEOUT, HSM_OPC_WRTPFR, HSM_OPT_AUTIDN, HSM_OPT_AUTTYP, HSM_OPT_CLTLOC, HSM_OPT_CUR, HSM_OPT_HEX, HSM_OPT_JOB, HSM_OPT_MSG, HSM_OPT_RCVTMO, HSM_OPT_RPYCCS, HSM_OPT_RQSCCS, HSM_OPT_SGI, HSM_OPT_UNI, HSM_OPT_USRATR, HSM_UAT_NOTSET
 
Constructor Summary
protected HsmServer(java.lang.String svrdsc)
          Initializes the HSM server.
 
Method Summary
abstract  void endHsmServer()
          Called by the HSM support layer when the HSM server is ending.
protected  HsmClientDetails getClientDetails()
          Gets details about the client making the HSM request (valid only during a HSM transaction).
protected  java.io.PrintWriter getTextWriter()
          Gets a PrintWriter for debug/status messages.
protected  java.io.PrintWriter getTextWriter(java.lang.String svrnam)
          Deprecated. As of Strategi V1R9M0 it is no longer necessary to pass the server name as an argument Gets a PrintWriter for debug/status messages.
static void main(java.lang.String[] args)
          Loads the HSM implementation and starts the HSM server.
abstract  boolean processHsmRequest(HsmServerRequest svrrqs, HsmClientDetails cltdtl)
          Called by the HSM support layer whenever a server request has been received and is available for processing.
protected  boolean processHsmRequestDefault(HsmServerRequest svrrqs, HsmClientDetails cltdtl)
          Performs default HSM processing for system level opcodes and unknown opcodes.
 void processRequests()
          Processes HSM requests.
 HsmServerRequest receiveRequest()
          Deprecated. As of Strategi V1R9M0 the Strategi HSM support layer provides a main() to allow the HsmServer to simply provide an implementation of startHsmServer(), processHsmRequest() and endHsmServer(). If a main() is used (and it should not be neccessary) then processRequests() should be used to begin dequeuing and processing requests (processRequests() will call startHsmServer() and endHsmServer()).
 void sendReply(HsmServerRequest svrrqs)
          Deprecated. As of Strategi V1R9M0 the Strategi HSM support layer provides a main() to allow the HsmServer to simply provide an implementation of startHsmServer(), processHsmRequest() and endHsmServer(). If a main() is used (and it should not be neccessary) then processRequests() should be used to begin dequeuing and processing requests (processRequests() will call startHsmServer() and endHsmServer()).
protected  boolean setOption(java.lang.String kwd, java.lang.String val)
          Sets a particular HSM server option.
abstract  void startHsmServer(java.lang.String svrnam)
          Called by the HSM support layer when the HSM server is starting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HsmServer

protected HsmServer(java.lang.String svrdsc)
Initializes the HSM server. Do not attempt to construct a HsmServer object manually, this will be done automatically by the HSM support layer.
Parameters:
svrdsc - Server description text, used for replies to *PING opcode requests.
Method Detail

startHsmServer

public abstract void startHsmServer(java.lang.String svrnam)
Called by the HSM support layer when the HSM server is starting.
Parameters:
svrnam - the name of this HSM server.

processHsmRequest

public abstract boolean processHsmRequest(HsmServerRequest svrrqs,
                                          HsmClientDetails cltdtl)
Called by the HSM support layer whenever a server request has been received and is available for processing.
Parameters:
svrrqs - the object containing the request data; also used to set the reply data.
cltdtl - details about the client making the request.
Returns:
true if the server should continue running; false if the server should be stopped.

endHsmServer

public abstract void endHsmServer()
Called by the HSM support layer when the HSM server is ending.

setOption

protected final boolean setOption(java.lang.String kwd,
                                  java.lang.String val)
Sets a particular HSM server option.
Parameters:
kwd - keyword identifying the option to set.
val - value to set.
Returns:
true if the option was set successfully, false otherwise.

getTextWriter

protected final java.io.PrintWriter getTextWriter(java.lang.String svrnam)
Deprecated. As of Strategi V1R9M0 it is no longer necessary to pass the server name as an argument Gets a PrintWriter for debug/status messages.

Parameters:
svrnam - the name of this HSM server (used to identify messages).
Returns:
the PrintWriter for debug/status messages.

getTextWriter

protected final java.io.PrintWriter getTextWriter()
Gets a PrintWriter for debug/status messages.
Returns:
the PrintWriter for debug/status messages.

getClientDetails

protected final HsmClientDetails getClientDetails()
Gets details about the client making the HSM request (valid only during a HSM transaction).
Returns:
HsmClientDetails object if called during a transaction, null otherwise.

processHsmRequestDefault

protected final boolean processHsmRequestDefault(HsmServerRequest svrrqs,
                                                 HsmClientDetails cltdtl)
Performs default HSM processing for system level opcodes and unknown opcodes.
Returns:
true if the server should continue running; false if the server should be stopped.

processRequests

public final void processRequests()
Processes HSM requests. This method blocks while the HSM server is active. This method is meant for internal HSM use only and should not be called by an extending HsmServer class. Note that this method is documented only because of older HSM servers which make use of this method.

receiveRequest

public HsmServerRequest receiveRequest()
Deprecated. As of Strategi V1R9M0 the Strategi HSM support layer provides a main() to allow the HsmServer to simply provide an implementation of startHsmServer(), processHsmRequest() and endHsmServer(). If a main() is used (and it should not be neccessary) then processRequests() should be used to begin dequeuing and processing requests (processRequests() will call startHsmServer() and endHsmServer()).


sendReply

public final void sendReply(HsmServerRequest svrrqs)
Deprecated. As of Strategi V1R9M0 the Strategi HSM support layer provides a main() to allow the HsmServer to simply provide an implementation of startHsmServer(), processHsmRequest() and endHsmServer(). If a main() is used (and it should not be neccessary) then processRequests() should be used to begin dequeuing and processing requests (processRequests() will call startHsmServer() and endHsmServer()).


main

public static void main(java.lang.String[] args)
Loads the HSM implementation and starts the HSM server. Extending HSM server classes should not override static void main(), but should let this method run as-is. If an extending class does define a static void main(), it is that class' responsibility to call processRequests() to start the server.