Use local copy of latest bndlib code for pre-release testing purposes
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1347815 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java
new file mode 100644
index 0000000..5218e2d
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java
@@ -0,0 +1,41 @@
+package aQute.libg.cryptography;
+
+import java.io.*;
+import java.security.*;
+
+public class Signer<D extends Digest> extends OutputStream {
+ Signature signature;
+ Digester<D> digester;
+
+ Signer(Signature s, Digester<D> digester) {
+ this.signature = s;
+ this.digester = digester;
+ }
+
+ @Override public void write(byte[] buffer, int offset, int length) throws IOException {
+ try {
+ signature.update(buffer, offset, length);
+ digester.write(buffer, offset, length);
+ } catch (SignatureException e) {
+ throw new IOException(e.getLocalizedMessage());
+ }
+ }
+
+ @Override public void write(int b) throws IOException {
+ try {
+ signature.update((byte) b);
+ digester.write(b);
+ } catch (SignatureException e) {
+ throw new IOException(e.getLocalizedMessage());
+ }
+ }
+
+
+ public Signature signature() throws Exception {
+ return signature;
+ }
+
+ public D digest() throws Exception {
+ return digester.digest();
+ }
+}