Examples of RadiusPacket


Examples of net.jradius.packet.RadiusPacket

        final AccessRequest request = new AccessRequest(radiusClient,
            attributeList);

        try {
            final RadiusPacket response = radiusClient.authenticate(request,
                this.radiusAuthenticator, this.retries);

            // accepted
            if (response instanceof AccessAccept) {
                LOG.debug("Authentication request suceeded for host:"
View Full Code Here

Examples of net.sourceforge.jradiusclient.RadiusPacket

          boolean authenticated = false;
     
      try{
          log.info("Entering RADIUS Validation...");
         
          RadiusPacket accessRequest = new RadiusPacket(RadiusPacket.ACCESS_REQUEST);
          RadiusAttribute userNameAttribute;
         
          userNameAttribute = new RadiusAttribute(RadiusAttributeValues.USER_NAME, radUser.getBytes());
          accessRequest.setAttribute(userNameAttribute);
                 
          accessRequest.setAttribute(new RadiusAttribute(RadiusAttributeValues.USER_PASSWORD, radPass.getBytes()));
             
          RadiusPacket accessResponse = rc.authenticate(accessRequest);
          switch(accessResponse.getPacketType()){
              case RadiusPacket.ACCESS_ACCEPT:
                  log.debug("User " + radUser + " validated by RADIUS server");
                  setRADIUSAttributes(accessResponse);
                  authenticated = true;
                  break;
              case RadiusPacket.ACCESS_REJECT:
                  log.warn("User " + radUser + " NOT validated by RADIUS server");
                  authenticated = false;
                  break;
              case RadiusPacket.ACCESS_CHALLENGE:
                  String reply = new String(accessResponse.getAttribute(RadiusAttributeValues.REPLY_MESSAGE).getValue());
                  log.debug("User " + radUser + " Challenged with " + reply);
                  break;
              default:
                  log.warn("Whoa, what kind of RadiusPacket is this? - " + accessResponse.getPacketType());
                  break;
          }
                     
      }catch(InvalidParameterException ivpex){
          log.info("InvalidParameterException: " + ivpex.getMessage());
View Full Code Here

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

Examples of org.tinyradius.packet.RadiusPacket

  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

Examples of org.tinyradius.packet.RadiusPacket

  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

Examples of org.tinyradius.packet.RadiusPacket

        
         // 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

Examples of org.tinyradius.packet.RadiusPacket

     
      // 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

Examples of org.tinyradius.packet.RadiusPacket

    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

Examples of org.tinyradius.packet.RadiusPacket

    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

Examples of org.tinyradius.packet.RadiusPacket

   * @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
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.