use of io.hops.hopsworks.common.security.CSR in project hopsworks by logicalclocks.
the class DelaTrackerCertController method signCsr.
public CSR signCsr(String userEmail, CSR csr) throws IOException, HopsSecurityException, GenericException, DelaCSRCheckException {
ClusterCert clusterCert = checkCSR(userEmail, csr);
CSR signedCert = certificatesController.signDelaClusterCertificate(csr);
String certSerialNumber;
try {
certSerialNumber = String.valueOf(certificatesController.extractSerialNumberFromCert(signedCert.getSignedCert()));
} catch (CertificateException e) {
throw new HopsSecurityException(RESTCodes.SecurityErrorCode.CERT_CREATION_ERROR, Level.WARNING, null, null, e);
}
clusterCert.setSerialNumber(certSerialNumber);
clusterCertFacade.update(clusterCert);
return signedCert;
}
use of io.hops.hopsworks.common.security.CSR in project hopsworks by logicalclocks.
the class CAProxy method signCSR.
private CSR signCSR(CSR csr, CA_PATH path) throws HopsSecurityException, GenericException {
try {
String csrJSON = objectMapper.writeValueAsString(csr);
HttpPost httpRequest = new HttpPost(path.path);
httpRequest.setHeader(HttpHeaders.CONTENT_TYPE, CONTENT_TYPE_JSON);
client.setAuthorizationHeader(httpRequest);
httpRequest.setEntity(new StringEntity(csrJSON));
HttpRetryableAction<CSR> retryableAction = new HttpRetryableAction<CSR>() {
@Override
public CSR performAction() throws ClientProtocolException, IOException {
return client.execute(httpRequest, CA_SIGN_RESPONSE_HANDLER);
}
};
return retryableAction.tryAction();
} catch (JsonProcessingException ex) {
throw new HopsSecurityException(RESTCodes.SecurityErrorCode.CSR_ERROR, Level.SEVERE, null, null, ex);
} catch (ClientProtocolException ex) {
LOG.log(Level.SEVERE, "Could not sign CSR", ex);
throw new HopsSecurityException(RESTCodes.SecurityErrorCode.CSR_ERROR, Level.SEVERE, null, null, ex.getCause());
} catch (IOException ex) {
LOG.log(Level.SEVERE, "Could not sign CSR", ex);
throw new GenericException(RESTCodes.GenericErrorCode.UNKNOWN_ERROR, Level.SEVERE, "Generic error while signing CSR", null, ex);
}
}
use of io.hops.hopsworks.common.security.CSR in project hopsworks by logicalclocks.
the class Cluster method singCertificate.
@POST
@Path("certificate")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@RolesAllowed({ "CLUSTER_AGENT" })
public Response singCertificate(CSR csr, @Context HttpServletRequest req) throws HopsSecurityException, GenericException, DelaCSRCheckException, IOException {
String userEmail = req.getUserPrincipal().getName();
CSR signedCSR = delaTrackerCertController.signCsr(userEmail, csr);
return Response.ok().entity(signedCSR).build();
}
Aggregations