public class DKIMSignature extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ALGORITHM |
protected Map<String,String> |
attributes |
static String |
BODY_HASH |
protected boolean |
bodyHashRequired |
static String |
CANONICALIZATION |
static String |
DEFAULT_ALGORITHM
This is settable
|
static String |
DEFAULT_SIGNER
This is settable
|
static String |
DKIM_SIGNATURE |
static String |
DOMAIN |
static String |
EXPIRATION |
protected List<String> |
headers |
static String |
HEADERS |
protected String |
headerValue |
static String |
IDENTITY |
static String |
LENGTH |
protected PrivateKey |
privateKey |
static String |
QUERY |
static String |
SELECTOR |
static String |
SHA256WITH_RSA |
protected byte[] |
signature |
static String |
SIGNATURE |
static String |
TIMESTAMP |
static String |
VERSION |
Constructor and Description |
---|
DKIMSignature() |
DKIMSignature(Map<String,String> attrs) |
DKIMSignature(String headerValue) |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(String headerName)
Add a reference to a header within the signature calculation
|
protected void |
extractAttributes() |
String |
getAlgorithm() |
Map<String,String> |
getAttributes() |
String |
getBased64Signature() |
String |
getDomain() |
List<String> |
getHeaderList() |
String |
getId() |
PrivateKey |
getPrivateKey()
Private key to use to sign the message.
|
String |
getQuery() |
String |
getSelector() |
byte[] |
getSignature() |
boolean |
isBodyHashRequired()
Whether or not to add a body hash to signature
|
boolean |
isExpired()
Return false if true current time.
|
boolean |
isStale(int seconds,
int minutes,
int hours,
int days,
int months,
int years)
Returns false if timestamp does not exist or if the current time is
greater than timestamp + variables
|
void |
setAlgorithm(String value)
Default value is SHA256withRSA, see Javadoc on java.security.Signature for other supported values.
|
void |
setAttribute(String name,
String value) |
void |
setBase64Signature(String signature) |
void |
setBodyHashRequired(boolean bodyHashRequired) |
void |
setDomain(String domain) |
void |
setExpiration(Date expire) |
void |
setExpiration(int seconds,
int minutes,
int hours,
int days,
int months,
int years)
Calculates an expiration date based on the current time plus the additional time units specified in the
method parameters.
|
void |
setId(String id) |
void |
setPrivateKey(PrivateKey privateKey) |
void |
setQuery(String query) |
void |
setSelector(String selector) |
void |
setSignature(byte[] signature) |
void |
setTimestamp() |
void |
setTimestamp(String value) |
void |
sign(Map headers,
byte[] body,
PrivateKey defaultKey)
Headers can be a Map
|
String |
toString()
Generates the Content-Signature value.
|
MultivaluedMap<String,String> |
verify(boolean bodyHashRequired,
Map headers,
byte[] body,
PublicKey key)
Headers can be a Map
|
MultivaluedMap<String,String> |
verify(Map headers,
byte[] body,
PublicKey key) |
public static final String DKIM_SIGNATURE
public static final String TIMESTAMP
public static final String DOMAIN
public static final String EXPIRATION
public static final String ALGORITHM
public static final String SIGNATURE
public static final String HEADERS
public static final String IDENTITY
public static final String VERSION
public static final String BODY_HASH
public static final String CANONICALIZATION
public static final String QUERY
public static final String SELECTOR
public static final String LENGTH
public static String DEFAULT_SIGNER
public static final String SHA256WITH_RSA
public static String DEFAULT_ALGORITHM
protected PrivateKey privateKey
protected byte[] signature
protected String headerValue
protected boolean bodyHashRequired
public DKIMSignature()
public DKIMSignature(String headerValue)
protected void extractAttributes()
public String toString()
public boolean isBodyHashRequired()
public void setBodyHashRequired(boolean bodyHashRequired)
public void addHeader(String headerName)
headerName
- public void setAttribute(String name, String value)
name
- value
- if null, remove attributeincludeSignature
- true if you want attribute to be included within the signature calculationdisplay
- true if you want attribute shown in the Content-Signaturepublic void setAlgorithm(String value)
value
- includeSignature
- true if you want attribute to be included within the signature calculationdisplay
- true if you want attribute shown in the Content-Signaturepublic void setTimestamp(String value)
public void setTimestamp()
public void setSelector(String selector)
public String getSelector()
public String getQuery()
public void setQuery(String query)
public void setDomain(String domain)
public String getDomain()
public void setId(String id)
value
- public void setExpiration(Date expire)
public void setExpiration(int seconds, int minutes, int hours, int days, int months, int years)
seconds
- minutes
- hours
- days
- months
- years
- public boolean isExpired()
public boolean isStale(int seconds, int minutes, int hours, int days, int months, int years)
public String getId()
public String getAlgorithm()
public String getBased64Signature()
public void setBase64Signature(String signature)
public byte[] getSignature()
public void setSignature(byte[] signature)
public PrivateKey getPrivateKey()
public void setPrivateKey(PrivateKey privateKey)
public void sign(Map headers, byte[] body, PrivateKey defaultKey) throws SignatureException
headers
- body
- if null, bh field will not be set or provideddefaultKey
- will be used if privateKey is nullGeneralSecurityException
SignatureException
public MultivaluedMap<String,String> verify(Map headers, byte[] body, PublicKey key) throws SignatureException
SignatureException
public MultivaluedMap<String,String> verify(boolean bodyHashRequired, Map headers, byte[] body, PublicKey key) throws SignatureException
headers
- body
- key
- SignatureException
Copyright © 2014. All Rights Reserved.