Search in sources :

Example 31 with DnsRecord

use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.

the class DNSRecordCommands method importRecord.

/*
	 * Imports a specific DNS record type from a file.
	 */
private void importRecord(String path, int type) {
    DnsRecord dnsRecord = loadAndVerifyDnsRecordFromBin(path);
    if (dnsRecord.getType() != type) {
        throw new IllegalArgumentException("File " + path + " does not contain the requested record type");
    }
    addDNS(dnsRecord);
}
Also used : DnsRecord(org.nhind.config.DnsRecord)

Example 32 with DnsRecord

use of org.nhind.config.DnsRecord in project nhin-d by DirectProject.

the class DNSRecordCommands method loadAndVerifyDnsRecordFromBin.

/*
	 * Loads a record from a file.  Records are stored in raw wire format.
	 */
private DnsRecord loadAndVerifyDnsRecordFromBin(String path) {
    File recFile = new File(path);
    if (!recFile.exists())
        throw new IllegalArgumentException("Record file " + recFile.getAbsolutePath() + " not found");
    Record rec = null;
    try {
        byte[] wire = FileUtils.readFileToByteArray(recFile);
        rec = Record.fromWire(wire, Section.ANSWER);
    } catch (Exception e) {
        throw new RuntimeException("Error reading file " + recFile.getAbsolutePath() + " : " + e.getMessage(), e);
    }
    return (rec != null) ? fromRecord(rec) : null;
}
Also used : DnsRecord(org.nhind.config.DnsRecord) SOARecord(org.xbill.DNS.SOARecord) Record(org.xbill.DNS.Record) File(java.io.File) RemoteException(java.rmi.RemoteException)

Aggregations

DnsRecord (org.nhind.config.DnsRecord)32 Command (org.nhindirect.dns.tools.utils.Command)14 Record (org.xbill.DNS.Record)7 ArrayList (java.util.ArrayList)6 RemoteException (java.rmi.RemoteException)4 CertificateConversionException (org.nhindirect.config.model.exceptions.CertificateConversionException)3 CERTRecord (org.xbill.DNS.CERTRecord)3 SOARecord (org.xbill.DNS.SOARecord)3 File (java.io.File)2 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 BaseTestPlan (org.nhindirect.dns.util.BaseTestPlan)2 ARecord (org.xbill.DNS.ARecord)2 MXRecord (org.xbill.DNS.MXRecord)2 Test (org.junit.Test)1 ConfigurationServiceProxy (org.nhind.config.ConfigurationServiceProxy)1 DNSRecord (org.nhindirect.config.store.DNSRecord)1 RRset (org.xbill.DNS.RRset)1