|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.acplt.oncrpc.XdrDecodingStream org.acplt.oncrpc.XdrHttpDecodingStream
public class XdrHttpDecodingStream
The XdrHttpDecodingStream
class provides the necessary
functionality to XdrDecodingStream
to receive XDR data through
HTTP tunnels.
Please note that there is currently no standard about how to tunnel XDR data over HTTP connections. There are a (quite a) few solutions out there, but they are more or less incompatible due to the lack of a RFC.
This class is responsible solely for receiving ONC/RPC replies. The reply data is base64 encoded and embedded within an ordinary plain ASCII page, as is shown in this example.
DEADBEEFDEADBEEFDEADBEEF...<CR><LF> B0D0EADSDEADBEEFB0D0EADS...<CR><LF> ...<CR><LF> DEADBE==<CR><LF>
Parsing is minimalistic to make the whole sucker as fast as possible (not looking at Java's performance at all).
Field Summary | |
---|---|
private byte[] |
asciiBuffer
The buffer receiving base64 encoded plain ASCII data from a HTTP web server. |
private int |
asciiBufferSize
Size of buffer for receiving the base64 encoded plain ASCII data. |
private byte[] |
buffer
The buffer which will be filled from the datagram socket and then be used to supply the information when decoding data. |
private int |
bufferHighmark
Index of the last four byte word in the buffer, which has been read in from the datagram socket. |
private int |
bufferIndex
The read pointer is an index into the buffer . |
private HttpClientConnection |
httpClient
Client HTTP tunnel to retrieve embedded XDR records from. |
Constructor Summary | |
---|---|
XdrHttpDecodingStream(HttpClientConnection httpClient)
Constructs a new XdrHttpDecodingStream . |
Method Summary | |
---|---|
void |
beginDecoding()
Initiates decoding of the next XDR record. |
void |
close()
Closes this decoding XDR stream and releases any system resources associated with this stream. |
void |
endDecoding()
End decoding of the current XDR record. |
private void |
fill()
Receives more encoded data over the HTTP connection and decodes it into octets, making them available through the buffer field. |
java.net.InetAddress |
getSenderAddress()
Returns the Internet address of the sender of the current XDR data. |
int |
getSenderPort()
Returns the port number of the sender of the current XDR data. |
int |
xdrDecodeInt()
Decodes (aka "deserializes") a "XDR int" value received from a XDR stream. |
void |
xdrDecodeOpaque(byte[] opaque,
int offset,
int length)
Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values, and starts at offset with a
length of length . |
byte[] |
xdrDecodeOpaque(int length)
Decodes (aka "deserializes") an opaque value, which is nothing more than a series of octets (or 8 bits wide bytes). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private HttpClientConnection httpClient
private byte[] buffer
private byte[] asciiBuffer
buffer
field.
private int asciiBufferSize
buffer
field.
private int bufferIndex
buffer
.
private int bufferHighmark
Constructor Detail |
---|
public XdrHttpDecodingStream(HttpClientConnection httpClient)
XdrHttpDecodingStream
.
httpClient
- HTTP client connection from which to read the
encoded and embedded ONC/RPC reply message.Method Detail |
---|
public java.net.InetAddress getSenderAddress()
beginDecoding()
,
otherwise it might return stale information.
getSenderAddress
in class XdrDecodingStream
public int getSenderPort()
beginDecoding()
,
otherwise it might return stale information.
getSenderPort
in class XdrDecodingStream
public void beginDecoding() throws OncRpcException, java.io.IOException
beginDecoding
in class XdrDecodingStream
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public void endDecoding() throws OncRpcException, java.io.IOException
endDecoding
is that calling it is an indication that
the current record is no more interesting to the caller and any
allocated data for this record can be freed.
To help the HTTP connection keeping alive, we swallow all data until we reach the end. If this is not possible, either because the server indicated that it can not keep the connection open, the content length was unknown in advance, or we got an I/O exception, we close the connection.
endDecoding
in class XdrDecodingStream
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public void close() throws OncRpcException, java.io.IOException
This implementation frees the allocated buffer but does not close the associated datagram socket. It only throws away the reference to this socket.
close
in class XdrDecodingStream
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.private void fill() throws OncRpcException, java.io.IOException
buffer
field.
OncRpcException
java.io.IOException
public int xdrDecodeInt() throws OncRpcException, java.io.IOException
xdrDecodeInt
in class XdrDecodingStream
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public byte[] xdrDecodeOpaque(int length) throws OncRpcException, java.io.IOException
xdrDecodeOpaque(byte[], int, int)
where
first the length of the opaque value is retrieved from the XDR stream.
xdrDecodeOpaque
in class XdrDecodingStream
length
- Length of opaque data to decode.
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.public void xdrDecodeOpaque(byte[] opaque, int offset, int length) throws OncRpcException, java.io.IOException
offset
with a
length of length
. Only the opaque value is decoded, so the
caller has to know how long the opaque value will be. The decoded data
is always padded to be a multiple of four (because that's what the
sender does).
xdrDecodeOpaque
in class XdrDecodingStream
opaque
- Byte vector which will receive the decoded opaque value.offset
- Start offset in the byte vector.length
- the number of bytes to decode.
OncRpcException
- if an ONC/RPC error occurs.
java.io.IOException
- if an I/O error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |