Examples of RadiusAttribute


Examples of org.tinyradius.attribute.RadiusAttribute

    StringBuffer s = new StringBuffer();
    s.append(getPacketTypeName());
    s.append(", ID ");
    s.append(packetIdentifier);
    for (Iterator i = attributes.iterator(); i.hasNext();) {
      RadiusAttribute attr = (RadiusAttribute)i.next();
      s.append("\n");
      s.append(attr.toString());
    }
    return s.toString();
  }
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

   * @see DefaultDictionary
   */
  public void setDictionary(Dictionary dictionary) {
    this.dictionary = dictionary;
    for (Iterator i = attributes.iterator(); i.hasNext();) {
      RadiusAttribute attr = (RadiusAttribute)i.next();
      attr.setDictionary(dictionary);
    }
  }
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

    // load attributes
    pos = 0;
    while (pos < attributeData.length) {
      int attributeType = attributeData[pos] & 0x0ff;
      int attributeLength = attributeData[pos + 1] & 0x0ff;
      RadiusAttribute a = RadiusAttribute.createRadiusAttribute(dictionary, -1, attributeType);
      a.readAttribute(attributeData, pos, attributeLength);
      rp.addAttribute(a);
      pos += attributeLength;
    }
   
    // request packet?
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

   */
  protected byte[] getAttributeBytes()
  throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream(MAX_PACKET_LENGTH);
    for (Iterator i = attributes.iterator(); i.hasNext();) {
      RadiusAttribute a = (RadiusAttribute)i.next();
      bos.write(a.writeAttribute());
    }
    bos.flush();
    return bos.toByteArray();
  }
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

  throws RadiusException {
    List attrs = getAttributes(USER_NAME);
    if (attrs.size() < 1 || attrs.size() > 1)
      throw new RuntimeException("exactly one User-Name attribute required");
   
    RadiusAttribute ra = (RadiusAttribute)attrs.get(0);
    return ((StringAttribute)ra).getAttributeValue();
  }
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

   * Retrieves the user name from the User-Name attribute.
   * @return user name
   */
  public int getAcctStatusType()
  throws RadiusException {
    RadiusAttribute ra = getAttribute(ACCT_STATUS_TYPE);
    if (ra == null)
      return -1;
    else
      return ((IntegerAttribute)ra).getAttributeValueInt();
  }
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

  public String getUserName() {
    List attrs = getAttributes(USER_NAME);
    if (attrs.size() < 1 || attrs.size() > 1)
      throw new RuntimeException("exactly one User-Name attribute required");
   
    RadiusAttribute ra = (RadiusAttribute)attrs.get(0);
    return ((StringAttribute)ra).getAttributeValue();
  }
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

   * @see org.tinyradius.packet.RadiusPacket#decodeRequestAttributes(java.lang.String)
   */
  protected void decodeRequestAttributes(String sharedSecret)
  throws RadiusException {
    // detect auth protocol
    RadiusAttribute userPassword = getAttribute(USER_PASSWORD);
    RadiusAttribute chapPassword = getAttribute(CHAP_PASSWORD);
    RadiusAttribute chapChallenge = getAttribute(CHAP_CHALLENGE);
   
    if (userPassword != null) {
      setAuthProtocol(AUTH_PAP);
      this.password = decodePapPassword(userPassword.getAttributeData(), RadiusUtil.getUtf8Bytes(sharedSecret));
      // copy truncated data
      userPassword.setAttributeData(RadiusUtil.getUtf8Bytes(this.password));
    } else if (chapPassword != null && chapChallenge != null) {
      setAuthProtocol(AUTH_CHAP);
      this.chapPassword = chapPassword.getAttributeData();
      this.chapChallenge = chapChallenge.getAttributeData();
    } else
      throw new RadiusException("Access-Request: User-Password or CHAP-Password/CHAP-Challenge missing");
  }
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

      //throw new RuntimeException("no password set");
   
    if (getAuthProtocol().equals(AUTH_PAP)) {
      byte[] pass = encodePapPassword(RadiusUtil.getUtf8Bytes(this.password), RadiusUtil.getUtf8Bytes(sharedSecret));
      removeAttributes(USER_PASSWORD);
      addAttribute(new RadiusAttribute(USER_PASSWORD, pass));
    } else if (getAuthProtocol().equals(AUTH_CHAP)) {
      byte[] challenge = createChapChallenge();
      byte[] pass = encodeChapPassword(password, challenge);
      removeAttributes(CHAP_PASSWORD);
      removeAttributes(CHAP_CHALLENGE);
      addAttribute(new RadiusAttribute(CHAP_PASSWORD, pass));
      addAttribute(new RadiusAttribute(CHAP_CHALLENGE, challenge));
    }
  }
View Full Code Here

Examples of org.tinyradius.attribute.RadiusAttribute

    throws IOException, RadiusException {
      // retrieve my Proxy-State attribute (the last)
      List proxyStates = packet.getAttributes(33);
      if (proxyStates == null || proxyStates.size() == 0)
        throw new RadiusException("proxy packet without Proxy-State attribute");
      RadiusAttribute proxyState = (RadiusAttribute)proxyStates.get(proxyStates.size() - 1);
     
      // retrieve proxy connection from cache
      String state = new String(proxyState.getAttributeData());
        RadiusProxyConnection proxyConnection = (RadiusProxyConnection)proxyConnections.remove(state);
      if (proxyConnection == null) {
        logger.warn("received packet on proxy port without saved proxy connection - duplicate?");
        return;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.