我在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)
答案 0 :(得分:1)
在使用JRadius库之前,应按如下方式加载JRadius字典。
AttributeFactory.loadAttributeDictionary("net.jradius.dictionary.AttributeDictionaryImpl");
另外,请确保已将JRadius Dictionary(jradius-dictionary-.jar)添加到类路径中。