TinyRadius客户端java登录认证

jar包:TinyRadius-1.0.jar

依赖:commons-logging.jar

radius配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<SYSTEM>
<RADIUS>
<ENABLE>true</ENABLE><!-- true:启用radius进行登陆验证;false:不启用;默认不启用 -->
<PARAM><!-- 可配置多个连接参数节点 -->
<HOST>127.0.0.1</HOST><!-- radius服务器地址 -->
<SHAREDSECRET>testing123</SHAREDSECRET><!-- radius服务器sharedSecret -->
</PARAM>
</RADIUS>
</SYSTEM>

 

java认证:

public static void main(String[] args) {

       String host = "127.0.0.1";
       String shared = "testing";
       String user = "username";
       String pass = "password";

       RadiusClient rc = new RadiusClient(host, shared);
       try {
         if(rc.authenticate(user, pass)){
            system.out("radius登录认证通过!");
         } else {
            system.out("radius登录认证不通过!");
         };
       }  catch (IOException e) {
           e.printStackTrace();
       } catch (RadiusException e) {
           e.printStackTrace();
       }

   rc.close();
}                 

 

 

 

 

详见:http://blog.sina.com.cn/s/blog_b7836e390102v2bb.html

posted @ 2020-10-26 11:01  bud  阅读(788)  评论(0编辑  收藏  举报