起步软件技术论坛-X3

 找回密码
 立即注册
搜索
楼主: alang

[分享]平台外验证用户的密码

[复制链接]
发表于 2008-6-13 14:50:53 | 显示全部楼层
还是出现这样的错误:
java.lang.UnsatisfiedLinkError: IsValidPassword
        at com.san.dragon.pm.service.CallDll.IsValidPassword(Native Method)
        at com.san.dragon.pm.service.LoginServiceImpl.isAUser(LoginServiceImpl.java:32)
        at com.san.dragon.pm.service.LoginServiceImpl$$FastClassByCGLIB$$280c58d6.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
        at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:698)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
        at com.san.dragon.pm.service.LoginServiceImpl$$EnhancerByCGLIB$$ef2b733.isAUser(<generated>)
        at com.san.dragon.pm.junit.TestLogin.testGetUser(TestLogin.java:20)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
回复 支持 反对

使用道具 举报

发表于 2008-6-13 15:17:01 | 显示全部楼层
调用dll的源码:

package com.san.dragon.pm.service;

public class CallDll {
    static {
        System.loadLibrary("libPassChk");
    }
    public native boolean IsValidPassword(String APass, String AEncodedPass);
}


调用上面的类:

package com.san.dragon.pm.service;


import com.san.dragon.pm.dao.LoginDao;

public class LoginServiceImpl implements LoginService {

        private LoginDao loginDao;

       
        public LoginDao getLoginDao() {
                return loginDao;
        }

        public void setLoginDao(LoginDao loginDao) {
                this.loginDao = loginDao;
        }

        public boolean isAUser(String password,String userName) {
                // TODO Auto-generated method stub
                CallDll cdll = new CallDll();
                String get_password ="";
               
        if (!userName.equals("")){
                get_password =  loginDao.getPassword(userName);
           
        }else {
                return false;
        }
               

            if (cdll.IsValidPassword(password,get_password)){
                         return true;
                 }else {
                     return false;
                }
               
               
        }
       


       
       

}


测试类:


package com.san.dragon.pm.junit;

import test.com.san.model.Jobs;
import test.com.san.service.TestServiceImpl;
import junit.framework.TestCase;

import com.san.core.spring.config.AppBeanFactory;

import com.san.dragon.pm.service.LoginServiceImpl;

public class TestLogin extends TestCase {
       
        public void testGetUser(){
               

               
                LoginServiceImpl service=(LoginServiceImpl)AppBeanFactory.getBean("loginServiceImpl");
                long beginTime=System.currentTimeMillis();
                System.out.println(System.getProperty("java.library.path") );
                if (service.isAUser("SHENJIPENG","DISPLAYNAME")){
                         System.out.println("login ok");
                }else {
                       
                         System.out.println("can't login");
                }
       
                System.out.println((System.currentTimeMillis()-beginTime)/1000);
        }
       
}
回复 支持 反对

使用道具 举报

发表于 2008-6-13 15:43:35 | 显示全部楼层
可以了!谢谢!
回复 支持 反对

使用道具 举报

发表于 2008-7-23 10:20:09 | 显示全部楼层
老大 5楼的示例有错误哈
public static extern Boolean IsValidPasswordForCsharp(String APass, String APassEncoded);
应该是
public static extern Boolean IsValidPassword(String APass, String APassEncoded);
回复 支持 反对

使用道具 举报

发表于 2008-11-18 14:48:03 | 显示全部楼层
javah 编译头文件使用JDK版本是多少
回复 支持 反对

使用道具 举报

发表于 2008-11-18 16:06:07 | 显示全部楼层
java.lang.NoClassDefFoundError是怎么回事
回复 支持 反对

使用道具 举报

发表于 2008-11-18 16:17:11 | 显示全部楼层
jdk的版本最好用1.5
java.lang.NoClassDefFoundError说明在指定的路径中没有发现用到的这个类。
回复 支持 反对

使用道具 举报

发表于 2008-11-18 16:17:32 | 显示全部楼层
java.lang.UnsatisfiedLinkError: IsValidPassword
怎么找不到方法
回复 支持 反对

使用道具 举报

发表于 2008-11-18 16:29:13 | 显示全部楼层
java.lang.UnsatisfiedLinkError: IsValidPassword
怎么会报这个错呢
回复 支持 反对

使用道具 举报

发表于 2008-11-18 16:46:04 | 显示全部楼层
怎么没人回应呢
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-4-20 18:59 , Processed in 0.044707 second(s), 13 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表