Sunday 7 December 2014

Real Time Web Based Biometric/Fingerprint Authentication Part 1

Introduction

Good day guys. It's been a while. I've been pretty busy, took time out to assist the team developing one of our pet project. www.buyafrik.com. The project is an ecommerce magento app soon to be launched.


Today I am sharing a code snippet of registration, authentication of client/customer's profile online with JEE Technology and a java wrapper for native library.

This code snippet is based on secugen biometric device.  The sdk is free on request having a JNI wrapper for WIN etc. It simplifies the bottleneck of licensing.

The Part 2 will see support of generic biometric devices.

Usage
1. Secure web based application login for financial institutions, government offices, networked enviroments
2. One time web biometric registration, verification.
3. Auto time clocking


Technologies
JEE (JSF ***primefaces***, EJB/JPA)

Servlet Container (Apache Tomcat 7.0 and above).

Devices
Fingerprint Device (Secugen hamster, DigitaPersona etc).
SDKs (Verifinger from NIST,Vendor specific like Secugen or digitaPerson sdks).



Diagram


 Web Form (JSF Page)




    
<?java
public void WebTricsCapture() throws IOException {
        int[] quality = new int[1];        
        ServletContext servletContext =
            (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
        filename =
          servletContext.getRealPath("") + File.separator + "resources" + File.separator + "images" + File.separator +
          "fingerprints" + File.separator + "pe.getEnrolmentUid"+".gif";
        
        BufferedImage img1gray = new BufferedImage(deviceInfo.imageWidth,deviceInfo.imageHeight, BufferedImage.TYPE_BYTE_GRAY);
        byte[] imageBuffer1 = ((java.awt.image.DataBufferByte) img1gray.getRaster().getDataBuffer()).getData();
        this.deviceName = 255;
        this.devicePort = SGPPPortAddr.USB_AUTO_DETECT;
        fplib = new JSGFPLib();
        ret = fplib.Init(this.deviceName);
            ret = fplib.OpenDevice(devicePort);
       
        if (fplib != null)
        {
          //fplib.GetImageQuality(deviceInfo.imageWidth, deviceInfo.imageHeight, imageBuffer1, quality);
          //ret = fplib.GetImage(imageBuffer1); 
            ret = fplib.GetImageEx(imageBuffer1,pee.getImage_capture() * 1000,0, pee.getImage_quality());
            fplib.GetImageQuality(deviceInfo.imageWidth, deviceInfo.imageHeight, imageBuffer1, quality);
            
          
            if (ret == SGFDxErrorCode.SGFDX_ERROR_NONE)
            {
              
               
                FileImageOutputStream imageOutput;
                imageOutput = new FileImageOutputStream(new File(filename));
                imageOutput.write(imageBuffer1, 0, imageBuffer1.length);
                imageOutput.close();
                
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                ImageIO.write(img1gray, "png", os);
                img = new DefaultStreamedContent(new ByteArrayInputStream(os.toByteArray()), "image/png");
                long ret2 = fplib.GetImageQuality(150, 150, imageBuffer1, quality);
                addMessageInfo("Obtained Image successfully ["+ret+"]" +" Image Quality ["+quality[0]+ "]");
               }
            else
            {
                addMessageError("Could not Get Image "+ret);
                //this.jLabelStatus.setText("GetImageEx() Error [" + ret + "]");                                
            }
        } 
        else
        {
            addMessageError("JSGFPLib is not Initialized");
           // this.jLabelStatus.setText("JSGFPLib is not Initialized");
        }        
    }

A hybrid Android and IOS Mobile Chat app

Project :   Development of a simple extensible chat  Technologies and Frameworks Oracle Mobile Application Framework (MAF) Oracle Java ...