From 69d965cc0fcc3060d8f70826bb7469ecb039f93c Mon Sep 17 00:00:00 2001 From: David Blacka Date: Sat, 26 May 2012 15:48:25 -0400 Subject: [PATCH] Wrap the new exceptions to mimic prior behavior. --- .../dnssec/security/DnsKeyConverter.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/com/verisignlabs/dnssec/security/DnsKeyConverter.java b/src/com/verisignlabs/dnssec/security/DnsKeyConverter.java index 6de283e..1149578 100644 --- a/src/com/verisignlabs/dnssec/security/DnsKeyConverter.java +++ b/src/com/verisignlabs/dnssec/security/DnsKeyConverter.java @@ -44,6 +44,7 @@ import javax.crypto.spec.DHParameterSpec; import javax.crypto.spec.DHPrivateKeySpec; import org.xbill.DNS.DNSKEYRecord; +import org.xbill.DNS.DNSSEC.DNSSECException; import org.xbill.DNS.Name; import org.xbill.DNS.utils.base64; @@ -95,7 +96,14 @@ public class DnsKeyConverter pKeyRecord.getKey()); } - return pKeyRecord.getPublicKey(); + try + { + return pKeyRecord.getPublicKey(); + } + catch (DNSSECException e) + { + throw new NoSuchAlgorithmException(e); + } } /** @@ -104,8 +112,16 @@ public class DnsKeyConverter public DNSKEYRecord generateDNSKEYRecord(Name name, int dclass, long ttl, int flags, int alg, PublicKey key) { - return new DNSKEYRecord(name, dclass, ttl, flags, DNSKEYRecord.Protocol.DNSSEC, alg, - key); + try + { + return new DNSKEYRecord(name, dclass, ttl, flags, DNSKEYRecord.Protocol.DNSSEC, alg, + key); + } + catch (DNSSECException e) + { + // FIXME: this mimics the behavior of KEYConverter.buildRecord(), which would return null if the algorithm was unknown. + return null; + } } // Private Key Specific Parsing routines