本文整理汇总了Java中net.jradius.packet.attribute.RadiusAttribute.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java RadiusAttribute.setValue方法的具体用法?Java RadiusAttribute.setValue怎么用?Java RadiusAttribute.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.jradius.packet.attribute.RadiusAttribute
的用法示例。
在下文中一共展示了RadiusAttribute.setValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRequest
import net.jradius.packet.attribute.RadiusAttribute; //导入方法依赖的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.attribute.RadiusAttribute; //导入方法依赖的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: verifyRequest
import net.jradius.packet.attribute.RadiusAttribute; //导入方法依赖的package包/类
public static Boolean verifyRequest(RadiusPacket request, String sharedSecret) throws IOException, InvalidKeyException, NoSuchAlgorithmException
{
byte[] hash = new byte[16];
ByteBuffer buffer = ByteBuffer.allocate(4096);
RadiusAttribute attr = request.findAttribute(AttributeDictionary.MESSAGE_AUTHENTICATOR);
if (attr == null) return null;
byte[] pval = attr.getValue().getBytes();
attr.setValue(hash);
format.packPacket(request, sharedSecret, buffer, true);
System.arraycopy(MD5.hmac_md5(buffer.array(), 0, buffer.position(), sharedSecret.getBytes()), 0, hash, 0, 16);
attr.setValue(pval);
return new Boolean(Arrays.equals(pval, hash));
}
示例4: processRequest
import net.jradius.packet.attribute.RadiusAttribute; //导入方法依赖的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()));
}
示例5: processRequest
import net.jradius.packet.attribute.RadiusAttribute; //导入方法依赖的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);
}
示例6: verifyReply
import net.jradius.packet.attribute.RadiusAttribute; //导入方法依赖的package包/类
public static Boolean verifyReply(byte[] requestAuth, RadiusPacket reply, String sharedSecret) throws IOException, InvalidKeyException, NoSuchAlgorithmException
{
byte[] replyAuth = reply.getAuthenticator();
byte[] hash = new byte[16];
ByteBuffer buffer = ByteBuffer.allocate(4096);
RadiusAttribute attr = reply.findAttribute(AttributeDictionary.MESSAGE_AUTHENTICATOR);
if (attr == null) return null;
byte[] pval = attr.getValue().getBytes();
attr.setValue(hash);
reply.setAuthenticator(requestAuth);
format.packPacket(reply, sharedSecret, buffer, true);
System.arraycopy(MD5.hmac_md5(buffer.array(), 0, buffer.position(), sharedSecret.getBytes()), 0, hash, 0, 16);
reply.setAuthenticator(replyAuth);
return new Boolean(Arrays.equals(pval, hash));
}