SmartFrog 3.10.000

org.smartfrog.sfcore.security
Class SFInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.smartfrog.sfcore.security.SFInputStream
All Implemented Interfaces:
java.io.Closeable

public class SFInputStream
extends java.io.FilterInputStream

We need to wrap the input stream returned by a socket so that we can later associate the thread that does the method invocation with the security session. We do that in a non-portable, and ad-hoc way but according to SUN experts in the RMI mailing list there is no better way to do it .... We basically rely on the thread that unmarshalls the arguments (and therefore calls read in this input stream) is the one that executes the method invocation. Then, we propagate the security context in a thread local updated in the read.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
SFInputStream(java.io.InputStream in, SFSocket sfs)
          Constructs SFInputStream with input stream and sockat.
 
Method Summary
 int read()
          Reads the next byte of data from this input stream.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from this input stream into an array of bytes.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SFInputStream

public SFInputStream(java.io.InputStream in,
                     SFSocket sfs)
Constructs SFInputStream with input stream and sockat.

Parameters:
in - The original input stream associated with the socket.
sfs - The socket that we want to associate with this input stream.
Method Detail

read

public int read()
         throws java.io.IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

This method simply performs in.read() and returns the result.

Overrides:
read in class java.io.FilterInputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

This method simply performs in.read(b, off, len) and returns the result.

Overrides:
read in class java.io.FilterInputStream
Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP