badpenguin.dkim
Class NSKey

java.lang.Object
  extended by badpenguin.dkim.NSKey

public class NSKey
extends java.lang.Object

This Object is used to store a public key and the associated meta data retrieved from DNS (or maybe some other naming system in future). Typically these keys are created and stored in a HashTable by the NSKeyStore object, which means we don't have to make a DNS call every time the DKIM library parses a mail message.

Author:
Mark Boddington <dk_NO_im@_SP_bad_AM_penguin.co.uk>
http://www.badpenguin.co.uk

Constructor Summary
NSKey(java.lang.String record, int cacheTime)
          Create a new NSKey object, from the Name Service text record provided in the record string.
 
Method Summary
 java.lang.String getGranularity()
          Retrieve the granularity value specified in the G tag for this key.
 java.lang.String getHashAlgorithm()
          Return the hash algorithms allowed for use with this key, as secified in the H tag.
 java.security.PublicKey getKey()
          Retrieve the public key from this NSKey object.
 int getRetries()
           
 boolean isExpired()
          Check if this key should be expired from the cache.
 boolean isTesting()
          Returns true if this NSKey record has the "y" flag set.
 boolean noSubdomains()
          Returns true if this NSKey record has the s flag set.
 boolean setUpdating(boolean update)
          The NSKeyStore calls this method when it wants to update the key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NSKey

public NSKey(java.lang.String record,
             int cacheTime)
Create a new NSKey object, from the Name Service text record provided in the record string. This string should be a DNS txt record which adheres to the _domainkey DNS TXT record specification

Parameters:
record - - The Name Services TXT record
cacheTime - - number of seconds to cache key for.
Method Detail

isExpired

public boolean isExpired()
Check if this key should be expired from the cache.

Returns:
true or false

setUpdating

public boolean setUpdating(boolean update)
The NSKeyStore calls this method when it wants to update the key. We synchronise the update flag so that only one thread will attempt an update at once. Return true if the calling thread may perform an update, and false if not.
If the update parameter is true, then the caller wants to perform an update. If it is false, then the caller is indicating that the update was unsuccessful.

Parameters:
update - true or false
Returns:
boolean - allow update or not

getRetries

public int getRetries()

getKey

public java.security.PublicKey getKey()
                               throws DkimException
Retrieve the public key from this NSKey object. The Public key can then be used for verification tasks. If the key has expired, then we will throw a

Returns:
The RSA Public Key
Throws:
DkimException

isTesting

public boolean isTesting()
Returns true if this NSKey record has the "y" flag set. Indicating that this domain is currently testing DKIM, Failed messages should be treated as though they had no signature.

Returns:
True or False

noSubdomains

public boolean noSubdomains()
Returns true if this NSKey record has the s flag set. The s flag indicates that if a DKIM-Signature has the i tag set, then it can not be a subdomain of the d tag. That is the right hand side of @ in both i and d tags must match exactly.

Returns:
True or False

getGranularity

public java.lang.String getGranularity()
Retrieve the granularity value specified in the G tag for this key.

Returns:
granularity

getHashAlgorithm

public java.lang.String getHashAlgorithm()
Return the hash algorithms allowed for use with this key, as secified in the H tag.

Returns:
colon separated list of hash algorithms


© Copyright 2009 Mark Boddington (www.badpenguin.co.uk)