Discover your environment through EWC
EWC listens to your devices. You can receive notifications when readers & smart cards are inserted or withdrew.
In your JavaScript file, you have to define a events notification callback and use it at EWC initialization.
/** * Card insertion/removal callback event handler */ function onHardwareChange( a_Event, a_ReaderName, a_SmartCardATR ) { var e = document.getElementById( "eventsDisplay" ); if( !e ) { return; } var sMsg = ""; switch( a_Event ) { case "CARD_IN": sMsg += "A smart card with the ATR "; sMsg += a_SmartCardATR; sMsg += " is inserted in the reader "; sMsg += a_ReaderName; break; case "CARD_OUT": sMsg += "The smart card is withdrawed from the reader "; sMsg += a_ReaderName; break; case "CARD_MUTE": sMsg += "The smart card inserted into the "; sMsg += a_ReaderName; sMsg += " reader is MUTE !!!"; break; case "READER_IN": sMsg += "The reader "; sMsg += a_ReaderName; sMsg += " is inserted on your system"; break; case "READER_OUT": sMsg += "The reader "; sMsg += a_ReaderName; sMsg += " is withdrawed from your system"; break; default: sMsg += "UNKNOWN EVENT "; sMsg += a_Event; sMsg += " "; break; } e.innerHTML += sMsg; } /** * Initialize EWC */ function initialize( ) { enex.init( null, null, null, onHardwareChange ); }
EWC can provide you the reader characteristics (the language, the screen size, ...) once a smart card has been inserted into the reader and a valid "Connection" object is ready.
In your JavaScript file, you have to call the "getPersonalCardReaderInformation" function from the "Connection" object. This function requires a callback variable as incoming parameter. This variable defines two attributes "success" and "failure".
The "success" attribute defines a function called by EWC when the "getPersonalCardReaderInformation" function succeeds. The unique parameter of the "success" function is the PCR Information.
The "failure" attribute defines a function called by EWC when the "getPersonalCardReaderInformation" function fails. The unique parameter of the "failure" function is an error object exposing a human readable message and the error code coming from the PCR.
// Create a callback to treat the return of the asynchronous function var resultCallback = { success : function( a_oResult ) { alert("The PCR information block is: " + a_oResult); }, failure : function( a_oResult ) { alert("Your reader is not compatible with the PCR information feature."); } }; var cnx = enex.getConnection( ); if( cnx ) { cnx.getPersonalCardReaderInformation( resultCallback ); } else { alert("A reader with a smart card inside are required to perform this operation"); }
You can know if your Smart Card Service is running on your machine or not.
In your JavaScript file, you have to call the "isSmartcardServiceAvailable" function from the EWC API. You have direct access to this function from the eNex global object. The function does not take any parameter and return a simple boolean value.
var bIsSmartcardServiceAvailable = enex.isSmartcardServiceAvailable( ); if ( bIsSmartcardServiceAvailable ) { alert("The Smart Card Service is running on your machine."); }
The Gemalto driver provides issue corrections and special features. It can be helpful to know if this piece of software is installed or not. EWC can provide you the Gemalto driver installation status once a smart card has been inserted into the reader and a valid "Connection" object is ready.
In your JavaScript file, you have to call the "is_gemalto_driver_installed" function from the "Connection" object. The function does not take any parameter and return a simple boolean value.
var cnx = enex.getConnection( ); if( cnx ) { var callback = { success : function(bIsGemaltoDriverInstalled){ if ( bIsGemaltoDriverInstalled ) { alert("The Gemalto driver is properly installed"); } else { alert("The Gemalto driver is NOT installed"); } }, failure : function(a_ErrorCode) { alert("An error occurred (" + a_ErrorCode + ")"); } }; cnx.is_gemalto_driver_installed(callback); }
EWC can provides you the name & version of the browser and the OS you are using with.
In your JavaScript file, you have to call the getBrowserCaracteristics and isBrowserSupported functions from the EWC API.
The isBrowserSupported function does not take any parameter and return a simple boolean value.
The function getBrowserCaracteristics returns an object containing the data that you can retrieve using the following EWC constants:
// Get the browser characteristics var r = enex.getBrowserCaracteristics( ); if ( r ) { var sMessage = "Your browser is " + r[ enex.BROWSER_NAME ]; sMessage += "The browser version is " + r[ enex.BROWSER_VERSION ] ; sMessage += "The Operating System is " + r[ enex.OPERATING_SYSTEM ] ; alert(sMessage); } // Find out if the browser is supported var bIsBrowserSupported = enex.isBrowserSupported( ); if ( bIsBrowserSupported ) { alert("Your browser is properly supported."); }
EWC can provides you the its version.
In your JavaScript file, you have to call the getVersion function from the EWC API.
The function does not take any parameter and return a simple string value.
// Get EWC version var sMessage = "The EWC version is " + enex.getVersion( ); alert(sMessage); // Get SConnect version var callbackSConnectVersion = { success:function(version) { alert("The SConnect version is " + version); }, failure:function(error) { alert("An error occurred (" + error.errorCode + ") (" + error.message + ")"; } }; enex.getSConnectVersion(callbackSConnectVersion);
EWC can provides you the list of all connected readers with or without smart card inside.
In your JavaScript file, you have to call the list_readers function from the EWC API.
The function takes a boolean to decide if you want the list of PCR with or without smart card inserted and return a simple array value.
var listCallback = { success : function( r ) { var sMessage = "The available readers are: "; if ( r.length ) { for( var i = 0 ; i < r.length ; ++i ) { sMessage += r[ i ] + " "; } } else { sMessage = "No reader available"; } alert(sMessage); }, failure : function( a_oError ) { var error = "An error occurred. "; error += "Error code (" + a_oError.errorCode + ")."; error += " Error message (" + a_oError.message + ")"; alert(error); } }; enex.list_readers( a_WithSmartcard, listCallback );
EWC can tell you if SConnect is already installed.
In your JavaScript file, you have to call the is_installed function from the EWC API.
The function does not take any parameter. The callback success is invoked if SConnect is installed otherwise the callback error is invoked if Sconnect isnot installed or an update is present.
var cb = { success : function() { alert("SConnect is installed"); }, failure : function(error) { var sMessage = "SConnect is not installed or an update is ready to be installed. "; sMessage += "Error (" + error.errorCode + ") "; sMessage += "Message (" + error.message + ")"; alert(sMessage); } }; enex.is_installed(cb);