author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:52:23 +0200 | |
changeset 46 | c75861f07646 |
child 47 | f464a16d553a |
permissions | -rw-r--r-- |
jtulach@46 | 1 |
/* |
jtulach@46 | 2 |
* To change this template, choose Tools | Templates |
jtulach@46 | 3 |
* and open the template in the editor. |
jtulach@46 | 4 |
*/ |
jtulach@46 | 5 |
|
jtulach@46 | 6 |
package org.apidesign.impl.security.extension; |
jtulach@46 | 7 |
|
jtulach@46 | 8 |
import org.apidesign.impl.security.friendapi.DigestImplementation; |
jtulach@46 | 9 |
import org.apidesign.impl.security.friendapi.DigestProvider; |
jtulach@46 | 10 |
import java.nio.ByteBuffer; |
jtulach@46 | 11 |
import java.security.MessageDigest; |
jtulach@46 | 12 |
import java.security.NoSuchAlgorithmException; |
jtulach@46 | 13 |
import java.util.logging.Level; |
jtulach@46 | 14 |
import java.util.logging.Logger; |
jtulach@46 | 15 |
|
jtulach@46 | 16 |
/** |
jtulach@46 | 17 |
* |
jtulach@46 | 18 |
* @author Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jtulach@46 | 19 |
*/ |
jtulach@46 | 20 |
// BEGIN: day.end.bridges.BridgeToNew |
jtulach@46 | 21 |
public class BridgeToNew implements DigestProvider { |
jtulach@46 | 22 |
|
jtulach@46 | 23 |
public DigestImplementation create(String algorithm) { |
jtulach@46 | 24 |
try { |
jtulach@46 | 25 |
final MessageDigest md = MessageDigest.getInstance(algorithm); |
jtulach@46 | 26 |
return new DigestImplementation(algorithm) { |
jtulach@46 | 27 |
|
jtulach@46 | 28 |
@Override |
jtulach@46 | 29 |
public void update(ByteBuffer bb) { |
jtulach@46 | 30 |
md.update(bb); |
jtulach@46 | 31 |
} |
jtulach@46 | 32 |
|
jtulach@46 | 33 |
@Override |
jtulach@46 | 34 |
public byte[] digest() { |
jtulach@46 | 35 |
return md.digest(); |
jtulach@46 | 36 |
} |
jtulach@46 | 37 |
}; |
jtulach@46 | 38 |
} catch (NoSuchAlgorithmException ex) { |
jtulach@46 | 39 |
Logger.getLogger(BridgeToNew.class.getName()).log(Level.INFO, null, ex); |
jtulach@46 | 40 |
return null; |
jtulach@46 | 41 |
} |
jtulach@46 | 42 |
} |
jtulach@46 | 43 |
} |
jtulach@46 | 44 |
// END: day.end.bridges.BridgeToNew |