1 package net.sourceforge.jcetaglib.tools; 2 3 import java.io.FilterOutputStream ; 4 import java.io.IOException ; 5 import java.io.OutputStream ; 6 import java.security.Signature ; 7 import java.security.SignatureException ; 8 9 10 14 15 16 public class SignatureOutputStream 17 extends FilterOutputStream { 18 private Signature sig = null; 19 20 public SignatureOutputStream(OutputStream out, 21 Signature sig) { 22 super(out); 23 this.sig = sig; 24 } 25 26 public void write(int b) 27 throws IOException { 28 try { 29 sig.update((byte) b); 30 } catch (SignatureException s_ex) { 31 throw new IOException (s_ex.getMessage()); 32 } 33 out.write(b); 34 } 35 36 public void write(byte[] b) 37 throws IOException { 38 try { 39 sig.update(b); 40 } catch (SignatureException s_ex) { 41 throw new IOException (s_ex.getMessage()); 42 } 43 44 out.write(b); 45 } 46 47 public void write(byte[] b, 48 int o, 49 int l) 50 throws IOException { 51 try { 52 sig.update(b, o, l); 53 } catch (SignatureException s_ex) { 54 throw(new IOException (s_ex.getMessage())); 55 } 56 57 out.write(b, o, l); 58 } 59 } 60 61 | Popular Tags |