org.tinyradius.packet
Class AccessRequest

java.lang.Object
  extended by org.tinyradius.packet.RadiusPacket
      extended by org.tinyradius.packet.AccessRequest

public class AccessRequest
extends RadiusPacket

This class represents an Access-Request Radius packet.


Field Summary
static java.lang.String AUTH_CHAP
          Challenged Handshake Authentication Protocol
static java.lang.String AUTH_PAP
          Passphrase Authentication Protocol
 
Fields inherited from class org.tinyradius.packet.RadiusPacket
ACCESS_ACCEPT, ACCESS_CHALLENGE, ACCESS_REJECT, ACCESS_REQUEST, ACCOUNTING_MESSAGE, ACCOUNTING_REQUEST, ACCOUNTING_RESPONSE, ACCOUNTING_STATUS, COA_ACK, COA_NAK, COA_REQUEST, DISCONNECT_ACK, DISCONNECT_NAK, DISCONNECT_REQUEST, MAX_PACKET_LENGTH, PASSWORD_ACCEPT, PASSWORD_REJECT, PASSWORD_REQUEST, RADIUS_HEADER_LENGTH, RESERVED, STATUS_ACCEPT, STATUS_CLIENT, STATUS_REJECT, STATUS_REQUEST, STATUS_SERVER
 
Constructor Summary
AccessRequest()
          Constructs an empty Access-Request packet.
AccessRequest(java.lang.String userName, java.lang.String userPassword)
          Constructs an Access-Request packet, sets the code, identifier and adds an User-Name and an User-Password attribute (PAP).
 
Method Summary
protected  void decodeRequestAttributes(java.lang.String sharedSecret)
          Decrypts the User-Password attribute.
protected  void encodeRequestAttributes(java.lang.String sharedSecret)
          Sets and encrypts the User-Password attribute.
 java.lang.String getAuthProtocol()
          Returns the protocol used for encrypting the passphrase.
 java.lang.String getUserName()
          Retrieves the user name from the User-Name attribute.
 java.lang.String getUserPassword()
          Retrieves the plain-text user password.
 void setAuthProtocol(java.lang.String authProtocol)
          Selects the protocol to use for encrypting the passphrase when encoding this Radius packet.
 void setUserName(java.lang.String userName)
          Sets the User-Name attribute of this Access-Request.
 void setUserPassword(java.lang.String userPassword)
          Sets the plain-text user password.
 boolean verifyPassword(java.lang.String plaintext)
          Verifies that the passed plain-text password matches the password (hash) send with this Access-Request packet.
 
Methods inherited from class org.tinyradius.packet.RadiusPacket
addAttribute, addAttribute, checkResponseAuthenticator, createRadiusPacket, createRequestAuthenticator, createResponseAuthenticator, decodePacket, decodeRequestPacket, decodeRequestPacket, decodeResponsePacket, decodeResponsePacket, encodePacket, encodeRequestPacket, encodeResponsePacket, getAttribute, getAttribute, getAttribute, getAttributeBytes, getAttributes, getAttributes, getAttributes, getAttributeValue, getAuthenticator, getDictionary, getMd5Digest, getNextPacketIdentifier, getPacketIdentifier, getPacketType, getPacketTypeName, getVendorAttribute, getVendorAttributes, removeAttribute, removeAttributes, removeAttributes, removeLastAttribute, setAttributes, setAuthenticator, setDictionary, setPacketIdentifier, setPacketType, toString, updateRequestAuthenticator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AUTH_PAP

public static final java.lang.String AUTH_PAP
Passphrase Authentication Protocol

See Also:
Constant Field Values

AUTH_CHAP

public static final java.lang.String AUTH_CHAP
Challenged Handshake Authentication Protocol

See Also:
Constant Field Values
Constructor Detail

AccessRequest

public AccessRequest()
Constructs an empty Access-Request packet.


AccessRequest

public AccessRequest(java.lang.String userName,
                     java.lang.String userPassword)
Constructs an Access-Request packet, sets the code, identifier and adds an User-Name and an User-Password attribute (PAP).

Parameters:
userName - user name
userPassword - user password
Method Detail

setUserName

public void setUserName(java.lang.String userName)
Sets the User-Name attribute of this Access-Request.

Parameters:
userName - user name to set

setUserPassword

public void setUserPassword(java.lang.String userPassword)
Sets the plain-text user password.

Parameters:
userPassword - user password to set

getUserPassword

public java.lang.String getUserPassword()
Retrieves the plain-text user password. Returns null for CHAP - use verifyPassword().

Returns:
user password
See Also:
verifyPassword(String)

getUserName

public java.lang.String getUserName()
Retrieves the user name from the User-Name attribute.

Returns:
user name

getAuthProtocol

public java.lang.String getAuthProtocol()
Returns the protocol used for encrypting the passphrase.

Returns:
AUTH_PAP or AUTH_CHAP

setAuthProtocol

public void setAuthProtocol(java.lang.String authProtocol)
Selects the protocol to use for encrypting the passphrase when encoding this Radius packet.

Parameters:
authProtocol - AUTH_PAP or AUTH_CHAP

verifyPassword

public boolean verifyPassword(java.lang.String plaintext)
                       throws RadiusException
Verifies that the passed plain-text password matches the password (hash) send with this Access-Request packet. Works with both PAP and CHAP.

Parameters:
plaintext -
Returns:
true if the password is valid, false otherwise
Throws:
RadiusException

decodeRequestAttributes

protected void decodeRequestAttributes(java.lang.String sharedSecret)
                                throws RadiusException
Decrypts the User-Password attribute.

Overrides:
decodeRequestAttributes in class RadiusPacket
Throws:
RadiusException
See Also:
RadiusPacket.decodeRequestAttributes(java.lang.String)

encodeRequestAttributes

protected void encodeRequestAttributes(java.lang.String sharedSecret)
Sets and encrypts the User-Password attribute.

Overrides:
encodeRequestAttributes in class RadiusPacket
See Also:
RadiusPacket.encodeRequestAttributes(java.lang.String)