-
- All Implemented Interfaces:
public class MessageFactoryThis class provides factory methods to allow an application to create STUN and TURN messages from a particular implementation.
-
-
Method Summary
Modifier and Type Method Description static RequestcreateBindingRequest()Creates a default binding request. static RequestcreateBindingRequest(long priority)Creates a default binding request. static RequestcreateBindingRequest(long priority, boolean controlling, long tieBreaker)Creates a default binding request. static Responsecreate3489BindingResponse(TransportAddress mappedAddress, TransportAddress sourceAddress, TransportAddress changedAddress)Creates a BindingResponse in a 3489 compliant manner, assigning the specified values to mandatory headers. static ResponsecreateBindingResponse(Request request, TransportAddress mappedAddress)Creates a BindingResponse in a 5389 compliant manner containing a single XOR-MAPPED-ADDRESS attribute static ResponsecreateBindingErrorResponse(char errorCode, String reasonPhrase, Array<char> unknownAttributes)Creates a binding error response according to the specified error code and unknown attributes. static ResponsecreateBindingErrorResponseUnknownAttributes(Array<char> unknownAttributes)Creates a binding error response with UNKNOWN_ATTRIBUTES error code and the specified unknown attributes. static ResponsecreateBindingErrorResponseUnknownAttributes(String reasonPhrase, Array<char> unknownAttributes)Creates a binding error response with UNKNOWN_ATTRIBUTES error code and the specified unknown attributes and reason phrase. static ResponsecreateBindingErrorResponse(char errorCode, String reasonPhrase)Creates a binding error response with an ERROR-CODE attribute. static ResponsecreateBindingErrorResponse(char errorCode)Creates a binding error response according to the specified error code. static IndicationcreateBindingIndication()Creates a default binding indication. static RequestcreateAllocateRequest()Create an allocate request without attribute. static RequestcreateAllocateRequest(byte protocol, boolean rFlag)Create an allocate request to allocate an even port. static ResponsecreateAllocationResponse(Request request, TransportAddress mappedAddress, TransportAddress relayedAddress, int lifetime)Creates a AllocationResponse in a 5389 compliant manner containing at most 4 attributes XOR-RELAYED-ADDRESS attribute LIFETIME attribute XOR-MAPPED-ADDRESS attribute static ResponsecreateAllocationResponse(Request request, TransportAddress mappedAddress, TransportAddress relayedAddress, Array<byte> token, int lifetime)Creates a AllocationResponse in a 5389 compliant manner containing at most 4 attributes XOR-RELAYED-ADDRESS attribute LIFETIME attribute RESERVATION-TOKEN attribute XOR-MAPPED-ADDRESS attribute static ResponsecreateAllocationErrorResponse(char errorCode)Creates a allocation error response according to the specified error code. static ResponsecreateAllocationErrorResponse(char errorCode, String reasonPhrase)Creates a allocation error response according to the specified error code. static RequestcreateGoogleAllocateRequest(String username)Create an allocate request for a Google TURN relay (old TURN protocol modified). static voidaddLongTermCredentialAttributes(Request request, Array<byte> username, Array<byte> realm, Array<byte> nonce)Adds the Attributes to a specific Request which support the STUN long-term credential mechanism. static RequestcreateRefreshRequest()Creates a new TURN Refresh Request without any optional attributes such as LIFETIME. static RequestcreateRefreshRequest(int lifetime)Create a refresh request. static ResponsecreateRefreshResponse(int lifetime)Creates a refresh success response with given lifetime. static ResponsecreateRefreshErrorResponse(char errorCode)Creates a refresh error response static ResponsecreateRefreshErrorResponse(char errorCode, String reasonPhrase)Creates a refresh error response. static RequestcreateChannelBindRequest(char channelNumber, TransportAddress peerAddress, Array<byte> tranID)Create a ChannelBind request. static ResponsecreateChannelBindResponse()Creates a Channel Bind Success Response. static ResponsecreateChannelBindErrorResponse(char errorCode)Creates a Channel Bind Error Response with given error code. static ResponsecreateChannelBindErrorResponse(char errorCode, String reasonPhrase)Creates a Channel Bind Error Response with given error code and reasonPhrase. static RequestcreateCreatePermissionRequest(TransportAddress peerAddress, Array<byte> transactionID)Creates a new TURN CreatePermission Request with a specific value for its XOR-PEER-ADDRESS attribute. static ResponsecreateCreatePermissionResponse()Creates a create permission success response. static ResponsecreateCreatePermissionErrorResponse(char errorCode)Creates a create permission error response. static ResponsecreatePermissionErrorResponse(char errorCode, String reasonPhrase)Creates a create permission error response. static IndicationcreateSendIndication(TransportAddress peerAddress, Array<byte> data, Array<byte> tranID)Create a Send Indication. static IndicationcreateDataIndication(TransportAddress peerAddress, Array<byte> data, Array<byte> tranID)Create a Data Indication. static RequestcreateSendRequest(String username, TransportAddress peerAddress, Array<byte> data)Create a old Send Request. static RequestcreateSharedSecretRequest()Create a shared secret request. static ResponsecreateSharedSecretResponse()Create a shared secret response. static ResponsecreateSharedSecretErrorResponse()Create a shared secret error response. static RequestcreateConnectRequest(TransportAddress peerAddress, Request request)Creates a ConnectRequest in a 6062 compliant manner containing only XOR-PEER-ADDRESS attribute static RequestcreateConnectRequest(TransportAddress peerAddress, Array<byte> transactionId)Creates a ConnectRequest in a 6062 compliant manner containing only XOR-PEER-ADDRESS attribute. static ResponsecreateConnectResponse(int connectionIdValue)Creates a Connect Response in a 6062 compliant manner containing a single CONNECTION-ID-ATTRIBUTE attribute static ResponsecreateConnectErrorResponse(char errorCode)Creates a Connect error response according to the specified error code. static ResponsecreateConnectErrorResponse(char errorCode, String reasonPhrase)Creates a Connect error response according to the specified error code. static RequestcreateConnectionBindRequest(int connectionIdValue)Creates a ConnectionBindRequest in a 6062 compliant manner containing only CONECTION-ID-ATTRIBUTE attribute. static ResponsecreateConnectionBindResponse()Creates a ConnectionBind Response in a 6062 compliant manner. static ResponsecreateConnectionBindErrorResponse(char errorCode)Creates a ConnectionBind error response according to the specified error code. static ResponsecreateConnectionBindErrorResponse(char errorCode, String reasonPhrase)Creates a ConnectionBind error response according to the specified error code. static IndicationcreateConnectionAttemptIndication(int connectionIdValue, TransportAddress peerAddress)Creates a ConnectionAttempt Indication in a 6062 compliant manner containing only CONECTION-ID-ATTRIBUTE attribute and XOR-PPER-ADDRESS attribute. static IndicationcreateConnectionAttemptIndication(int connectionIdValue, TransportAddress peerAddress, Array<byte> transactionId)Creates a ConnectionAttempt Indication in a 6062 compliant manner containing only CONECTION-ID-ATTRIBUTE attribute and XOR-PPER-ADDRESS attribute. -
-
Method Detail
-
createBindingRequest
static Request createBindingRequest()
Creates a default binding request. The request DOES NOT contains a ChangeRequest attribute with zero change ip and change port flags.
-
createBindingRequest
static Request createBindingRequest(long priority)
Creates a default binding request. The request contains a ChangeReqeust attribute with zero change ip and change port flags. It also contains the PRIORITY attribute used for ICE processing
- Parameters:
priority- the value for the priority attribute
-
createBindingRequest
static Request createBindingRequest(long priority, boolean controlling, long tieBreaker)
Creates a default binding request. The request contains a ChangeReqeust attribute with zero change ip and change port flags. It contains the PRIORITY, ICE-CONTROLLED or ICE-CONTROLLING attributes used for ICE processing
- Parameters:
priority- the value of the ICE priority attributescontrolling- the value of the controlling attributetieBreaker- the value of the ICE tie breaker attribute
-
create3489BindingResponse
static Response create3489BindingResponse(TransportAddress mappedAddress, TransportAddress sourceAddress, TransportAddress changedAddress)
Creates a BindingResponse in a 3489 compliant manner, assigning the specified values to mandatory headers.
- Parameters:
mappedAddress- the address to assign the mappedAddressAttributesourceAddress- the address to assign the sourceAddressAttributechangedAddress- the address to assign the changedAddressAttribute
-
createBindingResponse
static Response createBindingResponse(Request request, TransportAddress mappedAddress)
Creates a BindingResponse in a 5389 compliant manner containing a single XOR-MAPPED-ADDRESS attribute
- Parameters:
request- the request that created the transaction that this response will belong to.mappedAddress- the address to assign the mappedAddressAttribute
-
createBindingErrorResponse
static Response createBindingErrorResponse(char errorCode, String reasonPhrase, Array<char> unknownAttributes)
Creates a binding error response according to the specified error code and unknown attributes.
- Parameters:
errorCode- the error code to encapsulate in this messagereasonPhrase- a human readable description of the errorunknownAttributes- a char[] array containing the ids of one or more attributes that had not been recognized.
-
createBindingErrorResponseUnknownAttributes
static Response createBindingErrorResponseUnknownAttributes(Array<char> unknownAttributes)
Creates a binding error response with UNKNOWN_ATTRIBUTES error code and the specified unknown attributes.
- Parameters:
unknownAttributes- a char[] array containing the ids of one or more attributes that had not been recognized.
-
createBindingErrorResponseUnknownAttributes
static Response createBindingErrorResponseUnknownAttributes(String reasonPhrase, Array<char> unknownAttributes)
Creates a binding error response with UNKNOWN_ATTRIBUTES error code and the specified unknown attributes and reason phrase.
- Parameters:
reasonPhrase- a short description of the error.unknownAttributes- a char[] array containing the ids of one or more attributes that had not been recognized.
-
createBindingErrorResponse
static Response createBindingErrorResponse(char errorCode, String reasonPhrase)
Creates a binding error response with an ERROR-CODE attribute.
- Parameters:
errorCode- the error code to encapsulate in this messagereasonPhrase- a human readable description of the error.
-
createBindingErrorResponse
static Response createBindingErrorResponse(char errorCode)
Creates a binding error response according to the specified error code.
- Parameters:
errorCode- the error code to encapsulate in this message attributes that had not been recognized.
-
createBindingIndication
static Indication createBindingIndication()
Creates a default binding indication.
-
createAllocateRequest
static Request createAllocateRequest()
Create an allocate request without attribute.
-
createAllocateRequest
static Request createAllocateRequest(byte protocol, boolean rFlag)
Create an allocate request to allocate an even port. Attention this does not have attributes for long-term authentication.
- Parameters:
protocol- requested protocol numberrFlag- R flag for the EVEN-PORT
-
createAllocationResponse
static Response createAllocationResponse(Request request, TransportAddress mappedAddress, TransportAddress relayedAddress, int lifetime)
Creates a AllocationResponse in a 5389 compliant manner containing at most 4 attributes XOR-RELAYED-ADDRESS attribute LIFETIME attribute XOR-MAPPED-ADDRESS attribute
- Parameters:
request- the request that created the transaction that this response will belong to.mappedAddress- the address to assign the mappedAddressAttributerelayedAddress- the address to assign the relayedAddressAttributelifetime- the address to assign the lifetimeAttribute
-
createAllocationResponse
static Response createAllocationResponse(Request request, TransportAddress mappedAddress, TransportAddress relayedAddress, Array<byte> token, int lifetime)
Creates a AllocationResponse in a 5389 compliant manner containing at most 4 attributes XOR-RELAYED-ADDRESS attribute LIFETIME attribute RESERVATION-TOKEN attribute XOR-MAPPED-ADDRESS attribute
- Parameters:
request- the request that created the transaction that this response will belong to.mappedAddress- the address to assign the mappedAddressAttributerelayedAddress- the address to assign the relayedAddressAttributetoken- the address to assign the reservationTokenAttributelifetime- the address to assign the lifetimeAttribute
-
createAllocationErrorResponse
static Response createAllocationErrorResponse(char errorCode)
Creates a allocation error response according to the specified error code.
- Parameters:
errorCode- the error code to encapsulate in this message attributes that had not been recognised.
-
createAllocationErrorResponse
static Response createAllocationErrorResponse(char errorCode, String reasonPhrase)
Creates a allocation error response according to the specified error code.
- Parameters:
errorCode- the error code to encapsulate in this messagereasonPhrase- a human readable description of the error attributes that had not been recognised.
-
createGoogleAllocateRequest
static Request createGoogleAllocateRequest(String username)
Create an allocate request for a Google TURN relay (old TURN protocol modified).
- Parameters:
username- short-term username
-
addLongTermCredentialAttributes
static void addLongTermCredentialAttributes(Request request, Array<byte> username, Array<byte> realm, Array<byte> nonce)
Adds the Attributes to a specific Request which support the STUN long-term credential mechanism.
Warning: The MESSAGE-INTEGRITY Attribute will also be added so Attributes added afterwards will not be taken into account for the calculation of the MESSAGE-INTEGRITY value. For example, the FINGERPRINT Attribute may still safely be added afterwards, because it is known to appear after the MESSAGE-INTEGRITY.
- Parameters:
request- the Request in which the Attributes of the STUN long-term credential mechanism are to be addedusername- the value for the USERNAME Attribute to be added to requestrealm- the value for the REALM Attribute to be added to requestnonce- the value for the NONCE Attribute to be added to request
-
createRefreshRequest
static Request createRefreshRequest()
Creates a new TURN Refresh Request without any optional attributes such as LIFETIME.
-
createRefreshRequest
static Request createRefreshRequest(int lifetime)
Create a refresh request.
- Parameters:
lifetime- lifetime value
-
createRefreshResponse
static Response createRefreshResponse(int lifetime)
Creates a refresh success response with given lifetime.
- Parameters:
lifetime- the lifetime value to be used.
-
createRefreshErrorResponse
static Response createRefreshErrorResponse(char errorCode)
Creates a refresh error response
- Parameters:
errorCode- the error code to encapsulate in this message.
-
createRefreshErrorResponse
static Response createRefreshErrorResponse(char errorCode, String reasonPhrase)
Creates a refresh error response.
- Parameters:
errorCode- the error code to encapsulate in this message.reasonPhrase- a human readable description of the error.
-
createChannelBindRequest
static Request createChannelBindRequest(char channelNumber, TransportAddress peerAddress, Array<byte> tranID)
Create a ChannelBind request.
- Parameters:
channelNumber- the channel numberpeerAddress- the peer addresstranID- the ID of the transaction that we should be using
-
createChannelBindResponse
static Response createChannelBindResponse()
Creates a Channel Bind Success Response.
-
createChannelBindErrorResponse
static Response createChannelBindErrorResponse(char errorCode)
Creates a Channel Bind Error Response with given error code.
- Parameters:
errorCode- the error code to encapsulate in this message.
-
createChannelBindErrorResponse
static Response createChannelBindErrorResponse(char errorCode, String reasonPhrase)
Creates a Channel Bind Error Response with given error code and reasonPhrase.
- Parameters:
errorCode- the error code to encapsulate in this message.reasonPhrase- a human readable description of the error.
-
createCreatePermissionRequest
static Request createCreatePermissionRequest(TransportAddress peerAddress, Array<byte> transactionID)
Creates a new TURN CreatePermission Request with a specific value for its XOR-PEER-ADDRESS attribute.
- Parameters:
peerAddress- the value to assigned to the XOR-PEER-ADDRESS attributetransactionID- the ID of the transaction which is to be used for the assignment of peerAddress to the XOR-PEER-ADDRESS attribute
-
createCreatePermissionResponse
static Response createCreatePermissionResponse()
Creates a create permission success response.
-
createCreatePermissionErrorResponse
static Response createCreatePermissionErrorResponse(char errorCode)
Creates a create permission error response.
- Parameters:
errorCode- the error code to encapsulate in this message.
-
createPermissionErrorResponse
static Response createPermissionErrorResponse(char errorCode, String reasonPhrase)
Creates a create permission error response.
- Parameters:
errorCode- the error code to encapsulate in this message.reasonPhrase- a human readable description of the error.
-
createSendIndication
static Indication createSendIndication(TransportAddress peerAddress, Array<byte> data, Array<byte> tranID)
Create a Send Indication.
- Parameters:
peerAddress- peer addressdata- data (could be 0 byte)tranID- the ID of the transaction that we should be using
-
createDataIndication
static Indication createDataIndication(TransportAddress peerAddress, Array<byte> data, Array<byte> tranID)
Create a Data Indication.
- Parameters:
peerAddress- peer addressdata- data (could be 0 byte)tranID- the ID of the transaction that we should be using
-
createSendRequest
static Request createSendRequest(String username, TransportAddress peerAddress, Array<byte> data)
Create a old Send Request.
- Parameters:
username- the usernamepeerAddress- peer addressdata- data (could be 0 byte)
-
createSharedSecretRequest
static Request createSharedSecretRequest()
Create a shared secret request. WARNING: This is not currently supported.
-
createSharedSecretResponse
static Response createSharedSecretResponse()
Create a shared secret response. WARNING: This is not currently supported.
-
createSharedSecretErrorResponse
static Response createSharedSecretErrorResponse()
Create a shared secret error response. WARNING: This is not currently supported.
-
createConnectRequest
static Request createConnectRequest(TransportAddress peerAddress, Request request)
Creates a ConnectRequest in a 6062 compliant manner containing only XOR-PEER-ADDRESS attribute
- Parameters:
peerAddress- the address to assign the xorPeerAddressAttributerequest- the request that created the transaction that this response will belong to.
-
createConnectRequest
static Request createConnectRequest(TransportAddress peerAddress, Array<byte> transactionId)
Creates a ConnectRequest in a 6062 compliant manner containing only XOR-PEER-ADDRESS attribute. This method is used by turnserver.
- Parameters:
peerAddress- the address to assign the xorPeerAddressAttributetransactionId- the transaction id that this response will belong to.
-
createConnectResponse
static Response createConnectResponse(int connectionIdValue)
Creates a Connect Response in a 6062 compliant manner containing a single CONNECTION-ID-ATTRIBUTE attribute
- Parameters:
connectionIdValue- the address to assign the connectionIdAttribute
-
createConnectErrorResponse
static Response createConnectErrorResponse(char errorCode)
Creates a Connect error response according to the specified error code.
- Parameters:
errorCode- the error code to encapsulate in this message
-
createConnectErrorResponse
static Response createConnectErrorResponse(char errorCode, String reasonPhrase)
Creates a Connect error response according to the specified error code.
- Parameters:
errorCode- the error code to encapsulate in this messagereasonPhrase- a human readable description of the error
-
createConnectionBindRequest
static Request createConnectionBindRequest(int connectionIdValue)
Creates a ConnectionBindRequest in a 6062 compliant manner containing only CONECTION-ID-ATTRIBUTE attribute.
- Parameters:
connectionIdValue- the value to assign the connectionIdAtribute
-
createConnectionBindResponse
static Response createConnectionBindResponse()
Creates a ConnectionBind Response in a 6062 compliant manner.
-
createConnectionBindErrorResponse
static Response createConnectionBindErrorResponse(char errorCode)
Creates a ConnectionBind error response according to the specified error code.
- Parameters:
errorCode- the error code to encapsulate in this message
-
createConnectionBindErrorResponse
static Response createConnectionBindErrorResponse(char errorCode, String reasonPhrase)
Creates a ConnectionBind error response according to the specified error code.
- Parameters:
errorCode- the error code to encapsulate in this messagereasonPhrase- a human readable description of the error
-
createConnectionAttemptIndication
static Indication createConnectionAttemptIndication(int connectionIdValue, TransportAddress peerAddress)
Creates a ConnectionAttempt Indication in a 6062 compliant manner containing only CONECTION-ID-ATTRIBUTE attribute and XOR-PPER-ADDRESS attribute.
- Parameters:
connectionIdValue- the value to assign the connectionidAtributepeerAddress- the value to assign the xorPeerAddress
-
createConnectionAttemptIndication
static Indication createConnectionAttemptIndication(int connectionIdValue, TransportAddress peerAddress, Array<byte> transactionId)
Creates a ConnectionAttempt Indication in a 6062 compliant manner containing only CONECTION-ID-ATTRIBUTE attribute and XOR-PPER-ADDRESS attribute.
- Parameters:
connectionIdValue- the value to assign the connectionidAtributepeerAddress- the value to assign the xorPeerAddresstransactionId- the transaction id that the response belongs to.
-
-
-
-