17
ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565 Page 1 DOCUMENTATION ON FM220U WINDOWS APPLICATION Contents 1 Introduction ................................................................................................................................................... 2 1.1 RD Service Info Call ………………………............................................................................................ 2 1.2 Device Info Call …..…………………………........................................................................................... 3 1.3 Capture Call …………………………………............................................................................................ 3 1.4 Authentication Call ………………………............................................................................................ 5 1.5 Example for How to Generate Authentication XML Call ……………………….................... 6

DOCUMENTATION ON FM220U WINDOWS … Windows Application.pdfaccess computech pvt ltd. helpline numbers: 7874078565/ 8141958565 page 1 documentation on fm220u windows application contents

Embed Size (px)

Citation preview

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 1

DOCUMENTATION ON FM220U WINDOWS APPLICATION

Contents

1 Introduction ................................................................................................................................................... 2

1.1 RD Service Info Call ………………………............................................................................................ 2

1.2 Device Info Call …..…………………………........................................................................................... 3

1.3 Capture Call …………………………………............................................................................................ 3

1.4 Authentication Call ………………………............................................................................................ 5

1.5 Example for How to Generate Authentication XML Call ……………………….................... 6

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 2

1. Introduction:

- RD Service does necessary processing / extraction, captures good fingerprint, creates the

digitally signed certificate, forms the encrypted PID block, and gives the encrypted PID

block back to application along with other details including Device Information.

JAVASCRIPT CODE TO CALL RD Service 1.1 RD Service Info call:

- RD Service option will show status of RD Service for particular device if it is ready or not.

<!-- HTML button control to call rdservice info call --> <input type="button" value="RD service" onclick="rdservice()" />

<!--This function will be called on “info” button click... -->

