private class HttpServerConnection.InboundRequestImpl extends Request implements InboundRequest
Modifier and Type | Field and Description |
---|---|
private String |
cookie |
private boolean |
corrupt |
private MessageReader |
reader |
private MessageWriter |
writer |
Constructor and Description |
---|
HttpServerConnection.InboundRequestImpl(MessageReader reader,
MessageWriter writer)
Creates new InboundRequestImpl which uses given MessageReader and
MessageWriter instances to read/write request content.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addAckListener(AcknowledgmentSource.Listener listener)
Method called internally to register acknowledgment listener.
|
(package private) int |
available()
Method called internally to gauge available inbound data.
|
InvocationConstraints |
checkConstraints(InvocationConstraints constraints)
Verifies that this request satisfies the transport layer
aspects of all of the specified requirements, and returns the
requirements that must be at least partially implemented by
higher layers in order to fully satisfy the specified
requirements.
|
void |
checkPermissions()
Verifies that the current security context has all of the
security permissions necessary to receive this request.
|
(package private) void |
done(boolean corrupt)
Method called internally when request is finished.
|
(package private) void |
endInput()
Method called internally when finished reading inbound data.
|
(package private) void |
endOutput()
Method called internally to signal the end of outbound data.
|
InputStream |
getRequestInputStream()
Returns an
InputStream to read the request data
from. |
OutputStream |
getResponseOutputStream()
Returns an
OutputStream to write the response data
to. |
void |
populateContext(Collection context)
Populates the supplied collection with context information
representing this request.
|
(package private) int |
read(byte[] b,
int off,
int len)
Method called internally to read inbound request/response data.
|
(package private) boolean |
startInput()
Method called internally before any inbound data is read.
|
(package private) void |
startOutput()
Method called internally before any outbound data is written.
|
(package private) boolean |
streamCorrupt()
Returns true if stream corrupted, false if stream ok.
|
(package private) void |
write(byte[] b,
int off,
int len)
Method called internally to write outbound request/response data.
|
abort, addAcknowledgmentListener, finish, getDeliveryStatus, getInputStream, getOutputStream
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
abort
private final MessageReader reader
private final MessageWriter writer
private String cookie
private boolean corrupt
HttpServerConnection.InboundRequestImpl(MessageReader reader, MessageWriter writer)
public void checkPermissions()
InboundRequest
This method should be used when a particular shared mechanism is used to receive requests for a variety of interested parties, each with potentially different security permissions possibly more limited than those granted to the code managing the shared mechanism, so that the managing code can verify proper access control for each party.
For example, a TCP-based InboundRequest
implementation typically implements this method by invoking the
checkAccept
method of the
current security manager (if any) with the client's host
address and TCP port. An implementation that supports
authentication typically checks that the current security
context has the necessary AuthenticationPermission
with
accept
action.
checkPermissions
in interface InboundRequest
public InvocationConstraints checkConstraints(InvocationConstraints constraints) throws UnsupportedConstraintException
InboundRequest
For any given constraint, there must be a clear delineation
of which aspects (if any) must be implemented by the transport
layer. This method must not return a constraint (as a
requirement or a preference, directly or as an element of
another constraint) unless this request implements all of those
aspects. Also, this method must not return a constraint for
which all aspects must be implemented by the transport layer.
Most of the constraints in the net.jini.core.constraint
package must be fully implemented by the transport layer and
thus must not be returned by this method; the one exception is
Integrity
, for which the transport layer is responsible
for the data integrity aspect and higher layers are responsible
for the code integrity aspect.
For any ConstraintAlternatives
in the specified
constraints, this method should only return a corresponding
constraint if all of the alternatives satisfied by this request
need to be at least partially implemented by higher layers in
order to be fully satisfied.
The constraints actually in force may cause conditional
constraints to have to be satisfied. For example, if the only
requirement specified is Delegation.YES
but the client was in fact authenticated, then the client must
also have delegated to the server.
The constraints passed to this method may include constraints based on relative time.
checkConstraints
in interface InboundRequest
constraints
- the constraints that must be satisfiedUnsupportedConstraintException
- if the transport layer
aspects of any of the specified requirements are not satisfied
by this requestpublic void populateContext(Collection context)
InboundRequest
populateContext
in interface InboundRequest
context
- the context collection to populatepublic InputStream getRequestInputStream()
InboundRequest
InputStream
to read the request data
from. The sequence of bytes produced by reading from the
returned stream will be the sequence of bytes received as the
request data. When the entirety of the request has been
successfully read, reading from the stream will indicate an
EOF.
Invoking the close
method of the returned
stream will cause any subsequent read operations on the stream
to fail with an IOException
, although it will not
terminate this request as a whole; in particular, the response
may still be subsequently written to the stream returned by the
getResponseOutputStream
method. After
close
has been invoked on both the returned stream
and the stream returned by
getResponseOutputStream
, the implementation may
free all resources associated with this request.
If this method is invoked more than once, it will always return the identical stream object that it returned the first time (although the stream may be in a different state than it was upon return from the first invocation).
getRequestInputStream
in interface InboundRequest
public OutputStream getResponseOutputStream()
InboundRequest
OutputStream
to write the response data
to. The sequence of bytes written to the returned stream will
be the sequence of bytes sent as the response.
After the entirety of the response has been written to the
stream, the stream's close
method must be invoked
to ensure complete delivery of the response. It is possible
that none of the data written to the returned stream will be
delivered before close
has been invoked (even if
the stream's flush
method has been invoked at any
time). Note, however, that some or all of the data written to
the stream may be delivered to (and processed by) the recipient
before the stream's close
method has been invoked.
After the stream's close
method has been
invoked, no more data may be written to the stream; writes
subsequent to a close
invocation will fail with an
IOException
.
If this method is invoked more than once, it will always return the identical stream object that it returned the first time (although the stream may be in a different state than it was upon return from the first invocation).
getResponseOutputStream
in interface InboundRequest
boolean streamCorrupt()
void startOutput() throws IOException
Request
startOutput
in class Request
IOException
void write(byte[] b, int off, int len) throws IOException
Request
write
in class Request
IOException
void endOutput() throws IOException
Request
endOutput
in class Request
IOException
boolean startInput() throws IOException
Request
startInput
in class Request
IOException
int read(byte[] b, int off, int len) throws IOException
Request
read
in class Request
IOException
int available() throws IOException
Request
available
in class Request
IOException
void endInput() throws IOException
Request
endInput
in class Request
IOException
void addAckListener(AcknowledgmentSource.Listener listener)
Request
addAckListener
in class Request
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.