U.ARE.U4000B指印仪,ZKOnline SDK,java服务器端指纹特征码验证
U.ARE.U4000B指纹仪,ZKOnline SDK,java服务器端指纹特征码验证
前段时间的一个web项目搞了个指纹登陆,用的是中控的Biokey 开发工具,安装控件驱动神马的, 就不多说了,zkonline的SDK里都有,由于指纹需要在服务器端做比对,但SDK里只提供了DLL库的方式来解决比对问题,所以需要让java调用DLL库。。。在网上找到JNative这个东东来调用DLL里的方法。下面大概说一下实现的过程
1、下载JNative,我下的是JNative-1.3.2 这个包,解压后,包括JNative.jar,JNativeCpp.dll,libJNativeCpp.so三个文件(“libJNativeCpp.so”ms是在linux下用的,没有仔细关注)。
2、将JNative.jar放在工程的lib下,有的文章说要放在jdk的安装目录下,但我试了没有成功,在工程的lib下是成功的。后来为了保险,在JDK安装目录的\jre\lib\ext下也放了一份。
3、将 JNativeCpp.dll 放到tomcat安装目录的\bin 路径下 这个tomcat的版本不同,路径有所不同,我的是tomcat5
4、将 ZKonlineSDK (BS)中的 Match.dll 放到tomcat安装目录的\bin 路径下,(与 JNativeCpp.dll 在同一目录)
5、以上准备工作完成之后,就是编码了。
接下来是isVerFinger方法的调用
END
ps:初次写此类文章,如果不对之处,还希望多多批评指正,谢谢。
前段时间的一个web项目搞了个指纹登陆,用的是中控的Biokey 开发工具,安装控件驱动神马的, 就不多说了,zkonline的SDK里都有,由于指纹需要在服务器端做比对,但SDK里只提供了DLL库的方式来解决比对问题,所以需要让java调用DLL库。。。在网上找到JNative这个东东来调用DLL里的方法。下面大概说一下实现的过程
1、下载JNative,我下的是JNative-1.3.2 这个包,解压后,包括JNative.jar,JNativeCpp.dll,libJNativeCpp.so三个文件(“libJNativeCpp.so”ms是在linux下用的,没有仔细关注)。
2、将JNative.jar放在工程的lib下,有的文章说要放在jdk的安装目录下,但我试了没有成功,在工程的lib下是成功的。后来为了保险,在JDK安装目录的\jre\lib\ext下也放了一份。
3、将 JNativeCpp.dll 放到tomcat安装目录的\bin 路径下 这个tomcat的版本不同,路径有所不同,我的是tomcat5
4、将 ZKonlineSDK (BS)中的 Match.dll 放到tomcat安装目录的\bin 路径下,(与 JNativeCpp.dll 在同一目录)
5、以上准备工作完成之后,就是编码了。
import org.xvolks.jnative.JNative; import org.xvolks.jnative.exceptions.NativeException; import org.xvolks.jnative.pointers.Pointer; import org.xvolks.jnative.pointers.memory.MemoryBlockFactory; import org.xvolks.jnative.Type; public class VerFinger { //regFingertpl 为数据库中保存的指纹特征码 //verFingertpl 为需要被比对的指纹特征码 public String isVerFinger(String regFingertpl, String verFingertpl) throws NativeException, IllegalAccessException{ JNative jna = null; try{ if(jna == null){ jna = new JNative("Match.dll","Process");//调用Mathc中的Process方法 jna.setRetVal(Type.INT); } jna.setParameter(0,Type.STRING,regFingertpl);//设置Process方法中的第一个参数 jna.setParameter(1,Type.STRING,verFingertpl);//设置Process方法中的第二个参数 jna.invoke(); String val = jna.getRetVal();//获取Process方法的返回值 return val; } finally{ if(jna!=null){ jna.dispose(); } } } }
接下来是isVerFinger方法的调用
String regFingertpl = udao.getUserFinger(userName); String verFingertpl = request.getParameter("fingertpl"); VerFinger vf = new VerFinger(); String is=""; try { is = vf.isVerFinger(regFingertpl, verFingertpl); } catch (NativeException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(is.equals("65535")){//当返回值为“65535”时,指纹特征码对比成功 finger = "1"; ableLogin = "1"; } else if(is.equals("0"))")){//当返回值为“0”时,指纹特征码对比失败 { finger = "0"; ableLogin = "0"; }
END
ps:初次写此类文章,如果不对之处,还希望多多批评指正,谢谢。
1 楼
vondon
2011-04-14
您好。在使用您写的这段代码时候会遇到这种情况。不知道您那是如何解决的。
能不能给我发送一下match.dll动态库。
vondonster@gmail.com
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c95a5e4, pid=2628, tid=5856
#
# JRE version: 6.0_20-b02
# Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x2a5e4]
#
# An error report file with more information is saved as:
# D:\Workspaces\MyEclipse85\uautest\hs_err_pid2628.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
能不能给我发送一下match.dll动态库。
vondonster@gmail.com
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c95a5e4, pid=2628, tid=5856
#
# JRE version: 6.0_20-b02
# Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x2a5e4]
#
# An error report file with more information is saved as:
# D:\Workspaces\MyEclipse85\uautest\hs_err_pid2628.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#