public class DefaultClientProtocolHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private IStreamConnection |
m_connection
This stores the forwarded connection.
|
private int |
m_minDummyTrafficInterval
This stores the minimal dummy traffic interval (in ms) for the forwarder.
|
private ProgressCounter |
m_progressCounter
Count the number of packets that we read
Usefull for the beginning of the connection
|
private MixCascade |
m_selectedMixCascade
This stores the selected MixCascade.
|
private int |
m_state
This stores the internal protocol state.
|
private static int |
MAXIMUM_PROTOCOLMESSAGE_SIZE
This is the maximum net size of a protocol message in bytes.
|
private static byte[] |
MESSAGE_END_SIGNATURE
This is the end signature of every protocol message.
|
private static byte[] |
MESSAGE_START_COMPRESS_SIGNATURE
This is the start signature for a compressed protocol message.
|
private static byte[] |
MESSAGE_START_SIGNATURE
This is the start signature of every no compressed protocol message.
|
private static int |
PROTOCOL_VERSION
This is the version of the current protocol implementation.
|
private static int |
STATE_CASCADE_SELECTED
This is the state after we have sent our selected MixCascade to the forwarder.
|
private static int |
STATE_CLOSED_AFTER_ERROR
This is the state after we have got an error and closed the connection.
|
private static int |
STATE_FORWARDING
This is the state while forwarding is active.
|
private static int |
STATE_INITIALIZE
This is the state after the physical connection to the forwarder is established and the
protocol is initialized.
|
private static int |
STATE_OFFER_RECEIVED
This is the state after receiving the forward connection offer from the forwarder.
|
Constructor and Description |
---|
DefaultClientProtocolHandler(IStreamConnection a_connection)
Creates a new instance of DefaultClientProtocol handler.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
checkSignature(byte[] a_signature1,
byte[] a_signature2)
This method checks, whether to byte arrays have identical content or not.
|
private byte[] |
createProtocolPacket(byte[] a_data)
Creates a protocol packet from byte array with data.
|
private org.w3c.dom.Document |
generateConnectionRequest()
Creates the connection request message.
|
ForwardConnectionDescriptor |
getConnectionDescriptor()
Returns the connection descriptor with the offer from the forwarder.
|
ProgressCounter |
getPacketCounter() |
MixCascade |
getSelectedService() |
private byte[] |
readProtocolMessage()
Reads a message from the associated network connection.
|
void |
selectMixCascade(MixCascade a_mixCascade)
This method must be called exactly once, after we have received the the connection offer
from the forwarder.
|
private void |
sendProtocolMessage(byte[] a_message)
Sends a message to the associated network connection.
|
private byte[] |
xmlToProtocolPacket(org.w3c.dom.Document a_doc)
Creates a protocol packet from an XML structure.
|
private static final int PROTOCOL_VERSION
private static final int MAXIMUM_PROTOCOLMESSAGE_SIZE
private static final int STATE_INITIALIZE
private static final int STATE_OFFER_RECEIVED
private static final int STATE_CASCADE_SELECTED
private static final int STATE_FORWARDING
private static final int STATE_CLOSED_AFTER_ERROR
private static final byte[] MESSAGE_START_SIGNATURE
private static final byte[] MESSAGE_START_COMPRESS_SIGNATURE
private static final byte[] MESSAGE_END_SIGNATURE
private IStreamConnection m_connection
private int m_state
private int m_minDummyTrafficInterval
private MixCascade m_selectedMixCascade
private ProgressCounter m_progressCounter
public DefaultClientProtocolHandler(IStreamConnection a_connection)
a_connection
- A active ProxyConnection to a forwarder.public ForwardConnectionDescriptor getConnectionDescriptor() throws ClientForwardException
ClientForwardException
public MixCascade getSelectedService()
public void selectMixCascade(MixCascade a_mixCascade) throws ClientForwardException
a_mixCascade
- The mixcascade from the connection offer we want to use.ClientForwardException
private org.w3c.dom.Document generateConnectionRequest() throws ClientForwardException
ClientForwardException
private byte[] readProtocolMessage() throws ClientForwardException
ClientForwardException
private void sendProtocolMessage(byte[] a_message) throws ClientForwardException
a_message
- The message to send.ClientForwardException
private boolean checkSignature(byte[] a_signature1, byte[] a_signature2)
a_signature1
- The first byte array.a_signature2
- The second byte array.private byte[] xmlToProtocolPacket(org.w3c.dom.Document a_doc) throws java.lang.Exception
doc
- The XML structure which shall be transformed in a protocol packet.java.lang.Exception
private byte[] createProtocolPacket(byte[] a_data)
a_data
- The bytes to put in the protocol packet.public ProgressCounter getPacketCounter()
Copyright © 2023. All rights reserved.