Search in sources :

Example 1 with CertUtils

use of org.nhindirect.config.model.utils.CertUtils in project nhin-d by DirectProject.

the class CertCommands method importPublicCert.

@Command(name = "AddPublicCert", usage = IMPORT_PUBLIC_CERT_USAGE)
public void importPublicCert(String[] args) {
    final String fileLoc = StringArrayUtil.getRequiredValue(args, 0);
    try {
        final X509Certificate cert = new CertUtils().certFromFile(fileLoc);
        final org.nhind.config.Certificate addCert = new org.nhind.config.Certificate();
        addCert.setData(cert.getEncoded());
        addCert.setOwner(CryptoExtensions.getSubjectAddress(cert));
        addCert.setPrivateKey(false);
        addCert.setStatus(EntityStatus.ENABLED);
        proxy.addCertificates(new org.nhind.config.Certificate[] { addCert });
        System.out.println("Successfully imported public certificate.");
    } catch (IOException e) {
        System.out.println("Error reading file " + fileLoc + " : " + e.getMessage());
        return;
    }///CLOVER:OFF
     catch (Exception e) {
        System.out.println("Error importing certificate " + fileLoc + " : " + e.getMessage());
    }
///CLOVER:ON
}
Also used : CertUtils(org.nhindirect.config.model.utils.CertUtils) IOException(java.io.IOException) X509Certificate(java.security.cert.X509Certificate) IOException(java.io.IOException) X509Certificate(java.security.cert.X509Certificate) Command(org.nhindirect.dns.tools.utils.Command)

Aggregations

IOException (java.io.IOException)1 X509Certificate (java.security.cert.X509Certificate)1 CertUtils (org.nhindirect.config.model.utils.CertUtils)1 Command (org.nhindirect.dns.tools.utils.Command)1