]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/util/DNSUtil.java
Merge "Update notes about password security"
[gigi.git] / src / org / cacert / gigi / util / DNSUtil.java
index 816b24731bc576635096e30ab691b1fb9e5e6b9b..31fb1d6e2e88e00cc855e554cf520f748142cd4f 100644 (file)
@@ -25,7 +25,7 @@ public class DNSUtil {
 
     public static String[] getNSNames(String name) throws NamingException {
         Attributes dnsLookup = context.getAttributes(name, new String[] {
-            "NS"
+                "NS"
         });
         return extractTextEntries(dnsLookup.get("NS"));
     }
@@ -36,12 +36,16 @@ public class DNSUtil {
         env.put(Context.AUTHORITATIVE, "true");
         env.put(Context.PROVIDER_URL, "dns://" + server);
         InitialDirContext context = new InitialDirContext(env);
+        try {
 
-        Attributes dnsLookup = context.getAttributes(name, new String[] {
-            "TXT"
-        });
+            Attributes dnsLookup = context.getAttributes(name, new String[] {
+                    "TXT"
+            });
+            return extractTextEntries(dnsLookup.get("TXT"));
+        } finally {
+            context.close();
+        }
 
-        return extractTextEntries(dnsLookup.get("TXT"));
     }
 
     private static String[] extractTextEntries(Attribute nsRecords) throws NamingException {
@@ -57,7 +61,7 @@ public class DNSUtil {
 
     public static String[] getMXEntries(String domain) throws NamingException {
         Attributes dnsLookup = context.getAttributes(domain, new String[] {
-            "MX"
+                "MX"
         });
         return extractTextEntries(dnsLookup.get("MX"));
     }