+ InitialDirContext context = new InitialDirContext(env);
+ try {
+ Attributes dnsLookup;
+ try {
+ dnsLookup = context.getAttributes(domain, new String[] {
+ "257"
+ });
+ } catch (NameNotFoundException e) {
+ // We treat non-existing names as names without CAA-records
+ return new CAARecord[0];
+ }
+
+ Attribute nsRecords = dnsLookup.get("257");
+ if (nsRecords == null) {
+ return new CAARecord[] {};
+ }
+
+ CAA.CAARecord[] result = new CAA.CAARecord[nsRecords.size()];
+ for (int i = 0; i < result.length; i++) {
+ byte[] rec = (byte[]) nsRecords.get(i);
+
+ result[i] = new CAA.CAARecord(rec);
+ }
+
+ return result;
+ } finally {
+ context.close();