Using the SDK with Java
This section describes how to use the AssureID Sentinel SDK from a Java IDE such as NetBeans. The overall flow of your Java-based AssureID application will be to create an instance of the AssureIDSession class, add event listeners, and then open() the session. After the session has reported PlatformState.Ready to the registered PlatformStatusChangedListener, any session property setters may be called. Applications then receive events from AssureID from which they can access processed document results. Applications should close the session when exiting.
Referencing the AssureID Sentinel SDK
Section titled “Referencing the AssureID Sentinel SDK”The AssureID Java Platform SDK allows Java applications to interact with the AssureID Document Authentication Platform (DAP). To use this SDK, applications must reference the AssureIDJavaPlatformSDK.jar. The AssureIDJavaPlatformSDK.jar requires the AssureTec.AssureID.Platform.SDK.dll assembly, which is normally installed in the global application cache (GAC) when AssureID is installed on a machine.
| JavaSimpleExample.jar. AssureIDJavaPlatformSDK.jar | java -jar JavaSimpleExample.jar |
|---|---|
| JavaSimpleExample.jar. lib/AssureIDJavaPlatformSDK.jar. lib/AssureIDJavaPlatformSDK.dll | java -Djava.library.path=lib -jar JavaSimpleExample.jar |
Creating an AssureIDSession
Section titled “Creating an AssureIDSession”The main interface point is the AssureIDSession class. Applications create an instance of the AssureIDSession class.
import AssureTec.AssureID.SDK;AssureIDSession session = new AssureIDSession();Note that applications should create a single instance of the AssureIDSession class and open and close it as needed (rather than creating a new session instance each time one is required and disposing of these instances). Applications may register (add) or unregister (remove) event listeners at any time.
Connecting to the AssureID DAP
Section titled “Connecting to the AssureID DAP”After you create the AssureIDSession object, you must connect it to the Document Authentication Platform (DAP) by calling the open method:
session.open();Note: The open method will succeed even if the DAP service is not currently running. The DAP service is installed to start automatically. However, it can be started and stopped manually from the Windows Control Panel in Administrative Tools > Services. When the DAP service is started, any open sessions automatically connect to it.
To determine whether a session is currently connected, check the getIsConnected method or getPlatformStatus method. The PlatformStatusChanged event will fire whenever the platform state changes.
Controlling the AssureID DAP (Java)
Section titled “Controlling the AssureID DAP (Java)”Once the session has been opened and has reported PlatformState.Ready to the registered PlatformStatusChangedListener, any session property settings can be called. (With the exception of the setAutoDispose(boolean) method, which can be called anytime, attempts to set session properties before the session has reported Ready will be silently ignored.)
Receiving AssureID Sentinel SDK events (Java)
Section titled “Receiving AssureID Sentinel SDK events (Java)”The AssureIDSession object fires events to notify the application of state changes and provide applications with document data. To fully use the SDK, the application must subscribe to events that it is interested in. Applications add event listeners to the session instance through a collection of addEventListener methods. (There is a corresponding set of removeEventListener methods as well.)
session.addPlatformStatusChangedListener( new PlatformStatusChangedListener() { @Override public void platformStatusChanged(PlatformStatusEvent e) { // your code here… }});Accessing document or transaction information
Section titled “Accessing document or transaction information”You can access information about the current document or transaction with Java in two ways. Event arguments contain references to relevant data (such as the transaction, the document, and the document image). The current transaction and document are also accessible through the AssureIDSession object directly by using the getCurrentDocument and getCurrentTransaction methods.
Note: If the AutoDispose property is set to true, all document and transaction information is disposed of before processing the TransactionNew event for the next document. This means that an application that has references to the previous transaction or document object must relinquish them upon receiving this event. This includes all objects in the transaction-document model including images. If an application requires these objects beyond the TransactionNew event, the AutoDispose property should be set to false.
Threading considerations
Section titled “Threading considerations”Multithreaded AssureID applications can specify their desired threading model to AssureID through the setThreadingModel(ThreadModel) method.
Example
EventQueue.invokeLater(. new ParameterizedRunnable<PlatformStatusEvent>(e) {. @Override. public void run() {. // your code here… // access parameter via this.value member. // see JavaAdvancedSample application. }. });
- If set to ThreadModel.SingleThreaded, all AssureID event callbacks are fired on the Event Dispatch Thread (EDT).
- If set to ThreadModel.MultiThreaded, any callback intended to update any user interface component must marshal that code to the EDT.
GUI-based applications likely require that the AssureIDSession events be fired using the Event Dispatch Thread, especially if UI interaction within the event handlers is required. If no UI interaction is required (or possible), you can set this value to ThreadModel.MultiThreaded to allow the event handlers to be called from internal secondary threads.
Note: An example of the ParameterizedRunnable class is included with the JavaAdvancedSample application as a thread-safe way to marshal AssureID event objects to EDT workers.
Cleaning up
Section titled “Cleaning up”Applications should close() the session when exiting. Failure to do so may prevent the application from exiting.