01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the License). You may not use this file except in
05: * compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * Header Notice in each file and include the License file
14: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
15: * If applicable, add the following below the CDDL Header,
16: * with the fields enclosed by brackets [] replaced by
17: * you own identifying information:
18: * "Portions Copyrighted [year] [name of copyright owner]"
19: *
20: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
21: */
22:
23: package com.sun.xml.ws.security.opt.impl.util;
24:
25: import com.sun.xml.wss.impl.misc.Base64;
26: import java.io.IOException;
27: import java.io.OutputStream;
28:
29: /**
30: *
31: * @author K.Venugopal@sun.com
32: */
33: public class Base64OutputStream extends java.io.OutputStream {
34:
35: private OutputStream os;
36:
37: /** Creates a new instance of Base64OutputStream */
38: public Base64OutputStream(OutputStream os) {
39: this .os = os;
40: }
41:
42: public void write(byte[] b, int off, int len) throws IOException {
43: Base64.encodeToStream(b, off, len, os);
44: }
45:
46: public void write(byte[] b) throws IOException {
47: //Base64.encodeToStream(b,0,b.length,os);
48: String data = Base64.encode(b);
49: os.write(data.getBytes());
50: }
51:
52: public void write(int b) throws IOException {
53: os.write(b);
54: }
55:
56: }
|