本文整理汇总了Java中net.jradius.packet.RadiusPacket.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java RadiusPacket.addAttribute方法的具体用法?Java RadiusPacket.addAttribute怎么用?Java RadiusPacket.addAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.jradius.packet.RadiusPacket
的用法示例。
在下文中一共展示了RadiusPacket.addAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRequest
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
if (password == null) throw new RadiusException("no password given");
p.removeAttribute(password);
RadiusAttribute attr;
byte authChallenge[] = RadiusRandom.getBytes(16);
byte chapResponse[] = MSCHAP.doMSCHAPv1(password.getValue().getBytes(), authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("MS-CHAP-Challenge"));
attr.setValue(authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("MS-CHAP-Response"));
attr.setValue(chapResponse);
}
示例2: processRequest
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
if (password == null) throw new RadiusException("no password given");
p.removeAttribute(password);
RadiusAttribute attr;
byte authChallenge[] = RadiusRandom.getBytes(16);
byte chapResponse[] = CHAP.chapResponse((byte)p.getIdentifier(), password.getValue().getBytes(), authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("CHAP-Challenge"));
attr.setValue(authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("CHAP-Password"));
attr.setValue(chapResponse);
}
示例3: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
JRadiusSession session = request.getSession();
if (session == null) return noSessionFound(request);
// System.err.println(this.getClass().getName());
RadiusPacket req = request.getRequestPacket();
byte[] packetClass = (byte[])req.getAttributeValue(Attr_Class.TYPE);
byte[][] sessionClass = session.getRadiusClass();
if (packetClass != null || sessionClass != null)
{
if (sessionClass == null)
{
session.addLogMessage(request, "Request has Class attribute when it should not");
}
else
{
session.addLogMessage(request, "Missing Class Attribute (added)");
req.removeAttribute(Attr_Class.TYPE);
for (byte[] a : sessionClass) {
req.addAttribute(AttributeFactory.newAttribute(Attr_Class.TYPE, a, req.isRecyclable()));
}
}
}
if (req instanceof AccessRequest)
{
byte[] sessionState = session.getRadiusState();
if (sessionState != null)
{
// System.out.println("Missing State Attribute (added) "+sessionState.length+" "+sessionState[0]);
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_State.TYPE, sessionState, req.isRecyclable()));
}
}
return false;
}
示例4: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
RadiusPacket req = request.getRequestPacket();
RadiusPacket rep = request.getReplyPacket();
AttributeList ci = request.getConfigItems();
String u = (String) req.getAttributeValue(Attr_UserName.TYPE);
String n = (String) req.getAttributeValue(Attr_NASIdentifier.TYPE);
if ((username != null && username.equals(u)) ||
(nasid != null && nasid.equals(n)))
{
if (request.getType() == JRadiusServer.JRADIUS_authorize)
{
// Reject the user (which should be fine for monitoring)
// and stop processing the current handler chain
RadiusLog.info("Answering monitoring request: {User-Name = " + username + ", NAS-Identifier = " + nasid + "}");
if (replyMessage != null)
{
rep.addAttribute(new Attr_ReplyMessage(replyMessage));
}
ci.add(new Attr_AuthType(Attr_AuthType.Reject));
}
return true;
}
return false;
}
示例5: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws RadiusException
{
JRadiusSession session = request.getSession();
if (session == null) return noSessionFound(request);
RadiusPacket req = request.getRequestPacket();
byte[] bClass = (byte[]) req.getAttributeValue(Attr_Class.TYPE);
if (bClass != null)
{
String sClass = new String(bClass);
if (sClass.startsWith(ClassPrefix))
{
req.removeAttribute(Attr_Class.TYPE);
byte[][] classes = session.getRadiusClass();
if (classes != null)
{
for (byte[] c : classes)
{
RadiusAttribute cattr = AttributeFactory.newAttribute(Attr_Class.TYPE, c, req.isRecyclable());
req.addAttribute(cattr);
}
}
return false;
}
}
session.addLogMessage(request, "Accounting without Class Attribute");
return false;
}
示例6: processRequest
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException
{
if (password == null) throw new RadiusException("no password given");
p.removeAttribute(password);
RadiusAttribute attr;
p.addAttribute(attr = AttributeFactory.newAttribute("User-Password"));
attr.setValue(RadiusUtils.encodePapPassword(
password.getValue().getBytes(),
// Create an authenticator (AccessRequest just needs shared secret)
p.createAuthenticator(null, 0, 0, client.getSharedSecret()),
client.getSharedSecret()));
}
示例7: processRequest
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
if (password == null) throw new RadiusException("Password required");
p.removeAttribute(password);
RadiusAttribute attr;
byte authChallenge[] = RadiusRandom.getBytes(16);
byte chapResponse[] = MSCHAP.doMSCHAPv2(username.getValue().getBytes(), password.getValue().getBytes(), authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("MS-CHAP-Challenge"));
attr.setValue(authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("MS-CHAP2-Response"));
attr.setValue(chapResponse);
}
示例8: processRequest
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException
{
p.addAttribute(AttributeFactory.newAttribute(AttributeDictionary.EAP_MESSAGE, readData(), p.isRecyclable()));
}
示例9: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
JRadiusSession session = (JRadiusSession) request.getSession();
if (session == null) return noSessionFound(request);
RadiusPacket req = request.getRequestPacket();
RadiusPacket rep = request.getReplyPacket();
AttributeList ci = request.getConfigItems();
String username = (String)req.getAttributeValue(Attr_UserName.TYPE);
if (request.getApplicationContext() == null)
{
RadiusLog.error(this.getClass().getName()+" can only run when configured with Spring");
return false;
}
WebServiceListener wsListener = (WebServiceListener)request.getApplicationContext().getBean(listenerBean);
if (wsListener == null) return false;
OTPProxyRequest otpRequest = (OTPProxyRequest)wsListener.get(username);
if (otpRequest == null) return false;
req.addAttribute(new Attr_JRadiusSessionId(session.getSessionKey()));
otpRequest.setAccessRequest((RadiusRequest)req);
RadiusResponse resp = otpRequest.getAccessResponse();
if (resp == null)
{
ci.add(new Attr_AuthType(Attr_AuthType.Reject));
request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT);
return true;
}
RadiusLog.debug(
"------------------------------------------------\n"+
"OTP Proxy Response:\n" + resp.toString()+
"------------------------------------------------\n");
if (resp instanceof AccessAccept)
{
AttributeList attrs = resp.getAttributes();
attrs.remove(Attr_Class.TYPE);
attrs.remove(Attr_State.TYPE);
attrs.remove(Attr_EAPMessage.TYPE);
attrs.remove(Attr_MessageAuthenticator.TYPE);
rep.addAttributes(attrs);
return false;
}
ci.add(new Attr_AuthType(Attr_AuthType.Reject));
request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT);
return true;
}