org.xbill.DNS.RRset Java Examples
The following examples show how to use
org.xbill.DNS.RRset.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DNSSECVerifier.java From androdns with Apache License 2.0 | 6 votes |
public void learnDNSSECKeysFromRRSETs(RRset[] rrsets){ Iterator it; int i; for (i = 0; i < rrsets.length; i++) { RRset rrset = rrsets[i]; if (rrset.getType()!=Type.DNSKEY){ continue; } it = rrset.rrs(); while (it.hasNext()) { DNSKEYRecord r = (DNSKEYRecord) it.next(); addDNSKEY(r); } } }
Example #2
Source File: DnsUpdateWriter.java From nomulus with Apache License 2.0 | 6 votes |
private RRset makeDelegationSignerSet(DomainBase domain) { RRset signerSet = new RRset(); for (DelegationSignerData signerData : domain.getDsData()) { DSRecord dsRecord = new DSRecord( toAbsoluteName(domain.getDomainName()), DClass.IN, dnsDefaultDsTtl.getStandardSeconds(), signerData.getKeyTag(), signerData.getAlgorithm(), signerData.getDigestType(), signerData.getDigest()); signerSet.addRR(dsRecord); } return signerSet; }
Example #3
Source File: jnamed.java From dnsjava with BSD 2-Clause "Simplified" License | 6 votes |
public <T extends Record> RRset findExactMatch(Name name, int type, int dclass, boolean glue) { Zone zone = findBestZone(name); if (zone != null) { return zone.findExactMatch(name, type); } else { List<RRset> rrsets; Cache cache = getCache(dclass); if (glue) { rrsets = cache.findAnyRecords(name, type); } else { rrsets = cache.findRecords(name, type); } if (rrsets == null) { return null; } else { return rrsets.get(0); /* not quite right */ } } }
Example #4
Source File: OpenAliasHelper.java From xmrwallet with Apache License 2.0 | 5 votes |
@Override protected Boolean doInBackground(String... args) { //main(); if (args.length != 1) return false; String name = args[0]; if ((name == null) || (name.isEmpty())) return false; //pointless trying to lookup nothing Timber.d("Resolving %s", name); try { SimpleResolver sr = new SimpleResolver(DNSSEC_SERVERS[new Random().nextInt(DNSSEC_SERVERS.length)]); ValidatingResolver vr = new ValidatingResolver(sr); vr.setTimeout(0, DNS_LOOKUP_TIMEOUT); vr.loadTrustAnchors(new ByteArrayInputStream(ROOT.getBytes("ASCII"))); Record qr = Record.newRecord(Name.fromConstantString(name + "."), Type.TXT, DClass.IN); Message response = vr.send(Message.newQuery(qr)); final int rcode = response.getRcode(); if (rcode != Rcode.NOERROR) { Timber.i("Rcode: %s", Rcode.string(rcode)); for (RRset set : response.getSectionRRsets(Section.ADDITIONAL)) { if (set.getName().equals(Name.root) && set.getType() == Type.TXT && set.getDClass() == ValidatingResolver.VALIDATION_REASON_QCLASS) { Timber.i("Reason: %s", ((TXTRecord) set.first()).getStrings().get(0)); } } return false; } else { dnssec = response.getHeader().getFlag(Flags.AD); for (Record record : response.getSectionArray(Section.ANSWER)) { if (record.getType() == Type.TXT) { txts.addAll(((TXTRecord) record).getStrings()); } } } } catch (IOException | IllegalArgumentException ex) { return false; } return true; }
Example #5
Source File: DNSFormActivity.java From androdns with Apache License 2.0 | 5 votes |
public String rrSetsToString(RRset[] rrsets) { StringBuffer ansBuffer = new StringBuffer(); Iterator it; int i; for (i = 0; i < rrsets.length; i++) { RRset rrset = rrsets[i]; it = rrset.rrs(); while (it.hasNext()) { Record r = (Record) it.next(); //Log.i(TAG, "rrsetstostring: type=" + r.getType()); ansBuffer.append(r.toString()); ansBuffer.append("\n"); } //RRSIGs final Iterator<Record> sigIter = rrset.sigs(); while (sigIter.hasNext()) { final Record sigRec = sigIter.next(); ansBuffer.append(sigRec.toString()); ansBuffer.append("\n"); } } //replace tabs String ret = ansBuffer.toString().replace('\t', ' '); return ret; }
Example #6
Source File: DNSSECVerifier.java From androdns with Apache License 2.0 | 5 votes |
public void verifySignature(RRset rrset, RRSIGRecord rrsig) throws DNSSEC.DNSSECException,DNSKEYUnavailableException { Name ownerName = rrsig.getSigner(); int keyTag = rrsig.getFootprint(); DNSKEYRecord dnskey=getDNSKEY(ownerName,keyTag); if(dnskey==null){ Log.d(TAG,"missing DNSKEY "+hskey(ownerName.toString(),keyTag)); throw new DNSKEYUnavailableException("DNSKEY "+ownerName+"/"+keyTag+" not available"); } DNSSEC.verify(rrset, rrsig, dnskey); }
Example #7
Source File: DNSSECVerifier.java From androdns with Apache License 2.0 | 5 votes |
public String verificationStatusString(RRset[] rrsets){ StringBuffer buf = new StringBuffer(); for(RRset rrset:rrsets) { Iterator<RRSIGRecord> sigs = rrset.sigs(); while (sigs.hasNext()) { RRSIGRecord rrsig = sigs.next(); int keyID = rrsig.getFootprint(); buf.append(keyID); buf.append("/"); buf.append(rrsig.getSigner().toString()); buf.append(":"); buf.append(Type.string(rrset.getType())); buf.append("="); try { this.verifySignature(rrset, rrsig); buf.append("verified"); } catch (DNSKEYUnavailableException dku) { buf.append("have to learn DNSKEY"); } catch (DNSSEC.DNSSECException dse) { if (dse instanceof DNSSEC.SignatureExpiredException) { buf.append("expired"); } else if (dse instanceof DNSSEC.SignatureNotYetValidException) { buf.append("not yet valid"); } else if (dse instanceof DNSSEC.UnsupportedAlgorithmException) { buf.append("unsupported alg"); } else { buf.append(dse.getMessage()); } } buf.append("\n"); } } String validationStatus = buf.toString(); Log.d(TAG,"Validation status: "+validationStatus); return validationStatus; }
Example #8
Source File: DnsUpdateWriter.java From nomulus with Apache License 2.0 | 5 votes |
private RRset makeNameServerSet(DomainBase domain) { RRset nameServerSet = new RRset(); for (String hostName : domain.loadNameserverHostNames()) { NSRecord record = new NSRecord( toAbsoluteName(domain.getDomainName()), DClass.IN, dnsDefaultNsTtl.getStandardSeconds(), toAbsoluteName(hostName)); nameServerSet.addRR(record); } return nameServerSet; }
Example #9
Source File: DnsUpdateWriter.java From nomulus with Apache License 2.0 | 5 votes |
private RRset makeAddressSet(HostResource host) { RRset addressSet = new RRset(); for (InetAddress address : host.getInetAddresses()) { if (address instanceof Inet4Address) { ARecord record = new ARecord( toAbsoluteName(host.getHostName()), DClass.IN, dnsDefaultATtl.getStandardSeconds(), address); addressSet.addRR(record); } } return addressSet; }
Example #10
Source File: DnsUpdateWriter.java From nomulus with Apache License 2.0 | 5 votes |
private RRset makeV6AddressSet(HostResource host) { RRset addressSet = new RRset(); for (InetAddress address : host.getInetAddresses()) { if (address instanceof Inet6Address) { AAAARecord record = new AAAARecord( toAbsoluteName(host.getHostName()), DClass.IN, dnsDefaultATtl.getStandardSeconds(), address); addressSet.addRR(record); } } return addressSet; }
Example #11
Source File: DnsUpdateWriterTest.java From nomulus with Apache License 2.0 | 5 votes |
private ImmutableList<Record> findUpdateRecords( Update update, String resourceName, int recordType) { for (RRset set : update.getSectionRRsets(Section.UPDATE)) { if (set.getName().toString().equals(resourceName) && set.getType() == recordType) { return fixIterator(Record.class, set.rrs()); } } assertWithMessage( "No record set found for resource '%s' type '%s'", resourceName, Type.string(recordType)) .fail(); throw new AssertionError(); }
Example #12
Source File: jnamed.java From dnsjava with BSD 2-Clause "Simplified" License | 5 votes |
private void addCacheNS(Message response, Cache cache, Name name) { SetResponse sr = cache.lookupRecords(name, Type.NS, Credibility.HINT); if (!sr.isDelegation()) { return; } RRset nsRecords = sr.getNS(); for (Record r : nsRecords.rrs()) { response.addRecord(r, Section.AUTHORITY); } }
Example #13
Source File: jnamed.java From dnsjava with BSD 2-Clause "Simplified" License | 5 votes |
private void addGlue(Message response, Name name, int flags) { RRset a = findExactMatch(name, Type.A, DClass.IN, true); if (a == null) { return; } addRRset(name, response, a, Section.ADDITIONAL, flags); }
Example #14
Source File: jnamed.java From dnsjava with BSD 2-Clause "Simplified" License | 4 votes |
private void addNS(Message response, Zone zone, int flags) { RRset nsRecords = zone.getNS(); addRRset(nsRecords.getName(), response, nsRecords, Section.AUTHORITY, flags); }