Gemalto Ezio Web Connector

 

Connection to the smart card

Connection & reconnection to the smart card

Once EWC initialized after a call to the "init" function, automatically a Connection object is created on smart card insertion.

The Connection objects provides most of the function to generate CAP & Digital Signature tokens, operate PPDU & SPE, manage Secure Channel, ...

To get this object, you have to call the "getConnection" function.

var cnx = enex.getConnection();
  
if (cnx === null) {

  alert("The current connection is NOT available. Try to reconnect");
}
                    

This Connection object is automatically disposed when the smart card is removed.

The connection with the smart card can be deny at smart card insertion or can be lost for an external reason (as another programs establishing an exclusive PCSC connection with the smart card before EWC is able to connect to).

In this case, the "getConnection" function may return a null Connection object. In this case, the web application can try to reconnect to the smart card later calling the reConnection function.

var resultCallback = {
  
  success : function( a_oConnection ) {
    
    alert("You are reconnected to the smart card");
  },

  failure : function( a_oError ) {
  
    alert("The reconnection failed. Error code : " + a_oError.errorCode + ". Error message : " + a_oError.message);
  }  
};

enex.reConnection(resultCallback);                        
                    

Try it !