Tutorial Section

UIDAI has created a fully working sample Java client application to help the community rapidly develop applications that use Aadhaar authentication. This application is written in Java and demonstrates various features of Aadhaar authentication. This application is provided on an "AS-IS" basis and should not be considered as a supported, production strength software. This chapter covers details about downloading, installing, and running the sample and setting up development environment with the source code.

Sample Java application (both binary and source code zip files) to test Aadhaar authentication can be downloaded from here.

Running Sample from Distribution

When you download the binary distribution using downlink above, you get "auth-client-bin-1.5.zip". Follow steps below to install and run the client. These directions are for Windows OS. If you are using Linux or other OS, you may make appropriate modification to build and run the client.

You need Java 1.6 or above installed on your computer and an Internet connection to run this sample.

Unzip "auth-client-bin-1.5.zip" into a directory. You will see the following contents.


Sample Client Runtime Directory Listing

Run "runclient.bat" to run the sample application.

In order to use Indian name matching, it is required that the java apps run in UTF-8 character encoding mode. For that, in Java, following VM arguments has to be passed "-Dfile.encoding=UTF8". This is already added to the "runclient.bat" file.

This opens a command promt asking for OS type, enter 1 or 2 (based on your OS) and press ENTER.

This opens the sample authentication client. See screenshot below.


Auth Client Main Screen

Click "Edit->Preferences" menu to make sure you see following screen with values. Ensure license key, AUA code, Sub AUA code are as listed under "Testing Data" page.


Auth Client Preferences Screen

Now you are ready to test!!

Enter "999999990019" in "Aadhaar Number" field and "Shivshankar Choudhury" in the "Name" field. See "Testing Data" page for details on test data for testing various combinations.

Click "Authenticate" button at the bottom right

You should see a green tick mark within the "Authentication Status" field. See the following screen


Auth Client Result Screen

If you have issues, first ensure you have followed all steps correctly. If you face network or connection errors, please make sure your Internet connection is working well. If test server (auth.uidai.gov.in) is down or not reachable, try after some time.

If nothing works (!), please write to the discussion group.

As explained in previous chapter, sample Java client with source code is provided to help the community rapidly develop applications that use Aadhaar authentication. This application is written in Java and demonstrates various features of Aadhaar authentication. This application is provided on an "AS-IS" basis and should not be considered as a supported, production strength software. This chapter covers details about downloading and setting up development environment.

Sample Java application (both binary and source code zip files) to test Aadhaar authentication can be downloaded from here.

Setting up Development Environment

When you download the source distribution using downlink above, you get "auth-client-source-1.5.zip". Follow steps below to setup the client as a development environment. These directions are for Windows OS. If you are using Linux or other OS, you may make appropriate modification to the instructions below.

You need

Java 1.6.20 or above, Apache Maven 2.2.1 or above, and Eclipse Java IDE installed on your computerto setup environment based on this page.

You can use the source code and setup environment if you want it in other IDEs and build environments.

Unzip "auth-client-source-1.5.zip" into a directory. You should now see a directory named "auth-client-source-1.5" there

Navigate to "auth-client-source-1.5" directory. You should see the following listing.


Auth Client Source Directory Listing

Within "Command Prompt", change directory ("cd") to "auth-client-source-1.5"

Run "mvn eclipse:eclipse" command. If "Maven\bin" is not in path, please add it. Otherwise "mvn" command will not run.

You should see "Build Successful" message like below.


Auth Client Sample - Maven Build Screen

Launch Eclipse and create a new workspace (or use current workspace if you prefer)

Choose "File->Import" menu. This lanuches an import dialog.

Choose "Existing Projects into Workspace" option and click "Next"

Click "Browse" button next to "Select Root Directory"

Navigate to "auth-client-source-1.5" and select the directory

This will list 4 projects - "uidai-auth-client", "uidai-auth-xsd-model", "uidai-biometric-integration-api", and "uidai-sample-gui-app"

Make sure all projects are selected. See screen below.


Auth Client Sample - Eclipse Import Screen

Click "Finish" to import all 4 projects into workspace

If you have project that provides biometric integration API implementation, you will have to add it to the class path of the "uidai-sample-gui-app" project.Also, update the value of field, biometricAPIImplementationClass, in the SampleClientMainFrame.java to the value of the class that implements the API.

Select "SampleClientMainFrame.java" under project "uidai-sample-gui-app" (src/main/java/in/gov/uidai/auth/sampleapp folder) and choose "Run->Run COnfigurations" menu or click "Run" icon on toolbar and choose "Run COnfigurations".


Auth Client - Eclipse Run Configuration Menu

