01: /*
02: * reserved comment block
03: * DO NOT REMOVE OR ALTER!
04: */
05: /*
06: * Copyright 1999-2005 The Apache Software Foundation.
07: *
08: * Licensed under the Apache License, Version 2.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: */
21: package org.jcp.xml.dsig.internal;
22:
23: import java.io.ByteArrayOutputStream;
24: import javax.crypto.Mac;
25:
26: /**
27: * Derived from Apache sources and changed to use Mac objects
28: * objects instead of org.apache.xml.security.algorithms.SignatureAlgorithm
29: * objects.
30: *
31: * @author raul
32: *
33: */
34: public class MacOutputStream extends ByteArrayOutputStream {
35: private final static byte none[] = "error".getBytes();
36: private final Mac mac;
37:
38: public MacOutputStream(Mac mac) {
39: this .mac = mac;
40: }
41:
42: /** @inheritDoc */
43: public byte[] toByteArray() {
44: return none;
45: }
46:
47: /** @inheritDoc */
48: public void write(byte[] arg0) {
49: mac.update(arg0);
50: }
51:
52: /** @inheritDoc */
53: public void write(int arg0) {
54: mac.update((byte) arg0);
55: }
56:
57: /** @inheritDoc */
58: public void write(byte[] arg0, int arg1, int arg2) {
59: mac.update(arg0, arg1, arg2);
60: }
61: }
|