use of org.nhindirect.config.store.DNSRecord in project nhin-d by DirectProject.
the class DNSDaoImpl method get.
/**
* {@inheritDoc}}
*/
@Override
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)
public Collection<DNSRecord> get(String name, int type) {
if (log.isDebugEnabled())
log.debug("get(String, int) Enter");
List<DNSRecord> result = Collections.emptyList();
Query select = null;
if (type == Type.ANY) {
select = entityManager.createQuery("SELECT d from DNSRecord d WHERE UPPER(d.name) = ?1");
select.setParameter(1, name.toUpperCase(Locale.getDefault()));
} else {
select = entityManager.createQuery("SELECT d from DNSRecord d WHERE UPPER(d.name) = ?1 and d.type = ?2");
select.setParameter(1, name.toUpperCase(Locale.getDefault()));
select.setParameter(2, type);
}
@SuppressWarnings("rawtypes") List rs = select.getResultList();
if (rs != null && (rs.size() != 0) && (rs.get(0) instanceof DNSRecord)) {
result = (List<DNSRecord>) rs;
}
if (log.isDebugEnabled())
log.debug("get(String, int) Exit");
return result;
}
use of org.nhindirect.config.store.DNSRecord in project nhin-d by DirectProject.
the class ServiceTest method testDNSService.
// @Test
// public void testDomainService()
// {
// try
// {
// int count = configSvc. getDomainCount();
// log.info(""+count + " Domains exist in the database");
// }
// catch (ConfigurationServiceException e)
// {
// e.printStackTrace();
// fail(e.getMessage());
// }
// }
// @Test
public void testDNSService() {
// try
// {
//configSvc.getDNSCount();
int count = 0;
// log.info(""+count + " DNS records exist in the database");
// System.out.println(""+count + " DNS records exist in the database");
// configSvc.removeDomain("pjpassoc.com");
Collection<DNSRecord> records = new ArrayList<DNSRecord>();
// records.add(DNSRecordUtils.createARecord("pjpassoc.com", 3600L, "192.168.1.1"));
// records.add(DNSRecordUtils.createMXRecord("pjpassoc.com", "mail.pjpassoc.com", 3600L, 0));
byte[] certData = null;
try {
// certData = loadPkcs12FromCertAndKey("gm2552.der", "gm2552Key.der");
certData = loadCertificateData("gm2552.der");
if (certData != null) {
// get the owner from the certificate information
// first transform into a certificate
CertContainer cont = toCertContainer(certData);
if (cont != null && cont.getCert() != null) {
Certificate cert2 = new Certificate();
cert2.setData(certData);
System.out.println(getThumbPrint(cont.getCert()));
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// records.add(DNSEntryForm.createCertRecord("yahoo.com", 3600L, 0,0,0,certData));
// configSvc.addDNS(records);
// assertEquals(2, configSvc.getDNSCount());
// }
// catch (ConfigurationServiceException e)
// {
// e.printStackTrace();
// fail(e.getMessage());
// }
}
use of org.nhindirect.config.store.DNSRecord 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();
}
}
Aggregations