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
}
Aggregations