1.1 --- a/samples/messagedigest/src-new-api/org/apidesign/api/security/Digest.java Sat Jun 14 09:52:26 2008 +0200
1.2 +++ b/samples/messagedigest/src-new-api/org/apidesign/api/security/Digest.java Sat Jun 14 09:52:26 2008 +0200
1.3 @@ -2,28 +2,28 @@
1.4 package org.apidesign.api.security;
1.5
1.6 import java.nio.ByteBuffer;
1.7 -import org.apidesign.impl.security.friendapi.DigestImplementation;
1.8 -import org.apidesign.impl.security.friendapi.DigestProvider;
1.9 import java.util.ServiceLoader;
1.10 +import org.apidesign.spi.security.Digestor;
1.11
1.12 -/** MessageDigest extends MessageDigestSpi, that means the javadoc
1.13 +/** Simplified version of a Digest class that allows to compute a fingerprint
1.14 + * for buffer of data.
1.15 *
1.16 - * @author Jaroslav Tulach
1.17 + * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.18 */
1.19 // BEGIN: day.end.bridges.Digest
1.20 public final class Digest {
1.21 - private final DigestImplementation impl;
1.22 + private final DigestImplementation<?> impl;
1.23
1.24 /** Factory method is better than constructor */
1.25 - private Digest(DigestImplementation impl) {
1.26 + private Digest(DigestImplementation<?> impl) {
1.27 this.impl = impl;
1.28 }
1.29
1.30 /** Factory method to create digest for an algorithm.
1.31 */
1.32 public static Digest getInstance(String algorithm) {
1.33 - for (DigestProvider dp : ServiceLoader.load(DigestProvider.class)) {
1.34 - DigestImplementation impl = dp.create(algorithm);
1.35 + for (Digestor<?> digestor : ServiceLoader.load(Digestor.class)) {
1.36 + DigestImplementation<?> impl = DigestImplementation.create(digestor, algorithm);
1.37 if (impl != null) {
1.38 return new Digest(impl);
1.39 }
1.40 @@ -37,8 +37,7 @@
1.41 //
1.42
1.43 public byte[] digest(ByteBuffer bb) {
1.44 - impl.update(bb);
1.45 - return impl.digest();
1.46 + return impl.digest(bb);
1.47 }
1.48 }
1.49 // END: day.end.bridges.Digest