mail.node.crypt
Class MyCryptEngine

java.lang.Object
  extended by mail.node.crypt.CryptEngine
      extended by mail.node.crypt.MyCryptEngine

public class MyCryptEngine
extends CryptEngine

To get this running, download the
Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 5.0
from http://java.sun.com/javase/downloads/index_jdk5.jsp
You will also need org.apache-xml.security-1.4.1, but you will not need bouncy castle, because the java6 comes with jce already.

Author:
Arne Müller

Field Summary
(package private)  EncSupply enc
           
(package private)  java.security.KeyStore k
           
(package private)  java.security.PublicKey pubkey
           
 
Constructor Summary
MyCryptEngine(EncSupply enc)
           
 
Method Summary
 boolean checkSignature(org.w3c.dom.Element data)
          decodes the signature with the public key and then checks it
 void decrypt(org.w3c.dom.Element data)
          decrypt data with the private key The document that contains the Element will be modified!
 void encrypt(org.w3c.dom.Element data)
          encrypt data with the public key The document that contains the Element will be modified!
private static javax.crypto.SecretKey generateDataEncryptionKey()
          Get a key to be used for encrypting the element.
 byte[] getPublicKey()
           
 java.lang.String getPublicKeyString()
           
private static void print(org.w3c.dom.Document d)
           
 void sign(org.w3c.dom.Element data)
          sign data with the private key The document that contains the Element will be modified!
 
Methods inherited from class mail.node.crypt.CryptEngine
fromHex, getID, getID, toHex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

k

java.security.KeyStore k

pubkey

java.security.PublicKey pubkey

enc

EncSupply enc
Constructor Detail

MyCryptEngine

public MyCryptEngine(EncSupply enc)
              throws EncSupplyException
Throws:
EncSupplyException
Method Detail

generateDataEncryptionKey

private static javax.crypto.SecretKey generateDataEncryptionKey()
                                                         throws java.lang.Exception
Get a key to be used for encrypting the element. Here we are generating an AES key.

Throws:
java.lang.Exception

decrypt

public void decrypt(org.w3c.dom.Element data)
             throws EncryptionException
Description copied from class: CryptEngine
decrypt data with the private key The document that contains the Element will be modified! Data will change!

Specified by:
decrypt in class CryptEngine
Parameters:
data - to be decrypted
Throws:
EncryptionException

encrypt

public void encrypt(org.w3c.dom.Element data)
             throws EncryptionException
Description copied from class: CryptEngine
encrypt data with the public key The document that contains the Element will be modified! Data will change! It won't be available afterwards

Specified by:
encrypt in class CryptEngine
Parameters:
data - to be encrypted
Throws:
EncryptionException

getPublicKey

public byte[] getPublicKey()
Specified by:
getPublicKey in class CryptEngine

getPublicKeyString

public java.lang.String getPublicKeyString()
Specified by:
getPublicKeyString in class CryptEngine

checkSignature

public boolean checkSignature(org.w3c.dom.Element data)
                       throws EncryptionException
Description copied from class: CryptEngine
decodes the signature with the public key and then checks it

Specified by:
checkSignature in class CryptEngine
Parameters:
data - to check
Returns:
true, if signature is ok
Throws:
EncryptionException

sign

public void sign(org.w3c.dom.Element data)
          throws EncryptionException
Description copied from class: CryptEngine
sign data with the private key The document that contains the Element will be modified! Data will be extended, but it will keep being a valid element.

Specified by:
sign in class CryptEngine
Parameters:
data - to be signed
Throws:
EncryptionException

print

private static void print(org.w3c.dom.Document d)
                   throws java.lang.Exception
Throws:
java.lang.Exception