01: /*
02: * $Id: ApplicationCanonicalizer.java,v 1.4 2007/01/08 09:28:48 ashutoshshahi Exp $
03: * $Revision: 1.4 $
04: * $Date: 2007/01/08 09:28:48 $
05: */
06:
07: /*
08: * The contents of this file are subject to the terms
09: * of the Common Development and Distribution License
10: * (the License). You may not use this file except in
11: * compliance with the License.
12: *
13: * You can obtain a copy of the license at
14: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
15: * See the License for the specific language governing
16: * permissions and limitations under the License.
17: *
18: * When distributing Covered Code, include this CDDL
19: * Header Notice in each file and include the License file
20: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
21: * If applicable, add the following below the CDDL Header,
22: * with the fields enclosed by brackets [] replaced by
23: * you own identifying information:
24: * "Portions Copyrighted [year] [name of copyright owner]"
25: *
26: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
27: */
28:
29: package com.sun.xml.wss.impl.c14n;
30:
31: import com.sun.xml.wss.XWSSecurityException;
32: import java.io.InputStream;
33: import java.io.OutputStream;
34:
35: import java.util.logging.Level;
36:
37: /**
38: * Canoncializer for an Application Media Type.
39: * This should work for all application/** MIME types.
40: *
41: * @author XWS-Security Team
42: */
43: public class ApplicationCanonicalizer extends Canonicalizer {
44:
45: public ApplicationCanonicalizer() {
46: }
47:
48: public ApplicationCanonicalizer(String charset) {
49: super (charset);
50: }
51:
52: public byte[] canonicalize(byte[] input)
53: throws XWSSecurityException {
54: return input;
55: }
56:
57: public InputStream canonicalize(InputStream input,
58: OutputStream outputStream)
59: throws javax.xml.crypto.dsig.TransformException {
60: try {
61: if (outputStream == null) {
62: return input;
63: } else {
64: byte[] data = new byte[128];
65: while (true) {
66: int len = input.read(data);
67: if (len <= 0)
68: break;
69: outputStream.write(data, 0, len);
70: }
71: }
72: return null;
73: } catch (Exception ex) {
74: log.log(Level.SEVERE, "WSS1000.error.canonicalizing",
75: new Object[] { ex.getMessage() });
76: throw new javax.xml.crypto.dsig.TransformException(ex
77: .getMessage());
78: }
79: }
80: }
|