blob: 4161f4c1d3e06a47306079657dde85c76418ed12 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/*
6 * Copyright 1999-2005 The Apache Software Foundation.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * 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 */
21package org.jcp.xml.dsig.internal;
22
23import java.io.ByteArrayOutputStream;
24import 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 */
34public 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}