2
* $Id: SaslOutputStream.java,v 1.2 2003/10/19 16:16:50 dog Exp $
3
* Copyright (C) 2002 The Free Software Foundation
5
* This file is part of GNU inetlib, a library.
7
* GNU inetlib is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* GNU inetlib is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this library; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
* As a special exception, if you link this library with other files to
22
* produce an executable, this library does not by itself cause the
23
* resulting executable to be covered by the GNU General Public License.
24
* This exception does not however invalidate any other reasons why the
25
* executable file might be covered by the GNU General Public License.
28
package gnu.inet.util;
30
import java.io.FilterOutputStream;
31
import java.io.IOException;
32
import java.io.OutputStream;
34
import javax.security.sasl.SaslClient;
37
* A filter output stream that encodes data written to it using a SASL
40
* @author <a href="mailto:dog@gnu.org">Chris Burdess</a>
41
* @version $Revision: 1.2 $ $Date: 2003/10/19 16:16:50 $
43
public class SaslOutputStream extends FilterOutputStream
47
* The SASL client used for encoding data.
49
private final SaslClient sasl;
53
* @param sasl the SASL client
54
* @param out the target output stream
56
public SaslOutputStream(SaslClient sasl, OutputStream out)
65
public void write(int c) throws IOException
67
byte[] bytes = new byte[1];
72
public void write(byte[]bytes) throws IOException
74
write(bytes, 0, bytes.length);
80
public void write(byte[]bytes, int off, int len) throws IOException
82
byte[] wrapped = sasl.wrap(bytes, off, len);
83
super.write(wrapped, 0, wrapped.length);