Transaction signature handling. This class generates and verifies TSIG records on messages, which provide transaction security. @see TSIGRecord @author Brian Wellington
| 18 | */ |
| 19 | |
| 20 | public class TSIG { |
| 21 | |
| 22 | /** The domain name representing the HMAC-MD5 algorithm. */ |
| 23 | public static final Name HMAC_MD5 = |
| 24 | Name.fromConstantString("HMAC-MD5.SIG-ALG.REG.INT."); |
| 25 | |
| 26 | /** The domain name representing the HMAC-MD5 algorithm (deprecated). */ |
| 27 | public static final Name HMAC = HMAC_MD5; |
| 28 | |
| 29 | /** The domain name representing the HMAC-SHA1 algorithm. */ |
| 30 | public static final Name HMAC_SHA1 = Name.fromConstantString("hmac-sha1."); |
| 31 | |
| 32 | /** |
| 33 | * The domain name representing the HMAC-SHA224 algorithm. |
| 34 | * Note that SHA224 is not supported by Java out-of-the-box, this requires use |
| 35 | * of a third party provider like BouncyCastle.org. |
| 36 | */ |
| 37 | public static final Name HMAC_SHA224 = Name.fromConstantString("hmac-sha224."); |
| 38 | |
| 39 | /** The domain name representing the HMAC-SHA256 algorithm. */ |
| 40 | public static final Name HMAC_SHA256 = Name.fromConstantString("hmac-sha256."); |
| 41 | |
| 42 | /** The domain name representing the HMAC-SHA384 algorithm. */ |
| 43 | public static final Name HMAC_SHA384 = Name.fromConstantString("hmac-sha384."); |
| 44 | |
| 45 | /** The domain name representing the HMAC-SHA512 algorithm. */ |
| 46 | public static final Name HMAC_SHA512 = Name.fromConstantString("hmac-sha512."); |
| 47 | |
| 48 | private static Map algMap; |
| 49 | |
| 50 | static { |
| 51 | Map out = new HashMap(); |
| 52 | out.put(HMAC_MD5, "HmacMD5"); |
| 53 | out.put(HMAC_SHA1, "HmacSHA1"); |
| 54 | out.put(HMAC_SHA224, "HmacSHA224"); |
| 55 | out.put(HMAC_SHA256, "HmacSHA256"); |
| 56 | out.put(HMAC_SHA384, "HmacSHA384"); |
| 57 | out.put(HMAC_SHA512, "HmacSHA512"); |
| 58 | algMap = Collections.unmodifiableMap(out); |
| 59 | } |
| 60 | |
| 61 | public static Name |
| 62 | algorithmToName(String alg) |
| 63 | { |
| 64 | Iterator it = algMap.entrySet().iterator(); |
| 65 | while (it.hasNext()) { |
| 66 | Map.Entry entry = (Map.Entry) it.next(); |
| 67 | if (alg.equalsIgnoreCase((String)entry.getValue())) |
| 68 | return (Name) entry.getKey(); |
| 69 | } |
| 70 | throw new IllegalArgumentException("Unknown algorithm"); |
| 71 | } |
| 72 | public static String |
| 73 | nameToAlgorithm(Name name) |
| 74 | { |
| 75 | String alg = (String) algMap.get(name); |
| 76 | if (alg != null) |
| 77 | return alg; |
nothing calls this directly
no test coverage detected