我正在用Java中的this小示例来测试JRadius客户端。
但我不断收到此错误:

Exception in thread "main" net.sf.jradius.exception.UnknownAttributeException: Unknown attribute MS-CHAP-Challenge
at net.sf.jradius.packet.attribute.AttributeFactory.newAttribute(Unknown Source)
at net.sf.jradius.client.auth.MSCHAPv2Authenticator.processRequest(Unknown Source)
at net.sf.jradius.client.RadiusClient.authenticate(Unknown Source)
at lu.restena.zimbra.RestenaAuthenticator.main(RestenaAuthenticator.java:94)


我已经添加了所有罐子,并且也导入了。

我的代码:


        InetAddress remoteInetAddress = InetAddress.getByName(RADIUSname);
        RadiusClient radiusClient;
        radiusClient = new RadiusClient(
                remoteInetAddress,   // InetAddress - Address of remote RADIUS Server
                sharedSecret); // String - Shared Secret for remote RADIUS Server
        AttributeList attributeList;
        attributeList = new AttributeList();
        attributeList.add(new Attr_UserName(username));
        RadiusAuthenticator auth = RadiusClient.getAuthProtocol("mschapv2");
        RadiusPacket request;
        request = new AccessRequest(radiusClient, attributeList);
        request.addAttribute(new Attr_UserPassword(password));
        RadiusPacket reply = radiusClient.authenticate((AccessRequest) request, auth, 5);



错误发生在:

RadiusPacket reply = radiusClient.authenticate((AccessRequest) request, auth, 5);


有人知道为什么吗? (我是JRadius的新手)(MSCHAPv2Authenticator.java

最佳答案

在使用JRadius库之前,应按以下方式加载JRadius词典。

AttributeFactory.loadAttributeDictionary("net.jradius.dictionary.AttributeDictionaryImpl");


另外,请确保已将JRadius词典(jradius-dictionary-.jar)添加到类路径。

10-01 09:42