author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:52:25 +0200 | |
changeset 47 | f464a16d553a |
parent 46 | c75861f07646 |
child 48 | c5742322dbc8 |
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 java.nio.ByteBuffer; |
jtulach@46 | 9 |
import java.security.MessageDigest; |
jtulach@46 | 10 |
import java.security.NoSuchAlgorithmException; |
jtulach@46 | 11 |
import java.util.logging.Level; |
jtulach@46 | 12 |
import java.util.logging.Logger; |
jtulach@47 | 13 |
import org.apidesign.spi.security.Digestor; |
jtulach@46 | 14 |
|
jtulach@46 | 15 |
/** |
jtulach@46 | 16 |
* |
jtulach@46 | 17 |
* @author Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jtulach@46 | 18 |
*/ |
jtulach@46 | 19 |
// BEGIN: day.end.bridges.BridgeToNew |
jtulach@47 | 20 |
public class BridgeToNew extends Digestor<MessageDigest> { |
jtulach@47 | 21 |
@Override |
jtulach@47 | 22 |
protected MessageDigest create(String algorithm) { |
jtulach@46 | 23 |
try { |
jtulach@47 | 24 |
return MessageDigest.getInstance(algorithm); |
jtulach@46 | 25 |
} catch (NoSuchAlgorithmException ex) { |
jtulach@47 | 26 |
Logger.getLogger(BridgeToNew.class.getName()).log(Level.FINE, "Cannot find " + algorithm, ex); |
jtulach@46 | 27 |
return null; |
jtulach@46 | 28 |
} |
jtulach@46 | 29 |
} |
jtulach@47 | 30 |
|
jtulach@47 | 31 |
@Override |
jtulach@47 | 32 |
protected byte[] digest(MessageDigest data) { |
jtulach@47 | 33 |
return data.digest(); |
jtulach@47 | 34 |
} |
jtulach@47 | 35 |
|
jtulach@47 | 36 |
@Override |
jtulach@47 | 37 |
protected void update(MessageDigest data, ByteBuffer input) { |
jtulach@47 | 38 |
data.update(input); |
jtulach@47 | 39 |
} |
jtulach@46 | 40 |
} |
jtulach@46 | 41 |
// END: day.end.bridges.BridgeToNew |