Package org.apache.james.jdkim
Class DKIMVerifier
- java.lang.Object
-
- org.apache.james.jdkim.DKIMCommon
-
- org.apache.james.jdkim.DKIMVerifier
-
- Direct Known Subclasses:
IscheduleDKIMVerifier
public class DKIMVerifier extends DKIMCommon
-
-
Field Summary
Fields Modifier and Type Field Description protected int
allowableFutureSeconds
-
Fields inherited from class org.apache.james.jdkim.DKIMCommon
deepDebug
-
-
Constructor Summary
Constructors Constructor Description DKIMVerifier()
DKIMVerifier(PublicKeyRecordRetriever publicKeyRecordRetriever)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addStoredKey(String domain, String selector, String key)
Save a stored key for private-exchangestatic void
apply(PublicKeyRecord pkr, SignatureRecord sign)
asserts applicability of a signature record the a public key record.static void
clearStoredKeys()
Clear any keys stored for private-exchangeprotected PublicKeyRecordRetriever
getPublicKeyRecordRetriever()
BodyHasher
newBodyHasher(Headers messageHeaders)
protected BodyHasherImpl
newBodyHasher(SignatureRecord signRecord)
protected PublicKeyRecord
newPublicKeyRecord(String record)
SignatureRecord
newSignatureRecord(String record)
PublicKeyRecord
publicKeySelector(List<String> records)
PublicKeyRecord
publicRecordLookup(SignatureRecord sign)
Iterates through signature's declared lookup methodList<SignatureRecord>
verify(InputStream is)
Verifies all of the DKIM-Signature records declared in the supplied input streamList<SignatureRecord>
verify(BodyHasher bh)
Completes the simultaneous verification of multiple signatures given the previously prepared compound body hasher where the user already written the body to the outputstream and closed it.List<SignatureRecord>
verify(Headers messageHeaders, InputStream bodyInputStream)
Verifies all of the DKIM-Signature records declared in the Headers object.-
Methods inherited from class org.apache.james.jdkim.DKIMCommon
debugMsg, signatureCheck, streamCopy, trace, updateSignature
-
-
-
-
Constructor Detail
-
DKIMVerifier
public DKIMVerifier()
-
DKIMVerifier
public DKIMVerifier(PublicKeyRecordRetriever publicKeyRecordRetriever)
-
-
Method Detail
-
clearStoredKeys
public static void clearStoredKeys()
Clear any keys stored for private-exchange
-
addStoredKey
public static void addStoredKey(String domain, String selector, String key)
Save a stored key for private-exchange- Parameters:
domain
- as per specselector
- as per speckey
- as per spec
-
newPublicKeyRecord
protected PublicKeyRecord newPublicKeyRecord(String record)
-
newSignatureRecord
public SignatureRecord newSignatureRecord(String record)
-
newBodyHasher
protected BodyHasherImpl newBodyHasher(SignatureRecord signRecord) throws PermFailException
- Throws:
PermFailException
-
getPublicKeyRecordRetriever
protected PublicKeyRecordRetriever getPublicKeyRecordRetriever() throws PermFailException
- Throws:
PermFailException
-
publicKeySelector
public PublicKeyRecord publicKeySelector(List<String> records) throws PermFailException
- Throws:
PermFailException
-
apply
public static void apply(PublicKeyRecord pkr, SignatureRecord sign) throws PermFailException
asserts applicability of a signature record the a public key record. throws an- Parameters:
pkr
- public key recordsign
- signature record- Throws:
PermFailException
- when the keys are not applicable
-
publicRecordLookup
public PublicKeyRecord publicRecordLookup(SignatureRecord sign) throws TempFailException, PermFailException
Iterates through signature's declared lookup method- Parameters:
sign
- the signature record- Returns:
- an "applicable" PublicKeyRecord
- Throws:
TempFailException
- on errorPermFailException
- on error
-
verify
public List<SignatureRecord> verify(InputStream is) throws IOException, FailException
Verifies all of the DKIM-Signature records declared in the supplied input stream- Parameters:
is
- inputStream- Returns:
- a list of verified signature records.
- Throws:
IOException
- if errorFailException
- if no signature can be verified
-
newBodyHasher
public BodyHasher newBodyHasher(Headers messageHeaders) throws FailException
- Throws:
FailException
-
verify
public List<SignatureRecord> verify(Headers messageHeaders, InputStream bodyInputStream) throws IOException, FailException
Verifies all of the DKIM-Signature records declared in the Headers object.- Parameters:
messageHeaders
- parsed headersbodyInputStream
- input stream for the body.- Returns:
- a list of verified signature records
- Throws:
IOException
- on io errorFailException
- if no signature can be verified
-
verify
public List<SignatureRecord> verify(BodyHasher bh) throws FailException
Completes the simultaneous verification of multiple signatures given the previously prepared compound body hasher where the user already written the body to the outputstream and closed it.- Parameters:
bh
- the BodyHasher previously obtained by this class.- Returns:
- a list of valid (verified) signatures or null on null input.
- Throws:
FailException
- if no valid signature is found
-
-