All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.libg.cryptography.Signer Maven / Gradle / Ivy

Go to download

The bndlib project is a general library to be used with OSGi bundles. It contains lots of cool functionality that calculates dependencies, etc.

There is a newer version: 2.4.0
Show newest version
package aQute.libg.cryptography;

import java.io.*;
import java.security.*;

public class Signer extends OutputStream {
	Signature	signature;
	Digester	digester;

	Signer(Signature s, Digester 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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy