package CyrusSasl; import java.io.*; public class SaslOutputStream extends OutputStream { static final boolean DoEncrypt = true; static final boolean DoDebug = false; private static int MAXBUFFERSIZE=1000; private GenericCommon conn; OutputStream out; private byte[] buffer=new byte[MAXBUFFERSIZE]; private int buffersize=0; public SaslOutputStream(OutputStream out, GenericCommon conn) { if (DoDebug) { System.err.println("DEBUG constructing SaslOutputStream"); } this.conn=conn; this.out=out; } private void write_if_size() throws IOException { if (DoDebug) { System.err.println("DEBUG write_if_size(): buffersize " + buffersize); } if ( buffersize >=MAXBUFFERSIZE) flush(); } public synchronized void write(int b) throws IOException { buffer[buffersize]=(byte) b; buffersize++; write_if_size(); } public synchronized void write(byte b[]) throws IOException { write(b,0,b.length); } public synchronized void write(byte b[], int off, int len) throws IOException { if (DoDebug) { System.err.println("DEBUG writing() len " + len); } if (len+buffersize < MAXBUFFERSIZE) { for (int lup=0;lup