KeyMaster Servlets

KeyMaster includes two example servlets.

Token Generator Servlet

The KeyMaster Java kit includes the StandardKeyMasterServlet token generator example servlet.

This servlet can be configured via servlet parameters in the associated web.xml. It can also be used as the basis for your own custom token generator servlet.

Example web.xml config for StandardKeyMasterServlet


    <description>Name of the private key filename</description>

The following servlet parameters can be specified in the web.xml:

Parameter Type Description



The location of the PEM PKCS#8 formatted private key file relative to the webapp.



Hashing algorithm name. See the com.caplin.keymaster.KeyMasterHashingAlgorithm enumeration for valid algorithm names. The default algorithm is SHA256.


Class name of a security provider to add to those available.


Name of security provider to use for the token generation.

Poll Servlet

The KeyMaster Java kit includes a Poll servlet.

A typical Java KeyMaster deployment uses a Poll servlet which defines the interface that enables the application to receive KeyMaster keep-alive responses.

It is configured as shown below.


StreamLink accesses Poll at regular intervals to keep the KeyMaster servlet session alive.

The StreamLink configuration is as follows:

var streamlink = caplin.streamlink.StreamLinkFactory.create({
        liberator_urls: ["rttps://", "rttps://"],
        keymaster_url: "servlet/StandardKeyMaster",
        keymaster_keep_alive_url: "servlet/Poll"

Receiving Callbacks

To receive callbacks, add KeymasterPollResponseListener to caplin.streamlink.StreamLinkFactory.create method. You will be notified when onKeymasterError is called and asked to sign in again.

  liberator_urls: [
  keymaster_url: "servlet/StandardKeyMaster",
  keymaster_keep_alive_url: "servlet/Poll",
  keymaster_keep_alive_listener: {
    onKeymasterError: function(reason) {
      console.log("KeyMaster Failed due to : " + reason);
    onKeymasterResponse : function(response) {
      console.log("KeyMaster Success. Response Message : " + response);

More details on how to configure StreamLink using KeyMaster are here.

See also: