Search in sources :

Example 16 with DNSEntryForm

use of org.nhindirect.config.ui.form.DNSEntryForm in project nhin-d by DirectProject.

the class ServiceTest method testSOA.

//  @Test
public void testSOA() {
    DNSEntryForm SoadnsForm = new DNSEntryForm();
    SoadnsForm.setName("savvy");
    SoadnsForm.setTtl(84555L);
    SoadnsForm.setAdmin("ns.savvy.com");
    SoadnsForm.setDomain("ns2.savvy.com");
    SoadnsForm.setSerial(4L);
    SoadnsForm.setRefresh(6L);
    SoadnsForm.setRetry(8L);
    SoadnsForm.setExpire(66L);
    SoadnsForm.setMinimum(22L);
    Collection<DNSRecord> records = new ArrayList<DNSRecord>();
    records.add(DNSRecordUtils.createSOARecord(SoadnsForm.getName(), SoadnsForm.getTtl(), SoadnsForm.getDomain(), SoadnsForm.getAdmin(), (int) SoadnsForm.getSerial(), SoadnsForm.getRefresh(), SoadnsForm.getRetry(), SoadnsForm.getExpire(), SoadnsForm.getMinimum()));
    try {
        configSvc.addDNS(records);
        Collection<DNSRecord> arecords = configSvc.getDNSByType(DNSType.SOA.getValue());
        for (Iterator<DNSRecord> iter = arecords.iterator(); iter.hasNext(); ) {
            DNSRecord arec = iter.next();
            SOARecord newrec = (SOARecord) Record.newRecord(Name.fromString(arec.getName()), arec.getType(), arec.getDclass(), arec.getTtl(), arec.getData());
            System.out.println("A admin: " + newrec.getAdmin());
            System.out.println("A name: " + newrec.getName());
        }
    } catch (ConfigurationServiceException e) {
        e.printStackTrace();
    } catch (TextParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : DNSRecord(org.nhindirect.config.store.DNSRecord) ArrayList(java.util.ArrayList) ConfigurationServiceException(org.nhindirect.config.service.ConfigurationServiceException) DNSEntryForm(org.nhindirect.config.ui.form.DNSEntryForm) SOARecord(org.xbill.DNS.SOARecord) TextParseException(org.xbill.DNS.TextParseException)

Aggregations

DNSEntryForm (org.nhindirect.config.ui.form.DNSEntryForm)16 ConfigurationServiceException (org.nhindirect.config.service.ConfigurationServiceException)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 ModelAndView (org.springframework.web.servlet.ModelAndView)10 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)9 ArrayList (java.util.ArrayList)7 TextParseException (org.xbill.DNS.TextParseException)6 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 X509Certificate (java.security.cert.X509Certificate)5 CertificateEncodingException (javax.security.cert.CertificateEncodingException)5 IOException (java.io.IOException)4 Certificate (org.nhindirect.config.model.Certificate)4 DNSRecord (org.nhindirect.config.model.DNSRecord)4 DNSRecord (org.nhindirect.config.store.DNSRecord)4 NSRecord (org.xbill.DNS.NSRecord)3 SOARecord (org.xbill.DNS.SOARecord)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2