KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > utils > SignerOutputStream


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 package com.sun.org.apache.xml.internal.security.utils;
18
19 import java.io.ByteArrayOutputStream JavaDoc;
20
21 import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm;
22 import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
23
24 /**
25  * @author raul
26  *
27  */

28 public class SignerOutputStream extends ByteArrayOutputStream JavaDoc {
29     final static byte none[]="error".getBytes();
30     final SignatureAlgorithm sa;
31     /**
32      * @param sa
33      */

34     public SignerOutputStream(SignatureAlgorithm sa) {
35         this.sa=sa;
36     }
37
38     /** @inheritDoc */
39     public byte[] toByteArray() {
40         return none;
41     }
42     
43     /** @inheritDoc */
44     public void write(byte[] arg0) {
45         try {
46             sa.update(arg0);
47         } catch (XMLSignatureException e) {
48             throw new RuntimeException JavaDoc(""+e);
49         }
50     }
51     
52     /** @inheritDoc */
53     public void write(int arg0) {
54         try {
55             sa.update((byte)arg0);
56         } catch (XMLSignatureException e) {
57             throw new RuntimeException JavaDoc(""+e);
58         }
59     }
60     
61     /** @inheritDoc */
62     public void write(byte[] arg0, int arg1, int arg2) {
63         try {
64             sa.update(arg0,arg1,arg2);
65         } catch (XMLSignatureException e) {
66             throw new RuntimeException JavaDoc(""+e);
67         }
68     }
69     
70
71 }
72
Popular Tags