|
发表于 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);
}
} |
|