use of com.intel.mtwilson.datatypes.AssetTagCertRevokeRequest in project OpenAttestation by OpenAttestation.
the class RevokeTagCertificate method revokeCert.
@POST
public //@RequiresPermissions("tag_certificates:delete")
void revokeCert(@QueryParam("certId") String certId) {
log.debug("RPC: RevokeTagCertificate - Got request to revocation of certificate: {}", certId);
setCertificateId(UUID.valueOf(certId));
try (CertificateDAO dao = TagJdbi.certificateDao()) {
CertificateLocator locator = new CertificateLocator();
locator.id = certificateId;
Certificate obj = dao.findById(certificateId);
if (obj != null) {
// tries jvm properties, environment variables, then mtwilson.properties; you can set location of mtwilson.properties with -Dmtwilson.home=/path/to/dir
org.apache.commons.configuration.Configuration conf = ConfigurationUtil.getConfiguration();
ApiClient mtwilson = new ApiClient(conf);
log.debug("RPC: RevokeTagCertificate - Sha1 of the certificate about to be revoked is {}.", obj.getSha1());
dao.updateRevoked(certificateId, true);
AssetTagCertRevokeRequest request = new AssetTagCertRevokeRequest();
request.setSha1OfAssetCert(obj.getSha1().toByteArray());
mtwilson.revokeAssetTagCertificate(request);
//Global.mtwilson().revokeAssetTagCertificate(request);
log.info("RPC: RevokeTagCertificate - Certificate with id {} has been revoked successfully.");
} else {
log.error("RPC: RevokeTagCertificate - Certificate with id {} does not exist.", certificateId);
throw new RepositoryInvalidInputException(locator);
}
} catch (RepositoryException re) {
throw re;
} catch (Exception ex) {
log.error("RPC: RevokeTagCertificate - Error during certificate revocation.", ex);
throw new RepositoryException(ex);
}
}
Aggregations