author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:52:23 +0200 | |
changeset 44 | 716af5f2ebd1 |
permissions | -rw-r--r-- |
jtulach@44 | 1 |
/* |
jtulach@44 | 2 |
* To change this template, choose Tools | Templates |
jtulach@44 | 3 |
* and open the template in the editor. |
jtulach@44 | 4 |
*/ |
jtulach@44 | 5 |
|
jtulach@44 | 6 |
package org.apidesign.impl.security.spi; |
jtulach@44 | 7 |
|
jtulach@44 | 8 |
import java.nio.ByteBuffer; |
jtulach@44 | 9 |
import org.apidesign.spi.security.Digestor; |
jtulach@44 | 10 |
|
jtulach@44 | 11 |
/** |
jtulach@44 | 12 |
* |
jtulach@44 | 13 |
* @author jarda |
jtulach@44 | 14 |
*/ |
jtulach@44 | 15 |
public abstract class DigestorAccessor { |
jtulach@44 | 16 |
private static DigestorAccessor INSTANCE; |
jtulach@44 | 17 |
|
jtulach@44 | 18 |
protected DigestorAccessor() { |
jtulach@44 | 19 |
assert INSTANCE == null; |
jtulach@44 | 20 |
INSTANCE = this; |
jtulach@44 | 21 |
} |
jtulach@44 | 22 |
|
jtulach@44 | 23 |
public static DigestorAccessor getDefault() { |
jtulach@44 | 24 |
try { |
jtulach@44 | 25 |
Class.forName(Digestor.class.getName(), true, DigestorAccessor.class.getClassLoader()); |
jtulach@44 | 26 |
return INSTANCE; |
jtulach@44 | 27 |
} catch (ClassNotFoundException ex) { |
jtulach@44 | 28 |
throw new IllegalStateException(ex); |
jtulach@44 | 29 |
} |
jtulach@44 | 30 |
} |
jtulach@44 | 31 |
|
jtulach@44 | 32 |
protected abstract <Data> byte[] digest(Digestor<Data> dig, Data data); |
jtulach@44 | 33 |
protected abstract <Data> Data create(Digestor<Data> dig, String algorithm); |
jtulach@44 | 34 |
protected abstract <Data> void update(Digestor<Data> dig, Data data, ByteBuffer input); |
jtulach@44 | 35 |
} |