2
|
1 |
/*
|
|
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 |
*/
|
|
21 |
package org.jcp.xml.dsig.internal;
|
|
22 |
|
|
23 |
import java.io.ByteArrayOutputStream;
|
|
24 |
import javax.crypto.Mac;
|
|
25 |
|
|
26 |
/**
|
1337
|
27 |
* Derived from Apache sources and changed to use Mac objects instead of
|
|
28 |
* com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm objects.
|
2
|
29 |
*
|
|
30 |
* @author raul
|
1337
|
31 |
* @author Sean Mullan
|
2
|
32 |
*
|
|
33 |
*/
|
|
34 |
public class MacOutputStream extends ByteArrayOutputStream {
|
|
35 |
private final Mac mac;
|
|
36 |
|
|
37 |
public MacOutputStream(Mac mac) {
|
|
38 |
this.mac = mac;
|
|
39 |
}
|
|
40 |
|
|
41 |
/** @inheritDoc */
|
|
42 |
public void write(byte[] arg0) {
|
1337
|
43 |
super.write(arg0, 0, arg0.length);
|
2
|
44 |
mac.update(arg0);
|
|
45 |
}
|
|
46 |
|
|
47 |
/** @inheritDoc */
|
|
48 |
public void write(int arg0) {
|
1337
|
49 |
super.write(arg0);
|
|
50 |
mac.update((byte) arg0);
|
2
|
51 |
}
|
|
52 |
|
|
53 |
/** @inheritDoc */
|
|
54 |
public void write(byte[] arg0, int arg1, int arg2) {
|
1337
|
55 |
super.write(arg0, arg1, arg2);
|
|
56 |
mac.update(arg0, arg1, arg2);
|
2
|
57 |
}
|
|
58 |
}
|