...
Code Block | ||
---|---|---|
| ||
class SignSealUtility<E,V> implements Serializable { final static long serialVersionUID = 2648720192864531932L; private HashMap<E,V> ssnMap; private SealedObject sealedSsnMap; private SignedObject signedSsnMap; public SignSealUtility() { ssnMap = new HashMap<E,V>(); } public void seal(Cipher cipher) throws Exception { sealedSsnMap = new SealedObject(ssnMap, cipher); // Now set the Map to null so that original data does not remain in cleartext ssnMap = null; } public void unseal(Cipher cipher) throws Exception { ssnMap = (HashMap<E,V>)sealedSsnMap.getObject(cipher); } public void sign(Signature sig, PrivateKey key) throws Exception { signedSsnMap = new SignedObject(ssnMap, key, sig); ssnMap = null; } public void unsign(Signature sig, PublicKey key) throws Exception { if(signedSsnMap.verify(key, sig)) { ssnMap = (HashMap<E,V>)signedSsnMap.getObject(); } } public Object getdata(ObjectE key) throws Exception { return ssnMap.get(key); } public void setData(E key, V data) throws Exception { ssnMap.put(key, data); } } |
...