<commit_before>Python Client and Library for Aadhaar Authentication Service
------------------------------------------------------------

This python package supports biometrics and demographics
authentication using the Aadhaar Authentication Service (also known as
UID).

This implementation is basically compliant with
[Aadhaar authentication API Ver 1.5 (Rev 1)][spec] but WIP. 

[spec]: http://uidai.gov.in/images/FrontPageUpdates/aadhaar_authentication_api_1_5_rev1_1.pdf

Latest Release
--------------

  * Alpha Release (0.1) Nov 15, 2011 - Planned 
  * Platform support: Linux (Ubuntu) and Python 

Features
--------

  * Support for both biometrics and demographics
  * Simple API 
  * Automatic validation checks - UID numbering scheme, XSD compliance,
    encryption, and other checks    
  * Batch processing 
  * Extensive debugging information 
  * Easy configuration file

Example
-------

Download the [sample client][dl] 

[dl]: https://github.com/pingali/pyAadhaarAuth/blob/master/AadhaarAuth/simple-client.py

>         
>         
>      #!/usr/bin/env python     
>      """     
>      Simplest possible python client      
>      """      
>      import logging    
>      import sys    
>      from config import Config    
>      
>      from request import AuthRequest
>      
>      if __name__ == '__main__':   
>          assert(sys.argv)   
>          if len(sys.argv) < 3:   
>              print "Usage: simple-client.py <config-file> <uid> <name>"   
>              print "Please use default config file in fixtures/auth.cfg"    
>              sys.exit(1)    
>      
>          logging.basicConfig()   
>          
>          # Load sample configuration    
>          cfg = Config(sys.argv[1])   
>             
>          # Update the request information    
>          cfg.request.uid = sys.argv[2]   
>          cfg.request.name = sys.argv[3]   
>      
>          # Create the request object and execute   
>          req = AuthRequest(cfg)   
>          req.execute()   
>     


Installation
------------

Install dependencies    

>         
>        $ sudo apt-get install python-dev libxml2-dev libxslt1-dev libxmlsec1    
>        $ sudo apt-get install libxmlsec1-dev    
>        $ sudo pip install lxml pyxmlsec libxml2 M2Crypto    

Prepare working directory 

>         
>        $ mkdir auth-client   
>        $ WORK='pwd'/auth-client   

Install from repository. We will distribute it using Pypi once the
code stabilizes.

>         
>        $ cd /tmp   
>        $ wget --no-check-certificate -O pyAadhaarAuth.zip https://github.com/pingali/pyAadhaarAuth/zipball/master   
>        $ unzip pyAadhaarAuth.zip    
>        $ cd pyAadhaarAuth/pingali-pyAaadhaarAuth-a18142   
>        $ sudo python setup.py install    

Once installed populate the working directory with a simple client and
additional configuration files. Then perform the first authentication
request. 

>         
>        $ aadhaar-generate-client.py .      

This will install a sample client, certificates and configuration files. Now run the client. 

