public class DkimSigner extends Object
| Constructor and Description |
|---|
DkimSigner(String signingDomain,
String selector,
File derFile)
Created a new
DkimSigner for the given signing domain and
selector with the given DER encoded RSA private Key. |
DkimSigner(String signingDomain,
String selector,
InputStream derStream)
Created a new
DkimSigner for the given signing domain and
selector with the given DER encoded RSA private Key. |
DkimSigner(String signingDomain,
String selector,
RSAPrivateKey privateKey)
Created a new
DkimSigner for the given signing domain and
selector with the given RSAPrivateKey. |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeaderToSign(String header)
Adds a header to the set of headers that will be included in the
signature, if present.
|
Canonicalization |
getBodyCanonicalization()
Returns the configured
Canonicalization to be used for the body. |
Canonicalization |
getHeaderCanonicalization()
Returns the configured
Canonicalization to be used for the
headers. |
String |
getIdentity()
Returns the configured identity parameter.
|
boolean |
getLengthParam()
Returns the configured length parameter.
|
SigningAlgorithm |
getSigningAlgorithm()
Returns the configured
SigningAlgorithm. |
boolean |
isCheckDomainKey()
Returns whether the domain key should be retrieved and checked.
|
boolean |
isZParam()
Returns the configured z parameter.
|
void |
removeHeaderToSign(String header)
Removes a header from the set of headers that will be included in the
signature, unless it is one of the required headers ('From', 'To',
'Subject').
|
void |
setBodyCanonicalization(Canonicalization canonicalization)
Sets the
Canonicalization to be used for the body. |
void |
setCheckDomainKey(boolean checkDomainKey)
Sets, whether the domain key should be retrieved and checked.
|
void |
setHeaderCanonicalization(Canonicalization canonicalization)
Sets the
Canonicalization to be used for the headers. |
void |
setIdentity(String identity)
Sets the identity parameter to be used.
|
void |
setLengthParam(boolean lengthParam)
Sets the length parameter to be used.
|
void |
setSigningAlgorithm(SigningAlgorithm signingAlgorithm)
Sets the
SigningAlgorithm to be used. |
void |
setZParam(boolean zParam)
Sets the z parameter to be used.
|
protected String |
sign(DkimMessage message)
Returns the DKIM signature header line.
|
public DkimSigner(String signingDomain, String selector, RSAPrivateKey privateKey) throws DkimException
DkimSigner for the given signing domain and
selector with the given RSAPrivateKey.signingDomain - The signing domain to be used.selector - The selector to be used.privateKey - The RSAPrivateKey to be used to sign
DkimMessages.DkimException - If the given signing domain is invalid.public DkimSigner(String signingDomain, String selector, File derFile) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, DkimException
DkimSigner for the given signing domain and
selector with the given DER encoded RSA private Key.signingDomain - The signing domain to be used.selector - The selector to be used.derFile - A File that contains the DER encoded RSA private key
to be used.IOException - If reading the content of the given File failed.NoSuchAlgorithmException - If the RSA algorithm is not supported by the current JVM.InvalidKeySpecException - If the content of the given File couldn't be
interpreted as an RSA private key.DkimException - If the given signing domain is invalid.public DkimSigner(String signingDomain, String selector, InputStream derStream) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException
DkimSigner for the given signing domain and
selector with the given DER encoded RSA private Key.signingDomain - The signing domain to be used.selector - The selector to be used.derStream - A InputStream that yields the DER encoded RSA private
key to be used. The InputStream will be closed after
it has been read.IOException - If reading the content of the given InputStream
failed.NoSuchAlgorithmException - If the RSA algorithm is not supported by the current JVM.InvalidKeySpecException - If the content of the given InputStream couldn't be
interpreted as an RSA private key.DkimException - If the given signing domain is invalid.public String getIdentity()
public void setIdentity(String identity) throws DkimException
identity - The identity to be used.DkimException - If the given identity parameter doesn't belong to the signing
domain of this DkimSigner or an subdomain thereof.public Canonicalization getBodyCanonicalization()
Canonicalization to be used for the body.Canonicalization to be used for the body.public void setBodyCanonicalization(Canonicalization canonicalization)
Canonicalization to be used for the body.canonicalization - The Canonicalization to be used for the body.public Canonicalization getHeaderCanonicalization()
Canonicalization to be used for the
headers.Canonicalization to be used for the
headers.public void setHeaderCanonicalization(Canonicalization canonicalization)
Canonicalization to be used for the headers.canonicalization - The Canonicalization to be used for the headers.public void addHeaderToSign(String header)
header - The name of the header.public void removeHeaderToSign(String header)
header - The name of the header.public boolean getLengthParam()
public void setLengthParam(boolean lengthParam)
lengthParam - The length parameter to be used.public boolean isZParam()
public void setZParam(boolean zParam)
zParam - The z parameter to be used.public SigningAlgorithm getSigningAlgorithm()
SigningAlgorithm.SigningAlgorithm.public void setSigningAlgorithm(SigningAlgorithm signingAlgorithm) throws DkimException
SigningAlgorithm to be used.signingAlgorithm - The SigningAlgorithm to be used.DkimException - If either the signing algorithm or the hashing algorithm is
not supported by the current JVM or the Signature
couldn't be initialized.public boolean isCheckDomainKey()
DomainKey.check(String, RSAPrivateKey)public void setCheckDomainKey(boolean checkDomainKey)
checkDomainKey - Whether the domain key should be retrieved and checked.protected String sign(DkimMessage message) throws DkimSigningException
message - The DkimMessage to sign.DkimSigningException - If the given DkimMessage couldnt't be signed.Copyright © 2015–2018 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.