com.sun.jini.jeri.internal.http
Class HttpServerConnection.InboundRequestImpl

java.lang.Object
  extended by com.sun.jini.jeri.internal.http.Request
      extended by com.sun.jini.jeri.internal.http.HttpServerConnection.InboundRequestImpl
All Implemented Interfaces:
InboundRequest
Enclosing class:
HttpServerConnection

private class HttpServerConnection.InboundRequestImpl
extends Request
implements InboundRequest

HTTP-based implementation of InboundRequest abstraction.


Field Summary
private  String cookie
           
private  boolean corrupt
           
private  MessageReader reader
           
private  MessageWriter writer
           
 
Constructor Summary
HttpServerConnection.InboundRequestImpl(MessageReader reader, MessageWriter writer)
          Creates new InboundRequestImpl which uses given MessageReader and MessageWriter instances to read/write request content.
 
Method Summary
(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.
 
Methods inherited from class com.sun.jini.jeri.internal.http.Request
abort, addAcknowledgmentListener, finish, getDeliveryStatus, getInputStream, getOutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.jini.jeri.InboundRequest
abort
 

Field Detail

reader

private final MessageReader reader

writer

private final MessageWriter writer

cookie

private String cookie

corrupt

private boolean corrupt
Constructor Detail

HttpServerConnection.InboundRequestImpl

HttpServerConnection.InboundRequestImpl(MessageReader reader,
                                        MessageWriter writer)
Creates new InboundRequestImpl which uses given MessageReader and MessageWriter instances to read/write request content.

Method Detail

checkPermissions

public void checkPermissions()
Description copied from interface: InboundRequest
Verifies that the current security context has all of the security permissions necessary to receive this request.

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.

Specified by:
checkPermissions in interface InboundRequest

checkConstraints

public InvocationConstraints checkConstraints(InvocationConstraints constraints)
                                       throws UnsupportedConstraintException
Description copied from interface: InboundRequest
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. This method may also return preferences that must be at least partially implemented by higher layers in order to fully satisfy some of the specified preferences.

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.

Specified by:
checkConstraints in interface InboundRequest
Parameters:
constraints - the constraints that must be satisfied
Returns:
the constraints that must be at least partially implemented by higher layers
Throws:
UnsupportedConstraintException - if the transport layer aspects of any of the specified requirements are not satisfied by this request

populateContext

public void populateContext(Collection context)
Description copied from interface: InboundRequest
Populates the supplied collection with context information representing this request.

Specified by:
populateContext in interface InboundRequest
Parameters:
context - the context collection to populate

getRequestInputStream

public InputStream getRequestInputStream()
Description copied from interface: InboundRequest
Returns an 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).

Specified by:
getRequestInputStream in interface InboundRequest
Returns:
the input stream to read request data from

getResponseOutputStream

public OutputStream getResponseOutputStream()
Description copied from interface: InboundRequest
Returns an 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).

Specified by:
getResponseOutputStream in interface InboundRequest
Returns:
the output stream to write response data to

streamCorrupt

boolean streamCorrupt()
Returns true if stream corrupted, false if stream ok.


startOutput

void startOutput()
           throws IOException
Description copied from class: Request
Method called internally before any outbound data is written.

Specified by:
startOutput in class Request
Throws:
IOException

write

void write(byte[] b,
           int off,
           int len)
     throws IOException
Description copied from class: Request
Method called internally to write outbound request/response data.

Specified by:
write in class Request
Throws:
IOException

endOutput

void endOutput()
         throws IOException
Description copied from class: Request
Method called internally to signal the end of outbound data.

Specified by:
endOutput in class Request
Throws:
IOException

startInput

boolean startInput()
             throws IOException
Description copied from class: Request
Method called internally before any inbound data is read. Returns true if inbound data is valid, false otherwise (e.g., error message content).

Specified by:
startInput in class Request
Throws:
IOException

read

int read(byte[] b,
         int off,
         int len)
   throws IOException
Description copied from class: Request
Method called internally to read inbound request/response data.

Specified by:
read in class Request
Throws:
IOException

available

int available()
        throws IOException
Description copied from class: Request
Method called internally to gauge available inbound data.

Specified by:
available in class Request
Throws:
IOException

endInput

void endInput()
        throws IOException
Description copied from class: Request
Method called internally when finished reading inbound data.

Specified by:
endInput in class Request
Throws:
IOException

addAckListener

void addAckListener(AcknowledgmentSource.Listener listener)
Description copied from class: Request
Method called internally to register acknowledgment listener.

Specified by:
addAckListener in class Request

done

void done(boolean corrupt)
Description copied from class: Request
Method called internally when request is finished. If corrupt is true, the underlying transport channel has been left in an unknown state.

Specified by:
done in class Request


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.