Safran morpho指纹传感器与web java应用程序集成

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Safran morpho指纹传感器与web java应用程序集成相关的知识,希望对你有一定的参考价值。

我要求将Safron morpho指纹传感器与现有的Java Web应用程序集成。截至目前我只有safron morpho设备。请引导我启用并集成Web应用程序。

答案

这是你的解决方案。请按以下步骤操作:

  1. 下载这些文件。 https://www.dropbox.com/s/65ztgdzga0l110w/For_Testing.rar?dl=0
  2. 安装驱动程序,然后使用MorphoTestPage.html测试您的设备。
  3. 第一次复制HTML代码。
  4. 然后javascript
  5. 然后是servlet。
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.tomcat.util.codec.binary.Base64;

public class ThumbUpload extends HttpServlet {
   private String filePath;
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        filePath ="your directory path";
        DiskFileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
                PrintWriter out = response.getWriter();
        String htmlFiles = "";
        try {
            List<FileItem> items = upload.parseRequest(request);
            Iterator<FileItem> iter = items.iterator();
            FileItem item = (FileItem) iter.next();

            if (item.isFormField()) 
            {
                htmlFiles = item.getString();
            } 
        } catch (FileUploadException e) {

            System.out.println("Parsing file upload failed."+e);
        }


        FileOutputStream fos = null;
        try {
            byte[] contentData = htmlFiles.getBytes();
            byte[] decodedData = Base64.decodeBase64(contentData);
           String patientId = request.getParameter("patientId");
            String imgName = "Thumb_"+patientId+".png";
            fos = new FileOutputStream(filePath+imgName);
            fos.write(decodedData);
            out.println("Uploaded");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (fos != null) {
                fos.close();
            }
        }
    }
}

    <script>
                            var template;
function CallFingerAPI()
{
  var url = "https://localhost:8080/CallMorphoAPI";
  var xmlhttp;
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari

     xmlhttp=new XMLHttpRequest();
  
  }
  else
  {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }
     xmlhttp.onreadystatechange=function()
  {
     if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
	   fpobject = JSON.parse(xmlhttp.responseText);
           console.log(fpobject.Base64BMPIMage);
           
           // Call Servlet
           function uploadThumb(image){
      var formdata = image;         
      var  fr = new FormData();
      fr.append("data", formdata);
      var id = "<%=patientId%>";
      var url = "ThumbUpload?patientId="+id;
  var xmlhttp = new XMLHttpRequest();
  
                                 xmlhttp.onreadystatechange = function(){
                    if(xmlhttp.readyState === 4 && xmlhttp.status === 200){
                     var response = xmlhttp.responseText;
                        response = response.replace(/
?
|
/g, "");
                        response = response.trim();
                        if(response === "Uploaded"){
                           alert("Uploaded");
                        }
                        else{
                            alert("Error");
                            }
                            }

                            };
                            try{
                            xmlhttp.open("POST",url,true);
                            xmlhttp.send(fr);
                        }catch(e){alert("unable to connect to server");
                        }
           }
    uploadThumb(fpobject.Base64BMPIMage);
       template = fpobject.Base64ISOTemplate; 	    
       
           
     }
  }
  
  var timeout = 5;
  xmlhttp.open("POST",url+"?"+timeout,true);
  xmlhttp.send();

}
                    
                        </script>
                        
                        
                           <script>
<button type="button" class="special button" onclick="CallFingerAPI()">Capture Finger</button>

以上是关于Safran morpho指纹传感器与web java应用程序集成的主要内容,如果未能解决你的问题,请参考以下文章

屏下指纹传感器即将量产:iPhone又要变身?

关于ja3指纹处理

curl_cffi: 支持原生模拟浏览器 TLS/JA3 指纹的 Python 库

指纹识别怎么用

具有指纹认证的考勤应用程序

安卓指纹传感器API