jdk/src/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java
changeset 1337 e8d6cef36199
parent 2 90ce3da70b43
child 18780 f47b920867e7
equal deleted inserted replaced
1334:21b652819b97 1337:e8d6cef36199
    22 
    22 
    23 import java.io.ByteArrayOutputStream;
    23 import java.io.ByteArrayOutputStream;
    24 import javax.crypto.Mac;
    24 import javax.crypto.Mac;
    25 
    25 
    26 /**
    26 /**
    27  * Derived from Apache sources and changed to use Mac objects
    27  * Derived from Apache sources and changed to use Mac objects instead of
    28  * objects instead of org.apache.xml.security.algorithms.SignatureAlgorithm
    28  * com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm objects.
    29  * objects.
       
    30  *
    29  *
    31  * @author raul
    30  * @author raul
       
    31  * @author Sean Mullan
    32  *
    32  *
    33  */
    33  */
    34 public class MacOutputStream extends ByteArrayOutputStream {
    34 public class MacOutputStream extends ByteArrayOutputStream {
    35     private final static byte none[]="error".getBytes();
       
    36     private final Mac mac;
    35     private final Mac mac;
    37 
    36 
    38     public MacOutputStream(Mac mac) {
    37     public MacOutputStream(Mac mac) {
    39         this.mac = mac;
    38         this.mac = mac;
    40     }
    39     }
    41 
    40 
    42     /** @inheritDoc */
    41     /** @inheritDoc */
    43     public byte[] toByteArray() {
       
    44         return none;
       
    45     }
       
    46 
       
    47     /** @inheritDoc */
       
    48     public void write(byte[] arg0)  {
    42     public void write(byte[] arg0)  {
       
    43         super.write(arg0, 0, arg0.length);
    49         mac.update(arg0);
    44         mac.update(arg0);
    50     }
    45     }
    51 
    46 
    52     /** @inheritDoc */
    47     /** @inheritDoc */
    53     public void write(int arg0) {
    48     public void write(int arg0) {
    54         mac.update((byte)arg0);
    49         super.write(arg0);
       
    50         mac.update((byte) arg0);
    55     }
    51     }
    56 
    52 
    57     /** @inheritDoc */
    53     /** @inheritDoc */
    58     public void write(byte[] arg0, int arg1, int arg2) {
    54     public void write(byte[] arg0, int arg1, int arg2) {
    59         mac.update(arg0,arg1,arg2);
    55         super.write(arg0, arg1, arg2);
       
    56         mac.update(arg0, arg1, arg2);
    60     }
    57     }
    61 }
    58 }