use of com.intel.mtwilson.tag.repository.RepositoryInvalidInputException in project OpenAttestation by OpenAttestation.
the class MtWilsonImportTagCertificate method run.
@Override
@RequiresPermissions("tag_certificates:import")
public void run() {
log.debug("RPC:MtWilsonImportTagCertificate - Got request to deploy certificate with ID {}.", certificateId);
CertificateLocator locator = new CertificateLocator();
locator.id = certificateId;
try (CertificateDAO dao = TagJdbi.certificateDao()) {
Certificate obj = dao.findById(certificateId);
if (obj != null) {
log.debug("RPC:MtWilsonImportTagCertificate - Sha1 of the certificate about to be deployed is {}.", obj.getSha1());
AssetTagCertCreateRequest request = new AssetTagCertCreateRequest();
request.setCertificate(obj.getCertificate());
Global.mtwilson().importAssetTagCertificate(request);
log.info("RPC:MtWilsonImportTagCertificate - Certificate with id {} has been deployed successfully.");
} else {
log.error("RPC:MtWilsonImportTagCertificate - Specified Certificate with id {} is not valid.", certificateId);
throw new RepositoryInvalidInputException(locator);
}
} catch (RepositoryException re) {
throw re;
} catch (Exception ex) {
log.error("RPC:MtWilsonImportTagCertificate - Error during certificate deployment.", ex);
throw new RepositoryException(ex);
}
}
use of com.intel.mtwilson.tag.repository.RepositoryInvalidInputException 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