Class AccessRequest
java.lang.Object
org.tinyradius.core.packet.BaseRadiusPacket<RadiusRequest>
org.tinyradius.core.packet.request.GenericRequest
org.tinyradius.core.packet.request.AccessRequest
- All Implemented Interfaces:
AttributeHolder<RadiusRequest>
,NestedAttributeHolder<RadiusRequest>
,RadiusPacket<RadiusRequest>
,RadiusRequest
,MessageAuthSupport<RadiusRequest>
- Direct Known Subclasses:
AccessRequestArap
,AccessRequestChap
,AccessRequestEap
,AccessRequestNoAuth
,AccessRequestPap
public abstract class AccessRequest
extends GenericRequest
implements MessageAuthSupport<RadiusRequest>
This class represents an Access-Request Radius packet.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
protected static final int
protected static final int
protected static final org.apache.logging.log4j.Logger
protected static final SecureRandom
protected static final int
Fields inherited from interface org.tinyradius.core.attribute.AttributeHolder
attrHolderLogger
Fields inherited from interface org.tinyradius.core.packet.util.MessageAuthSupport
MESSAGE_AUTHENTICATOR, msgAuthLogger
Fields inherited from interface org.tinyradius.core.packet.RadiusPacket
HEADER_LENGTH, MAX_PACKET_LENGTH
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AccessRequest
(Dictionary dictionary, io.netty.buffer.ByteBuf header, List<RadiusAttribute> attributes) -
Method Summary
Modifier and TypeMethodDescriptiondecodeRequest
(String sharedSecret) Decodes the request against the supplied shared secret.encodeRequest
(String sharedSecret) AccessRequest overrides this method to generate a randomized authenticator (RFC 2865) and encode required attributes (e.g.protected byte[]
protected static byte[]
withAttributes
(List<RadiusAttribute> attributes) withAuthAttributes
(byte[] auth, List<RadiusAttribute> attributes) withChapPassword
(String password) Set CHAP-Password attribute with provided password and initializes CHAP-Challenge with random bytes.withPapPassword
(String password) Set User-Password attribute with provided password.Methods inherited from class org.tinyradius.core.packet.request.GenericRequest
with
Methods inherited from class org.tinyradius.core.packet.BaseRadiusPacket
equals, getAttributes, getAuthenticator, getChildVendorId, getDictionary, getHeader, getId, getType, hashCode, toString, verifyPacketAuth
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.tinyradius.core.attribute.AttributeHolder
addAttribute, addAttribute, decodeAttributes, encodeAttributes, filterAttributes, filterAttributes, filterAttributes, getAttribute, getAttribute, getAttributeByteBuf, getAttributes, getChildVendorId, getDictionary, removeAttributes, removeLastAttribute
Methods inherited from interface org.tinyradius.core.packet.util.MessageAuthSupport
computeMessageAuth, encodeMessageAuth, verifyMessageAuth
Methods inherited from interface org.tinyradius.core.attribute.NestedAttributeHolder
addAttribute, filterAttributes, filterAttributes, getAttribute, getFlattenedAttributes, getVendorAttributes, removeAttribute, removeAttributes
Methods inherited from interface org.tinyradius.core.packet.RadiusPacket
genHashedAuth, getAuthenticator, getHeader, getId, getLength, getType, toByteBuf, toByteBuffer, toBytes
-
Field Details
-
logger
protected static final org.apache.logging.log4j.Logger logger -
RANDOM
-
USER_PASSWORD
protected static final int USER_PASSWORD- See Also:
-
CHAP_PASSWORD
protected static final int CHAP_PASSWORD- See Also:
-
EAP_MESSAGE
protected static final int EAP_MESSAGE- See Also:
-
ARAP_PASSWORD
protected static final int ARAP_PASSWORD- See Also:
-
-
Constructor Details
-
AccessRequest
protected AccessRequest(Dictionary dictionary, io.netty.buffer.ByteBuf header, List<RadiusAttribute> attributes) throws RadiusPacketException - Throws:
RadiusPacketException
-
-
Method Details
-
random16bytes
protected static byte[] random16bytes() -
genAuth
- Overrides:
genAuth
in classGenericRequest
- Parameters:
sharedSecret
- to generate authenticator- Returns:
- new authenticator, must be idempotent
-
withChapPassword
Set CHAP-Password attribute with provided password and initializes CHAP-Challenge with random bytes.Removes existing auth-related attributes if present (User-Password, CHAP-Password etc).
- Parameters:
password
- plaintext password to encode into CHAP-Password- Returns:
- AccessRequestChap with encoded CHAP-Password and CHAP-Challenge attributes
- Throws:
IllegalArgumentException
- invalid passwordRadiusPacketException
- packet validation exceptions
-
withPapPassword
Set User-Password attribute with provided password.Removes existing auth-related attributes if present (User-Password, CHAP-Password etc).
- Parameters:
password
- plaintext password to encode into User-Password- Returns:
- AccessRequestPap with encoded User-Password attribute
- Throws:
RadiusPacketException
- packet validation exceptions
-
encodeRequest
AccessRequest overrides this method to generate a randomized authenticator (RFC 2865) and encode required attributes (e.g. User-Password).- Specified by:
encodeRequest
in interfaceRadiusRequest
- Overrides:
encodeRequest
in classGenericRequest
- Parameters:
sharedSecret
- shared secret that secures the communication with the other Radius server/client- Returns:
- RadiusPacket with new authenticator and encoded attributes
- Throws:
RadiusPacketException
- if invalid or missing attributes
-
decodeRequest
Description copied from interface:RadiusRequest
Decodes the request against the supplied shared secret.Must be idempotent.
- Specified by:
decodeRequest
in interfaceRadiusRequest
- Overrides:
decodeRequest
in classGenericRequest
- Parameters:
sharedSecret
- shared secret- Returns:
- verified RadiusRequest with decoded attributes if appropriate
- Throws:
RadiusPacketException
- if authenticator check fails
-
withAttributes
- Specified by:
withAttributes
in interfaceAttributeHolder<RadiusRequest>
- Overrides:
withAttributes
in classBaseRadiusPacket<RadiusRequest>
- Throws:
RadiusPacketException
-
withAuthAttributes
public AccessRequest withAuthAttributes(byte[] auth, List<RadiusAttribute> attributes) throws RadiusPacketException - Overrides:
withAuthAttributes
in classBaseRadiusPacket<RadiusRequest>
- Throws:
RadiusPacketException
-