public class DKIMSigner extends java.lang.Object implements MailFilter
Sendmail
filter to sign the mail with a private key.
Mail mail = new Mail();
//fill in the mail
DKIMSigner signer = new DKIMSigner("domain.com", "dkim", "rsa.private.der");
Sendmail sendmail = new Sendmail(m.sFrom);
sendmail.registerFilter(signer);
sendmail.send(mail);
Sendmail.registerFilter(MailFilter)
Constructor and Description |
---|
DKIMSigner(java.lang.String sDomain,
java.lang.String sDNSSelector,
java.lang.String sKeyPath)
DKIM signer
|
Modifier and Type | Method and Description |
---|---|
boolean |
addHeader(java.lang.String sHeader)
Add another header to the signature
|
void |
clearHeader()
Remove all headers, start clean
|
void |
filter(java.util.Map<java.lang.String,java.lang.String> mailHeaders,
java.lang.String sBody,
Mail mail)
Filter the mail contents and the headers.
|
static java.lang.String |
relaxedHeader(java.lang.String key,
java.lang.String value)
Implement the "relaxed" method for headers
|
boolean |
removeHeader(java.lang.String sHeader)
Remove a header from the signature
|
static java.lang.String |
simpleBody(java.lang.String body)
Implement the "simple" method for body
|
public DKIMSigner(java.lang.String sDomain, java.lang.String sDNSSelector, java.lang.String sKeyPath) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException, java.security.InvalidKeyException
sDomain
- sDNSSelector
- sKeyPath
- path to the file containing the private RSA keyjava.io.IOException
- when the key file cannot be readjava.security.NoSuchAlgorithmException
- if the algorithm is unknownjava.security.spec.InvalidKeySpecException
- if the contents of the private key file is not okjava.security.InvalidKeyException
- when the signature cannot make use of the given private keypublic boolean addHeader(java.lang.String sHeader)
sHeader
- public boolean removeHeader(java.lang.String sHeader)
sHeader
- public void clearHeader()
public void filter(java.util.Map<java.lang.String,java.lang.String> mailHeaders, java.lang.String sBody, Mail mail)
MailFilter
filter
in interface MailFilter
mailHeaders
- full set of headers, just before sending them to the serversBody
- full mail bodymail
- the original mailpublic static java.lang.String relaxedHeader(java.lang.String key, java.lang.String value)
key
- header keyvalue
- valuepublic static java.lang.String simpleBody(java.lang.String body)
body
-