Package org.tinyradius.packet

Examples of org.tinyradius.packet.RadiusPacket


   * retries)
   */
  public synchronized boolean authenticate(String userName, String password)
  throws IOException, RadiusException {
    AccessRequest request = new AccessRequest(userName, password);
    RadiusPacket response = authenticate(request);
    return response.getPacketType() == RadiusPacket.ACCESS_ACCEPT;
  }
View Full Code Here


  public synchronized RadiusPacket authenticate(AccessRequest request)
  throws IOException, RadiusException {
    if (logger.isInfoEnabled())
      logger.info("send Access-Request packet: " + request);
   
    RadiusPacket response = communicate(request, getAuthPort());
    if (logger.isInfoEnabled())
      logger.info("received packet: " + response);
   
    return response;
  }
View Full Code Here

  public synchronized RadiusPacket account(AccountingRequest request)
  throws IOException, RadiusException {
    if (logger.isInfoEnabled())
      logger.info("send Accounting-Request packet: " + request);
   
    RadiusPacket response = communicate(request, getAcctPort());
    if (logger.isInfoEnabled())
      logger.info("received packet: " + response);
   
    return response;
  }
View Full Code Here

        
         // remove only own Proxy-State (last attribute)
         packet.removeLastAttribute(33);

         // re-encode answer packet with authenticator of the original packet
         RadiusPacket answer = new RadiusPacket(packet.getPacketType(), packet.getPacketIdentifier(), packet.getAttributes());
         DatagramPacket datagram = makeDatagramPacket(answer, client.getSharedSecret(), client.getEndpointAddress().getAddress(), client.getEndpointAddress().getPort(), proxyConnection.getPacket());       
       
         // send back using correct socket
         DatagramSocket socket;
         if (proxyConnection.getPort() == getAuthPort())
View Full Code Here

     
      // Adds an attribute to the Access-Accept packet
      public RadiusPacket accessRequestReceived(AccessRequest accessRequest, InetSocketAddress client)
      throws RadiusException {
        System.out.println("Received Access-Request:\n" + accessRequest);
        RadiusPacket packet = super.accessRequestReceived(accessRequest, client);
        if (packet.getPacketType() == RadiusPacket.ACCESS_ACCEPT)
          packet.addAttribute("Reply-Message", "Welcome " + accessRequest.getUserName() + "!");
        if (packet == null)
          System.out.println("Ignore packet.");
        else
          System.out.println("Answer:\n" + packet);
        return packet;
View Full Code Here

    ar.addAttribute("Service-Type", "Login-User");
    ar.addAttribute("WISPr-Redirection-URL", "http://www.sourceforge.net/");
    ar.addAttribute("WISPr-Location-ID", "net.sourceforge.ap1");
   
    System.out.println("Packet before it is sent\n" + ar + "\n");
    RadiusPacket response = rc.authenticate(ar);
    System.out.println("Packet after it was sent\n" + ar + "\n");
    System.out.println("Response\n" + response + "\n");

    // 2. Send Accounting-Request
    AccountingRequest acc = new AccountingRequest("mw", AccountingRequest.ACCT_STATUS_TYPE_START);
View Full Code Here

    String plaintext = getUserPassword(accessRequest.getUserName());
    int type = RadiusPacket.ACCESS_REJECT;
    if (plaintext != null && accessRequest.verifyPassword(plaintext))
      type = RadiusPacket.ACCESS_ACCEPT;
   
    RadiusPacket answer = new RadiusPacket(type, accessRequest.getPacketIdentifier());
    copyProxyState(accessRequest, answer);
    return answer;
  }
View Full Code Here

   * @exception RadiusException malformed request packet; if this
   * exception is thrown, no answer will be sent
   */
  public RadiusPacket accountingRequestReceived(AccountingRequest accountingRequest, InetSocketAddress client)
  throws RadiusException {
    RadiusPacket answer = new RadiusPacket(RadiusPacket.ACCOUNTING_RESPONSE, accountingRequest.getPacketIdentifier());
    copyProxyState(accountingRequest, answer);
    return answer;
  }
View Full Code Here

            logger.info("ignoring packet from unknown client " + remoteAddress + " received on local address " + localAddress);
          continue;
        }
       
        // parse packet
        RadiusPacket request = makeRadiusPacket(packetIn, secret);
        if (logger.isInfoEnabled())
          logger.info("received packet from " + remoteAddress + " on local address " + localAddress + ": " + request);

        // handle packet
        logger.trace("about to call RadiusServer.handlePacket()");
        RadiusPacket response = handlePacket(localAddress, remoteAddress, request, secret);
       
        // send response
        if (response != null) {
          if (logger.isInfoEnabled())
            logger.info("send response: " + response);
View Full Code Here

   * @return response packet or null for no response
   * @throws RadiusException
   */
  protected RadiusPacket handlePacket(InetSocketAddress localAddress, InetSocketAddress remoteAddress, RadiusPacket request, String sharedSecret)
  throws RadiusException, IOException {
    RadiusPacket response = null;
   
    // check for duplicates
    if (!isPacketDuplicate(request, remoteAddress)) {
      if (localAddress.getPort() == getAuthPort()) {
        // handle packets on auth port
View Full Code Here

TOP

Related Classes of org.tinyradius.packet.RadiusPacket

Copyright © 2018 www.massapicom. 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.