/** * The values of valueOffset and valueLength are only used by some value types, for others * they are will always be the same or meaningless. * @param buffer * @param valueOffset * @param valueLength */ public void getBytes(ByteBuffer buffer, int valueOffset, int valueLength) { getBytes(buffer); }
protected byte[] getStateAttribute() { return stateAttribute == null ? null : stateAttribute.getValue().getBytes(); } }
/** * @return Returns the username. */ protected byte[] getUsername() { return username == null ? null : username.getValue().getBytes(); }
/** * @return Returns the password. */ protected byte[] getPassword() { if (password != null) return password.getValue().getBytes(); return "".getBytes(); }
protected byte[] getStateAttribute() { return stateAttribute == null ? null : stateAttribute.getValue().getBytes(); } }
/** * @return Returns the username. */ protected byte[] getUsername() { return username == null ? null : username.getValue().getBytes(); }
protected byte[] getClassAttribute() { return classAttribute == null ? null : classAttribute.getValue().getBytes(); }
/** * @return Returns the password. */ protected byte[] getPassword() { if (password != null) return password.getValue().getBytes(); return "".getBytes(); }
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)); }
public void packAttribute(ByteBuffer buffer, RadiusAttribute a) { AttributeValue attributeValue = a.getValue(); int length = attributeValue.getLength(); int padding = ((length + 0x03) & ~(0x03)) - length; packHeader(buffer, a); attributeValue.getBytes(buffer); while (padding-- > 0) putUnsignedByte(buffer, 0); }
@Override public void packAttribute(ByteBuffer buffer, RadiusAttribute a) { AttributeValue attributeValue = a.getValue(); putUnsignedByte(buffer, (int) a.getType()); putUnsignedByte(buffer, attributeValue.getLength() + 2); attributeValue.getBytes(buffer); } }
@Override public void packAttribute(ByteBuffer buffer, RadiusAttribute a) { AttributeValue attributeValue = a.getValue(); putUnsignedByte(buffer, (int) a.getType()); putUnsignedByte(buffer, attributeValue.getLength() + 2); attributeValue.getBytes(buffer); } }
public void packAttribute(OutputStream out, VSAttribute a) throws IOException { AttributeValue attributeValue = a.getValue(); writeUnsignedByte(out, (int)a.getVsaAttributeType()); writeUnsignedByte(out, attributeValue.getLength()); attributeValue.getBytes(out); }
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); } }
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); } }
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())); }
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())); }
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); } }
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); }
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); }