01: /*
02: * Copyright 1999-2005 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: */
17:
18: /*
19: * The contents of this file are subject to the terms
20: * of the Common Development and Distribution License
21: * (the License). You may not use this file except in
22: * compliance with the License.
23: *
24: * You can obtain a copy of the license at
25: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
26: * See the License for the specific language governing
27: * permissions and limitations under the License.
28: *
29: * When distributing Covered Code, include this CDDL
30: * Header Notice in each file and include the License file
31: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
32: * If applicable, add the following below the CDDL Header,
33: * with the fields enclosed by brackets [] replaced by
34: * you own identifying information:
35: * "Portions Copyrighted [year] [name of copyright owner]"
36: *
37: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
38: */
39:
40: package com.sun.xml.ws.security.opt.crypto.dsig.internal;
41:
42: import java.io.ByteArrayOutputStream;
43:
44: /**
45: * Derived from Apache sources and changed to use HmacSHA1 objects
46: * objects instead of org.apache.xml.security.algorithms.SignatureAlgorithm
47: * objects.
48: *
49: * @author raul
50: * @author Sean Mullan
51: *
52: */
53: public class MacOutputStream extends ByteArrayOutputStream {
54: private final static byte none[] = "error".getBytes();
55: private final HmacSHA1 mac;
56:
57: public MacOutputStream(HmacSHA1 mac) {
58: this .mac = mac;
59: }
60:
61: /** @inheritDoc */
62: public byte[] toByteArray() {
63: return none;
64: }
65:
66: /** @inheritDoc */
67: public void write(byte[] arg0) {
68: mac.update(arg0);
69: }
70:
71: /** @inheritDoc */
72: public void write(int arg0) {
73: mac.update((byte) arg0);
74: }
75:
76: /** @inheritDoc */
77: public void write(byte[] arg0, int arg1, int arg2) {
78: mac.update(arg0, arg1, arg2);
79: }
80: }
|