# HG changeset patch # User Jaroslav Tulach # Date 1213429906 -7200 # Node ID 8f9ed9c4a97b9af1d019fdc694b21e4054384123 # Parent 1b1a4a203bf26b5c7c22ddce337a780a9557def2 spi part diff -r 1b1a4a203bf2 -r 8f9ed9c4a97b samples/messagedigest/src/api/Digest.java --- a/samples/messagedigest/src/api/Digest.java Sat Jun 14 09:51:45 2008 +0200 +++ b/samples/messagedigest/src/api/Digest.java Sat Jun 14 09:51:46 2008 +0200 @@ -1,13 +1,19 @@ package api; +import java.nio.ByteBuffer; +import spi.DigestImplementation; + /** MessageDigest extends MessageDigestSpi, that means the javadoc * * @author Jaroslav Tulach */ public final class Digest { + private final DigestImplementation impl; + /** Factory method is better than constructor */ - private Digest() { + private Digest(DigestImplementation impl) { + this.impl = impl; } /** Factory method to create digest for an algorithm. @@ -16,6 +22,13 @@ return null; } + // + // these methods are kept the same as in original MessageDigest, + // but for simplicity choose just some from the original API + // + public byte[] digest(ByteBuffer bb) { + return null; + } } diff -r 1b1a4a203bf2 -r 8f9ed9c4a97b samples/messagedigest/src/spi/DigestImplementation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/messagedigest/src/spi/DigestImplementation.java Sat Jun 14 09:51:46 2008 +0200 @@ -0,0 +1,23 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package spi; + +import java.nio.ByteBuffer; + +/** + * + * @author Jaroslav Tulach + */ +public abstract class DigestImplementation { + final String name; + + protected DigestImplementation(String algorithm) { + this.name = algorithm; + } + + protected abstract void update(ByteBuffer bb); + protected abstract byte[] digest(); +}