Click "New Launch Configuration" icon on left top corner within the dialog. This created a new default run configuration for the sample application.

In order to use Indian name matching, it is required that the java apps run in UTF-8 character encoding mode. For that, in Java, following VM arguments has to be passed "-Dfile.encoding=UTF8". Within "Run Configurations" doalog, add this to VM arguments


Auth Sample Client - Eclipse Run Config Dialog

Click "Run" button on the bottom right within the "Run Configuration" dialog to run the application. you should see the sample application GUI window.

Choose "Edit->Preferences" menu option and ensure you choose appropriate path for public key file and keystore file (they are available under "auth-client-source-1.5\uidai-auth-client\src\main\resources" folder. Ensure license key, AUA code, Sub AUA code are as listed under "Testing Data" page

Enter "999999990019" in "Aadhaar Number" field and "Shivshankar Choudhury" in the "Name" field. Additional data is available on "Testing Data" page.

Click "Authenticate" button at the bottom right

You should see a green tick mark within the "Authentication Status" field. See the following screen


Auth Client Result Screen

If you have issues, first ensure you have followed all steps correctly. If you face network or connection errors, please make sure your Internet connection is working well. If test server (auth.uidai.gov.in) is down or not reachable, try after some time.

If nothing works (!), please write to the discussion group

NOTE: This code is contributed by Geodesic team and is available on as-is basis. Sample C application to test Aadhaar authentication can be downloaded from here.

A sample C client with source code is provided to help the community rapidly develop applications that use Aadhaar authentication. This sample application is written in C for the GeoAmida device and it demonstrates various features of Aadhaar authentication. This application is provided on an "AS-IS" basis and should not be considered as a supported, production strength software. This chapter covers details about downloading and setting up development environment.

Setting up Development Environment

When you download the source distribution from the link above, you get "c-auth-client-source-1.5.zip". Please follow steps below to setup the client as a development environment. These directions are for Linux OS and ARM devices. If you are using Windows or other OS, you may make appropriate modification to the instructions below.

Unzip "c-auth-client-source-1.5.zip" into a directory. You should now see a directory named "c-auth-client-source-1.5" there

Navigate to "c-auth-client-source-1.5" directory. You should see the following listing.

Directory Listing

Dependency Libraries:
libxml >= 2.7.6
openssl >= 0.9.8
Digital Signature Generation requires an additional libraries:
libXslt >= 1.1.24
libxmlsec1 >= 1.2.9

The below DEFINES values are need to modify before compiling:
LICENCE_KEY
UIDAI_PUBLIC_CERITIFICATE
AUA_PRIVATE_CERTIFICATE - Required for Digital Signature

Auth Xml API documentation is available under the doc folder


API Functions

You may use any editor tool (Eclipse, emacs or vim) installed on your development machine and setup the environment variable, LD_LIBRARY_PATH in order to find libraries.

Within "Command Prompt", change directory ("cd") to "c-auth-client-source-1.5

Sample Makefile included in the build for Geoamida and gcc version.
CC = arm-xscale-linux-gnueabi-gcc

On a successful make, you should see the executable file AuthClient.

Run AuthClient. It will generate Auth-XML. During compilation if the "-D XML_SECURITY" flag is set, then the Digital Signature will be created along with Auth Xml.

Sample Data:

Offline ekyc Xml

string XMLFilePath = ""; //Get the XML file
            string KeyFilePath = ""; //Get the public key certificate file
            string XMLFileContent = System.IO.File.ReadAllText(XMLFilePath); //Read the all xml content
            XmlDocument ObjXmlDocument = new XmlDocument(); //Create the object of Xml Document
            ObjXmlDocument.LoadXml(XMLFileContent); //Load the XML in XML Document
            SignedXml signedXml = new SignedXml(ObjXmlDocument); //
            XmlNodeList nodeList = ObjXmlDocument.GetElementsByTagName("Signature"); //Get the Signature value from XML file
            XmlNodeList certificates = ObjXmlDocument.GetElementsByTagName("X509Certificate"); //Get the certificate value from XML file            
            X509Certificate2 objX509Certificate2;
            objX509Certificate2 = new X509Certificate2(KeyFilePath, "public");
            //X509Certificate2 dcert2 = new X509Certificate2(Convert.FromBase64String(certificates[0].InnerText));
            bool passes = false;
            foreach (XmlElement element in nodeList)
            {
                signedXml.LoadXml(element);
                passes = signedXml.CheckSignature(objX509Certificate2, true); //validate the signed XML
            }
            if (passes)
            {
                MessageBox.Show("XML Validate Successfully");
            }
            else
            {
                MessageBox.Show("XML Validation Failed");

            }