This is an old revision of the document!
Web Integration API is an essential part of ADUCID for all web browser scenarios. It connects PEIG, AIM and the browser. Integration API is an essential component of ADUCID Binder, No-Code transacations and many other components.
Integration API is located in aducid-resurces folder (on Tomcat). It requires jQuery and API js and css files:
<script type="text/javascript" src="/aducid-resources/js/jquery.min.js"></script> <script type="text/javascript" src="/aducid-resources/js/aducid-api.js"></script> <link type="text/css" media="screen" href="/aducid-resources/css/aducid.css" rel="stylesheet" />
Create instance of ADUCID object:
var aducid = new ADUCID();
Set addresses of start, check and proxy operation of aducid-binder:
aducid.setStartOperationUrl("/aducid-binder/open"); aducid.setResultOperationUrl("/aducid-binder/openCheck"); aducid.setProxyUrl("/aducid-binder/proxy");
Override default methods to customize you page:
aducid.processResult = function(result) { if (result.status == "OK") { //authentication successful - reload page, redirect or display authenticated content location.reload(); } else { //display error status from result.data.message } }
Text displayed before operation
aducid.showQRHint = function(param) { $('#qr-code-hint').html("Example text - Use your PEIG to authenticate"); }
Text displayed during operation
aducid.showRunningHint = function(param) { $('#qr-code-hint').html("Example text - Operation in progress"); }
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <script type="text/javascript" src="/aducid-resources/js/jquery.min.js"></script> <script type="text/javascript" src="/aducid-resources/js/aducid-api.js"></script> <script type="text/javascript"> var aducid = new ADUCID(); $(document).ready(function() { aducid.setAuthentication(); aducid.setStartOperationUrl("/aducid-binder/open"); aducid.setResultOperationUrl("/aducid-binder/openCheck"); aducid.setProxyUrl("/aducid-binder/proxy"); aducid.setRedirectUrl("/aducid-binder/"); aucid.setRedirectUrl("/myapp/authenticated"); aducid.setErrorPage("/myapp/errorPage"); aducid.processResult = function(result) { if (result.status == "OK") { alert("Success - status: " + result.status); location.href = result.redirect; } else { alert("Error - status: " + result.status); location.href = result.redirect; } } //handle PEIG not installed error aducid.showPeigError = function() { alert("peig not found or other error"); } //handle communication or other error aducid.handleError = function(e) { alert(e.data.message); } aducid.showQRHint = function(param) { $('#qr-code-hint').html("Scan QR or click button to authenticate"); } aducid.showRunningHint = function(param) { $('#qr-code-hint').html("Operation is running"); }; //GUI mapping aducid.setButton($("#main-button")); aducid.setQrCode($("#qr-code")); aducid.setQrHint($("#qr-code-hint")); //start aducid.init(); }); </script> </head> <body> <h1>LOGIN PAGE</h1> <div> <button id="main-button">LOGIN using local PEIG</button> </div> <img id="qr-code" alt="" /> <div id="qr-code-hint"></div> </body> </html>
See also source file “/aducid-resources/js/aducid-api.js”
Method to pass more parameters like transaction amount, description, etc.
aducid.setInitParams = function(param) { initParams = param; }
aducid.setGenerateQr = function(param) { generateQr = param; }
aducid.setQrCode = function(param) { qrCode = param; }
aducid.setQrHint = function(param) { qrHint = param; }
aducid.setDebug = function(param) { aducidDebug = param; }
Tell Web API where your start operation is.
aducid.setStartOperationUrl = function(param) { startOperationUrl = param; }
aducid.setResultOperationUrl = function(param) { resultOperationUrl = param; }
POST is used to deliver more data like transaction parameters
aducid.setAjaxMethod = function(param) { ajaxMethod = param; }
aducid.setRedirectUrl = function(param) { redirectUrl = param; }
aducid.setButton = function(param) { aducidButton = param; param.click(function() { if (currentRequest != null) instance.startOperation(); else instance.init(true); }); }
<sxh java>
aducid.getSessionBinding = function() { return localStorage['session-binding']; }
</sxh java>
Is binding URI?
aducid.isURI = function() { return instance.getSessionBinding() == "URI"; }
Is binding QR?
aducid.isQR = function() { return instance.getSessionBinding() == "QR"; }
Is this operation going to be authentication (i.e. first operation in chain)?
aducid.setAuthentication = function() { instance.setSessionBinding(null); }
Text hint shown before operation started
aducid.showQRHint = function(param) { if (qrHint != null) qrHint.html(localize("aducid_common_authenticateComment")); }
How API can hide text hint
aducid.hideQRHint = function(param) { if (qrHint != null) qrHint.html(""); }
Text hint shown after operation started
aducid.showRunningHint = function(param) { if (qrHint != null) qrHint.html(localize("aducid_common_authenticationProgress")); }
How API can hide text hint
aducid.hideRunningHint = function(param) { if (qrHint != null) qrHint.html(""); }
The most important method - what API should do when operation finishes (not processed on iOS as we use returnUrl directly there)
aducid.processResult = function(result) { alert(result); }
How PEIG not installed is treated, marketplace redirect can be used here
aducid.showPeigError = function() { alert("peig error - override this function") }
Auxiliary method to animate operation in progress
aducid.startAnimation = function() { if (qrCode != null) { qrCode.show(); qrCode.attr("src", "/aducid-resources/img/running.gif"); } }
Stop animation
aducid.stopRunningAnimation = function() { if (qrCode == null) return; qrCode.hide(); }
How errors are treated - use nice dialogues here
aducid.handleError = function(e) { alert(e); }