Subject: Java-api-12 - input/output stream

From: "Steve Sonntag" <[email-masked]>
Date: Tue, 05 Dec 2000 10:12:32 -0700

I have been trying to figure out how the set/get inputStream & OutputStream
methods should be used in the LDAPConnection class.  The
document states:

Added getInputStream()getOutputStream(), setInputStream() 
(4.6.36), and setOutputStream(). They are used when establishing 
a security layer with SASL, and may also be used to interpose a 
proxy.

A few comments. and questions:

1)   I don't ever see a case where one would set the input stream and 
not also set the outputstream. If this is true, then the method should
set both of them, as setting them individually is inherently not thread safe.

2) Does it ever make sense to set these values on a connection
"in progress"?  Is there an intent that the existing stream classes be
subclassed to add encryption or other functionality? 
Or does it only make sense to change the streams only
after the connect and before the bind or the first operation?

3) I don't ever see an application using the existing input/output
streams directly on a connection in progresss - i.e., trying to read
on the input stream - that could cause great confusion in the API
as the reader thread in the api and the application contend for
input data.  Rather they would only be used to create sub classes
that extend their functionality.  Am I on the right track here?

-Steve

------------------------
Steve Sonntag
Novell, Inc., the leading provider of Net services software

---

From: "Steve Sonntag" <[email-masked]>
Date: Tue, 05 Dec 2000 16:08:15 -0700

So shouldn't both the input stream and the output stream be set
in one atomic operation so it is thread safe?

-Steve

>>> Rob Weltman <[email-masked]> 05-Dec-00 2:45:14 PM >>>
"Kurt D. Zeilenga" wrote:
> 
> At 10:45 AM 12/5/00 -0800, Rob Weltman wrote:
> >Steve Sonntag wrote:
> >>  I have been trying to figure out how the set/get inputStream & OutputStreammethods should be used in the LDAPConnection class.  Thedocument states: Added getInputStream()getOutputStream(), setInputStream()
> >>proxy. A few comments. and questions: 1)   I don't ever see a case where one would set the input stream andnot also set the outputstream. If this is true, then the method shouldset both of them, as setting them individually is inherently not thread safe. 2) Does it ever make sense to set these values on a connection"in progress"?  Is there an intent that the existing stream classes besubclassed to add encryption or other functionality?Or does it only make sense to change the streams onlyafter the connect and before the bind or the first operation? 3) I don't ever see an application using the existing input/outputstreams directly on a connection in progresss - i.e., trying to readon the input stream - that could cause great confusion in the APIas the reader thread in the api and the application contend forinput data.  Rather they would only be used to create sub classesthat extend their functionality.  Am I on the right track here? -Steve
> >
> >
> >  The only use we've had for the methods so far is on SASL bind, where the result of the operation may be a new security layer. In that case, both input and output streams are replaced.
> 
> Wouldn't you also need to replace them upon StartTLS?
> 
> Kurt

  Probably. But I haven't looked into the implementation of StartTLS yet.

Rob

---

From: Rob Weltman <[email-masked]>
Date: Tue, 05 Dec 2000 15:15:20 -0800

Seems like an unnecessary restriction to me. It is very easy to do something like

synchronized( ldc ) {
    ldc.setInputStream( is );
    ldc.setOutputStream( os );
}

  in a client that wants to set both of them. There may be a case where a client does not want to set both at the same time, and we would be preventing that by combining the two.

  The two examples I've looked into (SASL and StartTLS) do not involve a real client making those calls; they are made by middleware (SASL) code or by other parts of the LDAP class library itself (StartTLS). An implementation of the class library may have a combined method as described for internal operations or even for external clients if it sees a benefit to it.

Rob

Steve Sonntag wrote:

>  So shouldn't both the input stream and the output stream be setin one atomic operation so it is thread safe? -Steve
>