CIC iSign Version 1.2

InkTools
Class CicServer

java.lang.Object
  |
  +--InkTools.CicServer

public class CicServer
extends java.lang.Object

Provides highlevel functions for signature enrollment and verification for servlet development. Since servlets don't need UI elements, this class is the center piece for the servlet, similar as the CicInkControl is the center piece for an applet. The main task handled by a servlet will be signature verification, since signatures are captured in the applet on the front end. All the verification functions (enrollment, loading of templates and verification) are already in the CicSigCheck class, but are here wraped in a more convienence way to use within a servlet. Also wrapped is the CicUtils funtion for generating Jpegs from a CicDoodle object.

The idea is that a servlet gets ink data via HTTP tunneling in form of a byte stream, then creates a CicDoodle object in which the ink byte stream is streamed in. Then this doodle object can be used for the various function in this class.

The servlet developer is responsible for the user template management. This class provides functions for loading template and do verification against it, but not to handle a template database.

Note that the template maybe automatically was updated. For that reason, call the 'templateIsUpdated' function after every verification and retrieve and save the new template (use 'getTemplate) if it is required.

Version:
1.0
Author:
CIC

Constructor Summary
CicServer()
          Constructs a new CicServer object.
 
Method Summary
 CicReturn createGifFromSig(java.lang.String fileName, CicDoodle sigDoodle, int width, int height)
          Creates a Gif image from a signature.
 CicReturn createJpegFromSig(java.lang.String fileName, byte[] signature, int width, int height, java.lang.String key)
          Creates a Jpeg image from a signature.
 CicReturn createJpegFromSig(java.lang.String fileName, CicDoodle sigDoodle, int width, int height)
          Creates a Jpeg image from a signature.
 int enrollSignature(CicDoodle newDoodle)
          Enrolls a user signature one by one until all 3 valid signatures are passed in.
 CicSigCheck getSigCheckClass()
          Returns the current CicSigCheck class.
 byte[] getTemplate(boolean bRemoveNonePrinting)
          Returns the current loaded template as a byte stream after it was enrolled or streamed in propperly.
 void initEnrollment()
          Resets the phase of the enrollment process to start anew.
 CicReturn loadEncryptedTemplate(byte[] template, java.lang.String key)
          Loads an encrypted signature template from a byte stream into the CicSigCheck object.
 CicReturn loadEncryptedTemplate(java.lang.String fileName, java.lang.String key)
          Loads an encrypted signature template from a file into the CicSigCheck object.
 CicReturn loadTemplate(byte[] template)
          Loads an unencrypted signature template from a byte stream into the CicSigCheck object.
 CicReturn loadTemplate(java.lang.String fileName)
          Loads an unencrypted signature template from a file into the CicSigCheck object.
 void setEncryptionParam(java.lang.String key)
          Sets the encryption parameters for loading and enrolling templates (in the CicSigCheck class).
 boolean templateIsUpdated()
          Checks if the current template was updated by the last verification.
 CicReturn verifySignature(byte[] signature)
          Verifies a signature against the previously loaded template.
 CicReturn verifySignature(byte[] signature, java.lang.String key)
          Verifies a signature against the previously loaded template.
 CicReturn verifySignature(CicDoodle sigDoodle)
          Verifies a signature against the previously loaded template.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CicServer

public CicServer()
Constructs a new CicServer object. A newly generated CicSigCheck object will be loaded. Encryption is disabled by default.

Method Detail

loadTemplate

public CicReturn loadTemplate(byte[] template)
Loads an unencrypted signature template from a byte stream into the CicSigCheck object.

Parameters:
template - template byte stream
Returns:
CicReturn object

loadEncryptedTemplate

public CicReturn loadEncryptedTemplate(byte[] template,
                                       java.lang.String key)
Loads an encrypted signature template from a byte stream into the CicSigCheck object. The encryption key passed in must match the key with which the template was created, otherwise an error will occure.

Parameters:
template - template byte stream
key - encryption key for decrypting the template
Returns:
CicReturn object

loadTemplate

public CicReturn loadTemplate(java.lang.String fileName)
Loads an unencrypted signature template from a file into the CicSigCheck object.

Parameters:
fileName - template file name
Returns:
CicReturn object

loadEncryptedTemplate

public CicReturn loadEncryptedTemplate(java.lang.String fileName,
                                       java.lang.String key)
Loads an encrypted signature template from a file into the CicSigCheck object. The encryption key passed in must match the key with which the template was created, otherwise an error will occure.

Parameters:
fileName - template file name
Returns:
CicReturn object

enrollSignature

public int enrollSignature(CicDoodle newDoodle)
Enrolls a user signature one by one until all 3 valid signatures are passed in. If all 3 signatures are collected, a template will be generated. The return code will return the phase of the enrollment with: 1 = need more signatures and 2 = enrollment was successfull and 0 = enrollment failed. Call the function 'setEncryptionParameters' to turn encryption for the template generation on or off. If enrollment was successfull, call 'getTemplate' to extract the template byte stream for further storage. Call the 'initEnrollment' to reset the enrollment phase.

If the enrollment function determins that the signatures are too 'simple', a '0' will be returned. The user should then get notified about that. If the signatures where inconsistent after 3 signatures, the return of a '1' will request more signatures for the enrollment until all signatures are consistend enough for the enrollment.

Note: set the enryption parameter for the signature before calling this function.

Parameters:
newDoodle - the signature in an CicDoodle object added to the current enrollment process
Returns:
The phase of the enrollment process: 1 = need more signatures, 2 = enrollment is complete and 0 = enrollment failed.

getTemplate

public byte[] getTemplate(boolean bRemoveNonePrinting)
Returns the current loaded template as a byte stream after it was enrolled or streamed in propperly.

Parameters:
bRemoveNonePrinting - true if all none printable bytes should be replaced with ASCI encoding (increases template size), otherwise false
Returns:
a byte stream containing the template or null

templateIsUpdated

public boolean templateIsUpdated()
Checks if the current template was updated by the last verification. On every call to the 'signatureVerification' function the verification algorithm will dynamically evaluate if the user template has to get updated. If so, the user template will actually change and has to get saved. After a call to 'signatureVerification', programmers should call this function in order to determin if the stored template has to get replaced with the updated new one, if that is desired.

Returns:
true if the last signature verification actually updated the template. False if no update took place

setEncryptionParam

public void setEncryptionParam(java.lang.String key)
Sets the encryption parameters for loading and enrolling templates (in the CicSigCheck class).

Parameters:
key - the encryption key or null for disabling the encryption.

initEnrollment

public void initEnrollment()
Resets the phase of the enrollment process to start anew.


verifySignature

public CicReturn verifySignature(byte[] signature)
Verifies a signature against the previously loaded template. The signature is passed in in form of an unencrypted byte stream.

Parameters:
signature - the ink data in form of a byte stream
Returns:
CicReturn object

verifySignature

public CicReturn verifySignature(byte[] signature,
                                 java.lang.String key)
Verifies a signature against the previously loaded template. The signature is passed in as an encrypted byte stream with 'key' as the encryption key. The encryption key should match the key with which the signature data was encryptd.

Parameters:
signature - the signature data in form of a byte stream
Returns:
CicReturn object

verifySignature

public CicReturn verifySignature(CicDoodle sigDoodle)
Verifies a signature against the previously loaded template. The signature is passed in as a CicDoodle object.

Parameters:
sigDoodle - CicDoodle object containing the signature
Returns:
CicReturn object

getSigCheckClass

public CicSigCheck getSigCheckClass()
Returns the current CicSigCheck class. If a template was loaded or created, encryption parameters set, the returned class will still hold these value, and the user can use all CicSigCheck methods, which where not covered by the CicServer class.

Returns:
the current CicSigCheck class used in CicServer

createJpegFromSig

public CicReturn createJpegFromSig(java.lang.String fileName,
                                   byte[] signature,
                                   int width,
                                   int height,
                                   java.lang.String key)
Creates a Jpeg image from a signature. The signature is passed in as a byte stream, the 'key' value will determin if the byte stream was encrypted. If the byte stream contains no ink or the encryption key is not correct, a NO_INK error will be returned. The generated Jpeg will have the size width:height and will be saved as a file with the name 'fileName'.

Parameters:
fileName - the file name under which the newly created Jpeg image should get saved
signature - the byte stream of the signature
width - the width of the Jpeg image
height - the height of the Jpeg image
key - the encryption key if signature is encrypted, otherwise null
Returns:
CicReturn object

createJpegFromSig

public CicReturn createJpegFromSig(java.lang.String fileName,
                                   CicDoodle sigDoodle,
                                   int width,
                                   int height)
Creates a Jpeg image from a signature. The signature is passed in as a CicDoodle object. If the doodle contains no valid ink, a NO_INK error will be returned. The generated Jpeg will have the size width:height and will be saved as a file with the name 'fileName'.

Parameters:
fileName - the file name under which the newly created Jpeg image should get saved
sigDoodle - the signature in form of a CicDoodle object
width - The width of the Jpeg image
height - The height of the Jpeg image
Returns:
CicReturn object

createGifFromSig

public CicReturn createGifFromSig(java.lang.String fileName,
                                  CicDoodle sigDoodle,
                                  int width,
                                  int height)
Creates a Gif image from a signature. The signature is passed in as a CicDoodle object. If the doodle contains no valid ink, a NO_INK error will be returned. The generated Jpeg will have the size width:height and will be saved as a file with the name 'fileName'.

See Copyright notice in the CicUtils class for the Gif encoder.

Parameters:
fileName - the file name under which the newly created Jpeg image should get saved
sigDoodle - the signature in form of a CicDoodle object
width - The width of the Jpeg image
height - The height of the Jpeg image
Returns:
CicReturn object

CIC iSign Version 1.2