>        
>        $ ./aadhaar-sample-client.py  fixtures/auth.cfg 999999990019 "<NAME>"     
>        (999999990019,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': '<NAME>', 'ms': 'E'}, 'uid': '999999990019', 'demographics': ['Pi'], 'xmlcleanup': True, 'biometrics': [], 'command': 'generate', 'analyze': True}) -> y

'y' shows successful authentication. Note that this client is capable
of doing both demographic and biometric authentication but only does
demographic for now. You can enable biometric authentication by
uncommenting the relevant lines in the sample client. The parameters for the command line are valid testing values provided by UIDAI on their site.

Now run the batch client. Valid test data from the UIDAI site is
stored in fixtures/test_data.json and the file already specified in
auth.cfg file. In this case you can run the script installed by the
package in /usr/local/bin (on Linux).

>          
>       aadhaar-batch-client.py fixtures/auth.cfg 
>       (999999990019,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': u'<NAME>', 'ms': 'E'}, 'uid': u'999999990019', 'demographics': ['Pi'], 'FMR': {'bio': u'<KEY>'}, 'xmlcleanup': True, 'biometrics': ['FMR'], 'command': 'generate', 'analyze': True}) -> y
>       (999999990026,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': u'<NAME>', 'ms': 'E'}, 'uid': u'999999990026', 'demographics': ['Pi'], 'FMR': {'bio': u'<KEY>'}, 'xmlcleanup': True, 'biometrics': ['FMR'], 'command': 'generate', 'analyze': True}) -> y
>       (999999990042,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': u'<NAME>', 'ms': 'E'}, 'uid': u'999999990042', 'demographics': ['Pi'], 'FMR': {'bio': u'<KEY>'}, 'xmlcleanup': True, 'biometrics': ['FMR'], 'command': 'generate', 'analyze': True}) -> y
>       (999999990057,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': u'<NAME>', 'ms': 'E'}, 'uid': u'999999990057', 'demographics': ['Pi'], 'FMR': {'bio': u'<KEY>'}, 'xmlcleanup': True, 'biometrics': ['FMR'], 'command': 'generate', 'analyze': True}) -> y

Debugging
---------

Extensive logging is supported by the library to help with easy application development. You can enable it by choosing appropriate python logging parameters. For example the logging commands in the sample client file can be replaced by: 

>        
>       logging.getLogger().setLevel(logging.DEBUG) 
>       logging.basicConfig(
> 	                    filename='execution.log', 
>                           format='%(asctime)-6s: %(name)s - %(levelname)s - %(message)s')
>    

Look at execution.log in the local directory once the command is executed. 

Documentation
-------------

Please see docs/apidocs/index.html

Work-in-progress    
----------------

  Immediate: 
  1. Complete address, location and other demographic attributes     
  2. Test with https connection (whenever it is available) 
  3. Performance evaluation/statistics    

  Medium term:  
  1. Language support 
  2. ASA/AUA split operation model 
  3. Use the objectified xml to populate internal state    
  4. Look through the spec for validation rules beyond what the    
     XSD is providing (e.g., sanity checks)    
  5. Explore browser and mobile phone support 

Thanks 
------   <commit_msg>Readability edit<commit_after>Python Client and Library for Aadhaar Authentication Service
------------------------------------------------------------

This python package supports biometrics and demographics
authentication using the Aadhaar Authentication Service (also known as
UID).

This implementation is basically compliant with
[Aadhaar authentication API Ver 1.5 (Rev 1)][spec] but WIP. 

[spec]: http://uidai.gov.in/images/FrontPageUpdates/aadhaar_authentication_api_1_5_rev1_1.pdf

Latest Release
--------------

  * Alpha Release (0.1) Nov 15, 2011 - Planned 
  * Platform support: Linux (Ubuntu) and Python 

Features
--------

  * Support for both biometrics and demographics
  * Simple API 
  * Sample clients for single or batch requests 
  * Automatic validation checks - UID numbering scheme, XSD compliance,
    encryption, and other checks    
  * Extensive debugging information 
  * Easy configuration 

Example
-------

Download the [sample client][dl] 

[dl]: https://github.com/pingali/pyAadhaarAuth/blob/master/AadhaarAuth/simple-client.py

>         
>         
>      #!/usr/bin/env python     
>      """     
>      Simplest possible python client      
>      """      
>      import logging    
>      import sys    
>      from config import Config    
>      
>      from request import AuthRequest
>      
>      if __name__ == '__main__':   
>          assert(sys.argv)   
>          if len(sys.argv) < 3:   
>              print "Usage: simple-client.py <config-file> <uid> <name>"   
>              print "Please use default config file in fixtures/auth.cfg"    
>              sys.exit(1)    
>      
>          logging.basicConfig()   
>          
>          # Load sample configuration    
>          cfg = Config(sys.argv[1])   
>             
>          # Update the request information    
>          cfg.request.uid = sys.argv[2]   
>          cfg.request.name = sys.argv[3]   
>      
>          # Create the request object and execute   
>          req = AuthRequest(cfg)   
>          req.execute()   
>     


Installation
------------

Install dependencies    

>         
>        $ sudo apt-get install python-dev libxml2-dev libxslt1-dev libxmlsec1    
>        $ sudo apt-get install libxmlsec1-dev    
>        $ sudo pip install lxml pyxmlsec libxml2 M2Crypto    

Prepare working directory 

>         
>        $ mkdir auth-client   
>        $ WORK='pwd'/auth-client   

Install from repository. We will distribute it using Pypi once the
code stabilizes.

>         
>        $ cd /tmp   
>        $ wget --no-check-certificate -O pyAadhaarAuth.zip https://github.com/pingali/pyAadhaarAuth/zipball/master   
>        $ unzip pyAadhaarAuth.zip    
>        $ cd pyAadhaarAuth/pingali-pyAaadhaarAuth-a18142   
>        $ sudo python setup.py install    

Once installed populate the working directory with a simple client and
additional configuration files. Then perform the first authentication
request. 

>         
>        $ aadhaar-generate-client.py .      

This will install a sample client, certificates and configuration files. Now run the client. 

>        
>        $ ./aadhaar-sample-client.py  fixtures/auth.cfg 999999990019 "<NAME>"     
>        (999999990019,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': 'Shivshankar Choudhury', 'ms': 'E'}, 'uid': '999999990019', 'demographics': ['Pi'], 'xmlcleanup': True, 'biometrics': [], 'command': 'generate', 'analyze': True}) -> y

'y' shows successful authentication. Note that this client is capable
of doing both demographic and biometric authentication but only does
demographic for now. You can enable biometric authentication by
uncommenting the relevant lines in the sample client. The parameters for the command line are valid testing values provided by UIDAI on their site.

Now run the batch client. Valid test data from the UIDAI site is
stored in fixtures/test_data.json and the file already specified in
auth.cfg file. In this case you can run the script installed by the
package in /usr/local/bin (on Linux).

>          
>       aadhaar-batch-client.py fixtures/auth.cfg 
>       (999999990019,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': u'<NAME>', 'ms': 'E'}, 'uid': u'999999990019', 'demographics': ['Pi'], 'FMR': {'bio': u'Rk1SACAyMAAAAAD<KEY>'}, 'xmlcleanup': True, 'biometrics': ['FMR'], 'command': 'generate', 'analyze': True}) -> y
>       (999999990026,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': u'<NAME>', 'ms': 'E'}, 'uid': u'999999990026', 'demographics': ['Pi'], 'FMR': {'bio': u'<KEY>'}, 'xmlcleanup': True, 'biometrics': ['FMR'], 'command': 'generate', 'analyze': True}) -> y
>       (999999990042,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': u'<NAME>', 'ms': 'E'}, 'uid': u'999999990042', 'demographics': ['Pi'], 'FMR': {'bio': u'<KEY>'}, 'xmlcleanup': True, 'biometrics': ['FMR'], 'command': 'generate', 'analyze': True}) -> y
>       (999999990057,{'xml': '/tmp/request.xml', 'signedxml': '/tmp/request.xml.sig', 'Pi': {'name': u'<NAME>', 'ms': 'E'}, 'uid': u'999999990057', 'demographics': ['Pi'], 'FMR': {'bio': u'<KEY>'}, 'xmlcleanup': True, 'biometrics': ['FMR'], 'command': 'generate', 'analyze': True}) -> y

Debugging
---------

Extensive logging is supported by the library to help with easy application development. You can enable it by choosing appropriate python logging parameters. For example the logging commands in the sample client file can be replaced by: 

>        
>       logging.getLogger().setLevel(logging.DEBUG) 
>       logging.basicConfig(
> 	                    filename='execution.log', 
>                           format='%(asctime)-6s: %(name)s - %(levelname)s - %(message)s')
>    

Look at execution.log in the local directory once the command is executed. 

Documentation
-------------

Please see docs/apidocs/index.html

Work-in-progress    
----------------

  Immediate: 
  1. Integrate the commandline processing with help 
  2. Test with https connection (whenever it is available) 
  3. Performance evaluation/statistics    

  Medium term:  
  1. Language support 
  2. ASA/AUA split operation model 
  3. Use the objectified xml to populate internal state    
  4. Look through the spec for validation rules beyond what the    
     XSD is providing (e.g., sanity checks)    
  5. Explore browser and mobile phone support 

Thanks 
------   
{'fraction_non_alphanumeric': 0.14644157051033843, 'fraction_numerical': 0.02671726167428173, 'mean_word_length': 2.59221140472879, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 162, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 64}, 'pii_count': 0, 'substrings_counts': 22, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '30735', 'n_tokens_mistral': 4101, 'n_tokens_neox': 3746, 'n_words': 1191}