org.apache.james.jdkim
Class DKIMSigner

java.lang.Object
  extended by org.apache.james.jdkim.DKIMCommon
      extended by org.apache.james.jdkim.DKIMSigner

public class DKIMSigner
extends DKIMCommon


Constructor Summary
DKIMSigner(String signatureRecordTemplate, PrivateKey privateKey)
           
 
Method Summary
static PrivateKey getPrivateKey(String privateKeyPKCS8)
          Generate a PrivateKey from a Base64 encoded private key.
 BodyHasher newBodyHasher(SignatureRecord signRecord)
           
 SignatureRecord newSignatureRecordTemplate(String record)
           
 String sign(Headers message, BodyHasher bhj)
           
 String sign(InputStream is)
           
 
Methods inherited from class org.apache.james.jdkim.DKIMCommon
signatureCheck, streamCopy, updateSignature
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DKIMSigner

public DKIMSigner(String signatureRecordTemplate,
                  PrivateKey privateKey)
Method Detail

newSignatureRecordTemplate

public SignatureRecord newSignatureRecordTemplate(String record)

newBodyHasher

public BodyHasher newBodyHasher(SignatureRecord signRecord)
                         throws PermFailException
Throws:
PermFailException

sign

public String sign(InputStream is)
            throws IOException,
                   FailException
Throws:
IOException
FailException

sign

public String sign(Headers message,
                   BodyHasher bhj)
            throws PermFailException
Throws:
PermFailException

getPrivateKey

public static PrivateKey getPrivateKey(String privateKeyPKCS8)
                                throws NoSuchAlgorithmException,
                                       InvalidKeySpecException
Generate a PrivateKey from a Base64 encoded private key. In order to generate a valid PKCS8 key when you have a PEM key you can do this: openssl pkcs8 -topk8 -inform PEM -in rsapriv.pem -outform DER -nocrypt -out rsapriv.der And then base64 encode the content.

Parameters:
privateKeyPKCS8 - a Base64 encoded string of the RSA key in PKCS8 format
Returns:
the PrivateKey
Throws:
NoSuchAlgorithmException - if RSA is unknown
InvalidKeySpecException - on bad input key


Copyright © 2008-2009 The Apache Software Foundation. All Rights Reserved.