use of org.nhindirect.dns.tools.utils.Command in project nhin-d by DirectProject.
the class DNSRecordCommands method addMX.
/**
* Adds an MX records to the configuration service.
* @param args Contains the MX record attributes.
*
* @since 1.0
*/
@Command(name = "Dns_MX_Add", usage = ADD_MX_USAGE)
public void addMX(String[] args) {
DnsRecord record = fromRecord(parser.parseMX(args));
addDNS(record);
}
use of org.nhindirect.dns.tools.utils.Command in project nhin-d by DirectProject.
the class CertCommands method importPrivateCert.
@Command(name = "AddPrivateCert", usage = IMPORT_PRIVATE_CERT_USAGE)
public void importPrivateCert(String[] args) {
final String fileLoc = StringArrayUtil.getRequiredValue(args, 0);
final String passPhrase = StringArrayUtil.getOptionalValue(args, 1, "");
try {
final byte[] certBytes = FileUtils.readFileToByteArray(new File(fileLoc));
final byte[] insertBytes = (passPhrase == null || passPhrase.isEmpty()) ? certBytes : CertUtils.pkcs12ToStrippedPkcs12(certBytes, passPhrase);
final X509Certificate cert = CertUtils.toX509Certificate(insertBytes);
org.nhind.config.Certificate addCert = new org.nhind.config.Certificate();
addCert.setData(certBytes);
addCert.setOwner(CryptoExtensions.getSubjectAddress(cert));
addCert.setPrivateKey(cert instanceof X509CertificateEx);
addCert.setStatus(EntityStatus.ENABLED);
proxy.addCertificates(new org.nhind.config.Certificate[] { addCert });
System.out.println("Successfully imported private certificate.");
} catch (IOException e) {
System.out.println("Error reading file " + fileLoc + " : " + e.getMessage());
return;
} catch (Exception e) {
System.out.println("Error importing certificate " + fileLoc + " : " + e.getMessage());
}
}
use of org.nhindirect.dns.tools.utils.Command in project nhin-d by DirectProject.
the class DNSRecordCommands method addANAME.
/**
* Adds an A records to the configuration service.
* @param args Contains the A record attributes.
*
* @since 1.0
*/
@Command(name = "Dns_ANAME_Add", usage = ADD_ANAME_USAGE)
public void addANAME(String[] args) {
DnsRecord record = fromRecord(parser.parseANAME(args));
addDNS(record);
}
use of org.nhindirect.dns.tools.utils.Command in project nhin-d by DirectProject.
the class DNSRecordCommands method ensureMX.
/**
* Adds an MX records to the configuration service only if the record does not exist.
* @param args Contains the MX record attributes.
*
* @since 1.0
*/
@Command(name = "Dns_MX_Ensure", usage = ENSURE_MX_USAGE)
public void ensureMX(String[] args) {
DnsRecord record = fromRecord(parser.parseMX(args));
if (!verifyIsUnique(record, false)) {
return;
}
addDNS(record);
}
use of org.nhindirect.dns.tools.utils.Command 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);
}
Aggregations