Function rdservice() { getJSON_rd('http://localhost:11100/rd', function (err, data) { if (err != null) { alert('Something went wrong: ' + err); } else { document.getElementById("<%=PidData.ClientID%>").value = String(data); // getElementById() method returns pid data about client } } ); } <!-- This function will be called from above button click function... -->

var getJSON_rd = function (url, callback) { var xhr = new XMLHttpRequest(); xhr.open('RDSERVICE', url, true); xhr.responseType = 'text'; xhr.onload = function () { var status = xhr.status; if (status == 200) { callback(null, xhr.response); } else { callback(status); } }; xhr.send();

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 3

};

1.2 Device Info Call: <!-- HTML button control to call device info call--> <input type="button" value="Info" onclick="info()" /> <!-- This function will be called on button click...--> function info() { getJSON_info('http://localhost:11100/rd/info', function (err, data) { if (err != null) { alert('Something went wrong: ' + err);

} else { document.getElementById("<%=PidData.ClientID%>").value = String(data); // getElementById() method returns pid data about client

} } ); } <!-- This function will be called from above button click function... --> var getJSON_info = function (url, callback) { var xhr = new XMLHttpRequest();

xhr.open('DEVICEINFO', url, true); xhr.responseType = 'text'; xhr.onload = function () { var status = xhr.status; if (status == 200) { callback(null, xhr.response); } else { callback(status); } }; xhr.send(); };

1.3 Capture call:

<!--HTML button control to call Capture call-->

<input type="button" value="Capture" onclick="captureFP()" />

<!--This function will be called on button click...-->

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 4

function captureFP() { getJSONCapture('http://localhost:11100/rd/capture', function (err, data) {

if (err != null) { alert('Something went wrong: ' + err); } else {

document.getElementById("PidData").value = String(data); // get the element with id= “PidData” with specified value.

} }

); }

<!-- This function will be called from above button click function.. --> var getJSONCapture = function (url, callback) { var xhr = new XMLHttpRequest(); xhr.open('CAPTURE', url, true); xhr.responseType = 'text';

var InputXml = "<PidOptions> <Opts fCount=\"1\" fType=\"0\" iCount=\"0\" pCount=\"0\" format=\"0\" pidVer=\"2.0\" timeout=\"20000\" otp=\"\" posh=\"LEFT_INDEX\" env=\"S\" wadh=\"\" /> <Demo></Demo> <CustOpts> <Param name=\"ValidationKey\" value=\"js1fuuea8+e7lE1MEow3VX6SyG1WuNETPSrfEip83zBzIBxTgGDYI8X9KUffza0U64BpryYJRLRkg3rIkyHemqe+OxFetRI1QQKvVtAG/9lP+ibAqzGboPugE5YtfqbXEjkMEMZtupumTgmwyE0ut5KgA5ai19KXFU+3bLHol5NCCYmLJynrCQkaZJPc81aF\" /> </CustOpts> </PidOptions>";

/* <Demo>: Element allows demographic data to be passed to form PID block as per authentication

specification. <CustOpts>: no application should hard code these and should be configured on app or AUA servers.

These parameters can be used for any custom application authentication or for other configuration parameters. Device providers can differentiate their service in the market by enabling advanced algorithms that applications can take advantage of.

Opts:

Int fCount (optional) number of finger records to be captured (0 to 10) Int fType (optional) ISO format (0 for FMR or 1 for FIR), 0 (FMR) is default Int iCount (optional) number of iris records to be captured (0 to 2) Int pCount (optional) number of face photo records to be captured (0 to 1). Currently face matching

is not supported. Int format (mandatory) 0 for XML, 1 for Protobuf

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 5

String pidVer (mandatory) PID version Int timeout capture timeout in milliseconds String env (optional) default value being "P"(prod), other valid values are "PP"(preProd) and

"S"(Staging). String otp (optional) OTP value captured from user in case of 2-factor auth String wadh (optional) If passed, RD Service should use this within PID block root element “as-is”. String posh (optional) if specific positions need to be captured, applications can pass a comma

delimited position attributes. See “posh” attribute definition in Authentication Specification for valid values. RD Service (if showing preview) can indicate the finger using this. If passed, this should be passed back within PID block. Default is “UNKNOWN”, meaning “any” finger/iris can be captured. */

xhr.onload = function () { var status = xhr.status; if (status == 200) { callback(null, xhr.response); } else { callback(status); } }; xhr.send(InputXml);

};

1.4 Authentication call: <!-- ASP.NET button control to call Capture call -->

<asp:Button ID="BtnAuth" runat="server" Text="Authenticate" OnClientClick="convertData(); return true;" OnClick="BtnAuth_Click" /> <!-- here convertData() javascript function is used to encode string into HTML encoded data Function-->

convertData() {

document.getElementById("<%=PidData.ClientID%>").value = String(document.getElementById("<%=PidData.ClientID%>").value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); }

<!-- Here OnClick event will be handled by backend code...--> <!-- Refer AuthXMl generation code to know about Auth XML generation -->

protected void BtnAuth_Click(object sender, EventArgs e) {

string pidData_xml = HttpUtility.HtmlDecode(PidData.Text); if (txtAadhaar.Text.Trim().Length > 0 && pidData_xml.Trim().Length > 0 &&

pidData_xml.Substring(0,8).ToUpper().Equals("<PIDDATA") && (pidData_xml.ToUpper().Contains("ERRCODE=\"0\"") || pidData_xml.ToUpper().Contains("ERRCODE=\"\"")))

{

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 6

if (Aadhar_code.AuthenticateRequest(txtAadhaar.Text, pidData_xml)) { Result.Text = "Success."; } else { Result.Text = "Failed"; } PidData.Text = ""; } else { Result.Text = "Invalid value or Capture Error"; } }

1.5 Example for How to Generate Authentication XML Call: - This Code is only for reference purpose.

// VBConversions Note: VB project level imports

using System.Data; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls.WebParts; using System.Diagnostics; using System.Xml.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Collections.Specialized; using System.Web.Profile; using Microsoft.VisualBasic; using System.Configuration; using System.Web.UI.WebControls; using System.Collections; using System; using System.Web; using System.Web.UI; using System.Web.SessionState; using System.Security.Cryptography; using System.Text; using System.Web.Caching; using System.Web.Security; using System.Linq; // End of VB project level imports using System.Xml; using System.Xml.Serialization; using System.IO;

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 7

namespace Aadhaar_FM220_PID_web { public class Aadhar_code { public static string FieldTerminalID = "registered"; public static string Aua = "public"; public static string ServiceAgency = "public"; public static string signaturePassword = "public"; public static bool SignXML = true; public static string URL = "http://developer.uidai.gov.in/auth";

//public static string URL = "http://developer.uidai.gov.in/auth";

public static bool ShowXml = true; public static AuthResponseDetails ResData = new AuthResponseDetails(); private static string encryptedPidBlk = ""; private static string encryptrdSkey = ""; private static string cert_Ident = ""; private static string encryptedHmac = ""; private static string dev_type = ""; private static string dev_code = ""; private static string pub_cert = ""; private static string prvd_code = ""; private static string term_id = ""; private static string dev_UDC = "";

private static string dpid = ""; private static string rdsid = ""; private static string rdsver = "";

public static bool AuthenticateRequest(string uidStr, string pidXmlData) { try { Uses uses = createUsesElement(); AuthDataFromDeviceToAUA auaData = null; readPidXmlData(pidXmlData); Meta meta_data = createMeta(); auaData = prepareAUAData(uidStr, FieldTerminalID,

meta_data); Auth auth = createAuthRequest(Aua, ServiceAgency, LicenseKey, uses, auaData, meta_data); ResData = ClientAuthenticate(auth); if (!ReferenceEquals(ResData, null)) { if (ReferenceEquals(ResData.authRes, null)) {

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 8

return false; } if (ResData.authRes.ret == "Y") { return true; } } else { ResData = new AuthResponseDetails(); ResData.authRes = new AuthRes(); ResData.authRes.ret = "N"; ResData.authRes.err = "Server Error"; return false; } } catch (Exception) { //HANDLE EXCEPTION } return false; } public static AuthResponseDetails ClientAuthenticate(Auth auth) { AuthResponseDetails retAuth = new AuthResponseDetails(); try { string signedXML = generateAuthXML(auth); //Now Sign Auth Xml and Send to Auth Sever...... } catch (Exception ex) { //HANDLE EXCEPTION } return null; } public static string generateAuthXML(Auth auth) { string RetVal = "";

RetVal = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";

//RetVal = RetVal + "<Auth";

RetVal = RetVal + "<Auth xmlns=\"http://www.uidai.gov.in/authentication/uid-auth-request/2.0\"";

//RetVal = RetVal + "<Authxmlns=\"http://www.uidai.gov.in/authentication/uid-auth request/1.0\"";

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 9

RetVal = RetVal + " uid=\"" + auth.uid + "\""; RetVal = RetVal + " rc=\"" + auth.rc + "\""; RetVal = RetVal + " tid=\"" + auth.tid + "\""; RetVal = RetVal + " ac=\"" + auth.ac + "\""; RetVal = RetVal + " sa=\"" + auth.sa + "\""; RetVal = RetVal + " ver=\"" + auth.ver + "\""; RetVal = RetVal + " txn=\"" + auth.txn + "\""; RetVal = RetVal + " lk=\"" + auth.lk + "\">"; SignXML = true; RetVal = RetVal + auth.Uses; RetVal = RetVal + "<Meta"; RetVal = RetVal + " udc=\"" + auth.Meta.udc + "\""; RetVal = RetVal + " rdsId=\"" + auth.Meta.rdsId + "\"";

RetVal = RetVal + " rdsVer=\"" + auth.Meta.rdsVer + "\""; RetVal = RetVal + " dpId=\"" + auth.Meta.dpId + "\"";

RetVal = RetVal + " dc=\"" + auth.Meta.dc + "\""; RetVal = RetVal + " mi=\"" + auth.Meta.mi + "\""; RetVal = RetVal + " mc=\"" + auth.Meta.mc + "\"/>";

RetVal = RetVal + "<Skey ci=\"" + auth.Skey.ci + "\">"; RetVal = RetVal + auth.Skey.valueBs64 + "</Skey>"; RetVal = RetVal + "<Data type=\"X\">" + auth.Base64Data + "</Data>"; RetVal = RetVal + "<Hmac>" + auth.Hmac + "</Hmac>"; RetVal = RetVal + "</Auth>"; return RetVal; } public static AuthDataFromDeviceToAUA prepareAUAData(string uid, string

terminalId, Meta meta) { try { byte[] EncryptedSessionKey =

Convert.FromBase64String(encryptrdSkey); byte[] encryptedHmacBytes =

Convert.FromBase64String(encryptedHmac); byte[] encPID = Convert.FromBase64String(encryptedPidBlk); string certificateIdentifier = cert_Ident; string dataType = "X"; AuthDataFromDeviceToAUA auaData = new

AuthDataFromDeviceToAUA(); auaData.uid = uid; auaData.terminalId = terminalId; SessionKeyDetails sessionKeyDetails = new

SessionKeyDetails();

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 10

sessionKeyDetails.normalSkey = EncryptedSessionKey; sessionKeyDetails.keyIdentifier = cert_Ident; auaData.sessionKeyDetails = sessionKeyDetails; auaData.encryptedPid = encPID; auaData.encrytpedHmac = encryptedHmacBytes; auaData.certificateIdentifier = certificateIdentifier; auaData.dataType = dataType; auaData.meta = meta; return auaData; } catch (Exception) { //HANDLE EXCEPTION } //return null; } public static Auth createAuthRequest(string aua, string sa, string licenseKey,

Uses uses, AuthDataFromDeviceToAUA auaData, Meta metaData) { Auth authval = new Auth(); authval.uid = auaData.uid; authval.ver = "2.0"; authval.ac = aua; authval.rc = "Y"; authval.sa = sa; authval.txn = "AuthDemoClient" + ":" + aua + ":" +

Strings.Format(DateTime.Now, "yyyyMMddhhmmssfff"); authval.lk = licenseKey; authval.tid = auaData.terminalId; authval.Meta = metaData; Skey sk = new Skey(); sk.ci = auaData.certificateIdentifier; sk.valueBs64 =

Convert.ToBase64String(auaData.sessionKeyDetails.normalSkey);

sk.ki = auaData.sessionKeyDetails.keyIdentifier; authval.Skey = sk; authval.Base64Data = Convert.ToBase64String(auaData.encryptedPid); authval.Hmac = Convert.ToBase64String(auaData.encrytpedHmac); authval.Uses = "<Uses pi=\"n\" pa=\"n\" pfa=\"n\" bio=\"y\"

bt=\"FMR\" pin=\"n\" otp=\"n\"/>"; return authval; } private static Meta createMeta() { Meta m = new Meta(); m.dc = dev_code.ToUpper(); m.udc = dev_UDC;

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 11

m.dpId = dpid; m.rdsId = rdsid; m.mi = prvd_code; m.mc = pub_cert; m.rdsVer = rdsver; return m; } private static Uses createUsesElement() { Uses uses = new Uses(); uses.pi = "n"; uses.pa = "n"; uses.pin = "n"; uses.otp = "n"; uses.bio = "y"; uses.pfa = "n"; uses.bt = "FMR"; return uses; } public class AuthResponseDetails { public AuthRes authRes; public string xml; } public class AuthRes { public string ret; public string code; public string txn; public string err; public string info; public string ts; } public class Auth { public string uid; public string rc; public string ac; public string tid; public string ver; public string txn; public string lk; public string sa; public string Uses; public Meta Meta;

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 12

public Skey Skey; public string Base64Data; public string Hmac; } public class Skey { public string valueBs64; public string ci; public string ki; } public class Meta { public string udc; public string rdsId; public string rdsVer; public string dpId; public string dc; public string mi; public string mc; //Public irmi As String //Public irmc As String //Public fdmi As String //Public fdmc As String //Public pip As String //Public fdc As String //Public idc As String //Public lot As String //Public lov As String

} public class Uses { public string pi; public string pa; public string pfa; public string bio; public string bt; public string pin; public string otp; } public class AuthDataFromDeviceToAUA { public string uid; public string terminalId; public byte[] encryptedPid; public byte[] encrytpedHmac;

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 13

public string certificateIdentifier; public string dataType; public SessionKeyDetails sessionKeyDetails; public Meta meta; } public class SessionKeyDetails { public bool isSynchronizedKeySchemeUsed; public bool isSynchronizedKeyBeingInitialized; public byte[] seedSkeyForSynchronizedKey; public byte[] randomNumberForSynchornizedKey; public string keyIdentifier; public byte[] normalSkey; } public class SynchronizedKey { public byte[] seedSkey; public string keyIdentifier; } private static void readPidXmlData(string pidXml) { PidData piddt = default(PidData); var serializer = new XmlSerializer(typeof(PidData)); using (var stream = new StringReader(pidXml)) { using (var reader = XmlReader.Create(stream)) { piddt = (PidData) (serializer.Deserialize(reader)); } } encryptrdSkey = piddt.Skey.Value; cert_Ident = piddt.Skey.ci; encryptedHmac = piddt.Hmac.Value;

dev_UDC = "102"; // piddt.DeviceDriverInfo.dpId; dev_type = "F";

term_id = "registered"; dev_code = piddt.DeviceInfo.dc.Replace("-", ""); prvd_code = piddt.DeviceInfo.mi; pub_cert = piddt.DeviceInfo.mc; encryptedPidBlk = piddt.Data.Value;

dpid = piddt.DeviceInfo.dpId; rdsid = piddt.DeviceInfo.rdsId;

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 14

rdsver = piddt.DeviceInfo.rdsVer; } private static void readDeviceDeriverInfoXmlData(string infoXml) { using (XmlReader reader = XmlReader.Create(new

System.IO.StringReader(infoXml))) { reader.ReadToFollowing("DeviceDriverInfo"); if (reader.GetAttribute("providerCode") != null &&

string.IsNullOrEmpty(reader.GetAttribute ("providerCode")) == false)

{ reader.MoveToAttribute("providerCode"); dev_UDC = reader.Value.ToString(); } reader.ReadToFollowing("Device"); if (reader.GetAttribute("type") != null &&

string.IsNullOrEmpty(reader.GetAttribute ("type")) == false)

{ reader.MoveToAttribute("type"); dev_type = reader.Value.ToString(); } if (reader.GetAttribute("tid") != null &&

string.IsNullOrEmpty(reader.GetAttribute ("tid")) == false)

{ reader.MoveToAttribute("tid"); term_id = reader.Value.ToString(); } if (reader.GetAttribute("dc") != null &&

string.IsNullOrEmpty(reader.GetAttribute ("dc")) == false)

{ reader.MoveToAttribute("dc"); dev_code = reader.Value.ToString(); } if (reader.GetAttribute("mi") != null &&

string.IsNullOrEmpty(reader.GetAttribute ("mi")) == false)

{ reader.MoveToAttribute("mi"); prvd_code = reader.Value.ToString(); } if (reader.GetAttribute("mc") != null &&

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 15

string.IsNullOrEmpty(reader.GetAttribute ("mc")) == false)

{ reader.MoveToAttribute("mc"); pub_cert = reader.Value.ToString(); } } } } [XmlType("PidData")] public class PidData { public Resp Resp { get; set; } public DeviceInfo DeviceInfo { get; set; } public Skey Skey { get; set; } public Hmac Hmac { get; set; } public Data Data { get; set; } public PidData() { Resp = new Resp(); Skey = new Skey(); Data = new Data(); Hmac = new Hmac(); DeviceInfo = new DeviceInfo(); } } [XmlType("Skey")] public class Skey { [XmlAttribute("ci")] public String ci { get; set; } [XmlText] public string Value { get; set; } public Skey() { ci = ""; Value = ""; } } [XmlType("Hmac")] public class Hmac { [XmlText] public string Value { get; set; }

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 16

public Hmac() { Value = ""; } } [XmlType("Data")] public class Data { [XmlAttribute("type")] public String type { get; set; } [XmlText] public string Value { get; set; } public Data() { type = ""; Value = ""; } } public class Resp { [XmlAttribute("errCode")] public String errCode { get; set; } [XmlAttribute("errInfo")] public String errInfo { get; set; } [XmlAttribute("fCount")] public String fCount { get; set; } [XmlAttribute("fType")] public String fType; [XmlAttribute("iCount")] public String iCount; [XmlAttribute("pCount")] public String pCount; [XmlAttribute("ts")] public String ts { get; set; } [XmlAttribute("nmPoints")] public String nmPoints { get; set; } [XmlAttribute("qScore")] public String qScore { get; set; } public Resp() { errCode = ""; errInfo = ""; fCount = "0"; ts = ""; nmPoints = ""; qScore = "";

ACCESS COMPUTECH PVT LTD. HELPLINE NUMBERS: 7874078565/ 8141958565

Page 17

fType = "0"; iCount = "0"; pCount = "0"; } }

[XmlType("DeviceInfo")] public class DeviceInfo { [XmlAttribute("dpId")] public String dpId { get; set; } [XmlAttribute("rdsId")] public String rdsId { get; set; } [XmlAttribute("rdsVer")] public String rdsVer { get; set; } [XmlAttribute("dc")] public String dc { get; set; } [XmlAttribute("mi")] public String mi { get; set; } [XmlAttribute("mc")] public String mc { get; set; } public DeviceInfo() { dpId = ""; //ACP220STK rdsId = ""; rdsVer = ""; dc = ""; mi = ""; mc = ""; } } }