public class ReservationTokenAttribute extends Attribute
Modifier and Type | Field and Description |
---|---|
private int |
hashCode
A hashcode for hashtable storage.
|
static String |
NAME
Attribute name.
|
private static Random |
random
The object to use to generate the rightmost 8 bytes of the token.
|
private byte[] |
reservationToken
ReservationToken value.
|
ALTERNATE_SERVER, attributeType, CHANGE_REQUEST, CHANGED_ADDRESS, CHANNEL_NUMBER, CONNECTION_ID, DATA, DESTINATION_ADDRESS, DONT_FRAGMENT, ERROR_CODE, EVEN_PORT, FINGERPRINT, HEADER_LENGTH, ICE_CONTROLLED, ICE_CONTROLLING, LIFETIME, MAGIC_COOKIE, MAPPED_ADDRESS, MESSAGE_INTEGRITY, NONCE, PASSWORD, PRIORITY, REALM, REFLECTED_FROM, REMOTE_ADDRESS, REQUESTED_ADDRESS_FAMILY, REQUESTED_TRANSPORT, RESERVATION_TOKEN, RESPONSE_ADDRESS, SOFTWARE, SOURCE_ADDRESS, UNKNOWN_ATTRIBUTES, UNKNOWN_OPTIONAL_ATTRIBUTE, USE_CANDIDATE, USERNAME, XOR_MAPPED_ADDRESS, XOR_ONLY, XOR_PEER_ADDRESS, XOR_RELAYED_ADDRESS
Modifier | Constructor and Description |
---|---|
protected |
ReservationTokenAttribute()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static ReservationTokenAttribute |
createNewReservationTokenAttribute()
Creates a Reservation Token object.The Reservation Token itself is
generated using the following algorithm:
The first 6 bytes of the id are given the value of
System.currentTimeMillis().
|
(package private) void |
decodeAttributeBody(byte[] attributeValue,
char offset,
char length)
Copies the value of the reservationToken attribute from the specified
attributeValue.
|
byte[] |
encode()
Returns a binary representation of this attribute.
|
boolean |
equals(Object obj)
Compares two STUN Attributes.
|
private static void |
generateReservationTokenAttribute(ReservationTokenAttribute token,
int nb)
Generates a random ReservationTokenAttribute
|
char |
getDataLength()
Returns the length of this attribute's body.
|
String |
getName()
Returns the human readable name of this attribute.
|
byte[] |
getReservationToken()
Returns a (cloned) byte array containing the reservationToken value of
the reservationToken attribute.
|
int |
hashCode()
Returns the hash code of this Reservation-Token.
|
void |
setReservationToken(byte[] reservationToken)
Copies the specified binary array into the the reservationToken value of
the reservationToken attribute.
|
String |
toString()
Returns a string representation of the token.
|
static String |
toString(byte[] reservationToken)
Returns a string representation of the token.
|
getAttributeType, getLocationInMessage, setAttributeType, setLocationInMessage
public static final String NAME
private byte[] reservationToken
private int hashCode
private static final Random random
void decodeAttributeBody(byte[] attributeValue, char offset, char length) throws StunException
decodeAttributeBody
in class Attribute
attributeValue
- a binary array containing this attribute's
field values and NOT containing the attribute header.offset
- the position where attribute values begin (most often
offset is equal to the index of the first byte after length)length
- the length of the binary array.StunException
- if attributeValue contains invalid reservationToken.public byte[] encode()
public String getName()
public byte[] getReservationToken()
public void setReservationToken(byte[] reservationToken)
reservationToken
- the binary array containing the reservationToken.public char getDataLength()
getDataLength
in class Attribute
public static ReservationTokenAttribute createNewReservationTokenAttribute()
private static void generateReservationTokenAttribute(ReservationTokenAttribute token, int nb)
token
- ReservationTokenAttributenb
- number of bytes to generatepublic boolean equals(Object obj)
public String toString()
public static String toString(byte[] reservationToken)
reservationToken
- the Reservation Token to convert into
String.Copyright © 2018. All rights reserved.