Search in sources :

Example 11 with DnsRecord

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

the class DNSRecordCommands method ensureANAME.

/**
	 * Adds an A records to the configuration service only if the record does not exist.
	 * @param args Contains the A record attributes.
	 * 
	 * @since 1.0
	 */
@Command(name = "Dns_ANAME_Ensure", usage = ENSURE_ANAME_USAGE)
public void ensureANAME(String[] args) {
    DnsRecord record = fromRecord(parser.parseANAME(args));
    if (!verifyIsUnique(record, false)) {
        return;
    }
    addDNS(record);
}
Also used : DnsRecord(org.nhind.config.DnsRecord) Command(org.nhindirect.dns.tools.utils.Command)

Example 12 with DnsRecord

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

the class DNSRecordCommands method verifyIsUnique.

/*
	 * ensures that a record is unique in the configuration service
	 */
private boolean verifyIsUnique(DnsRecord record, boolean details) {
    DnsRecord existing = find(record);
    if (existing != null) {
        System.out.println("Record already exists");
        print(existing);
        return false;
    }
    return true;
}
Also used : DnsRecord(org.nhind.config.DnsRecord)

Example 13 with DnsRecord

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

the class DNSRecordCommands method print.

/*
	 * prints the contents of an array of records
	 */
private void print(DnsRecord[] records) {
    if (records != null) {
        for (DnsRecord record : records) {
            print(record);
            System.out.println("\r\n-------------------------------------------");
        }
    }
}
Also used : DnsRecord(org.nhind.config.DnsRecord)

Example 14 with DnsRecord

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

the class DNSRecordCommands method fromRecord.

/*
	 * Convert a dnsjava record to a DnsRecord for use with the proxy.
	 */
private DnsRecord fromRecord(Record rec) {
    DnsRecord retVal = new DnsRecord();
    retVal.setData(rec.rdataToWireCanonical());
    retVal.setDclass(rec.getDClass());
    retVal.setName(rec.getName().toString());
    retVal.setTtl(rec.getTTL());
    retVal.setType(rec.getType());
    return retVal;
}
Also used : DnsRecord(org.nhind.config.DnsRecord)

Example 15 with DnsRecord

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

the class ClientProxyDNSTest method addDNSRecord.

@Test
public void addDNSRecord() throws Exception {
    cleanDNSRecords();
    DNSRecord rec = DNSRecordUtils.createARecord("example.domain.com", 86400L, "127.0.0.1");
    DnsRecord recToAdd = new DnsRecord();
    recToAdd.setData(rec.getData());
    recToAdd.setDclass(rec.getDclass());
    recToAdd.setName(rec.getName());
    recToAdd.setTtl(rec.getTtl());
    recToAdd.setType(rec.getType());
    proxy.addDNS(new DnsRecord[] { recToAdd });
    assertEquals(1, proxy.getDNSCount());
    DnsRecord[] recs = proxy.getDNSByNameAndType(recToAdd.getName(), recToAdd.getType());
    assertNotNull(recs);
    assertEquals(1, recs.length);
    assertEquals(rec.getName(), recs[0].getName());
}
Also used : DNSRecord(org.nhindirect.config.store.DNSRecord) DnsRecord(org.nhind.config.DnsRecord) Test(org.junit.Test)

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