use of io.hops.hopsworks.exceptions.EncryptionMasterPasswordException in project hopsworks by logicalclocks.
the class SystemAdminService method changeMasterEncryptionPassword.
/**
* Admin endpoint that changes the master encryption password used to encrypt the certificates' password
* stored in the database.
* @param sc
* @param oldPassword Current password
* @param newPassword New password
* @return
* @throws HopsSecurityException
*/
@PUT
@Path("/encryptionPass")
public Response changeMasterEncryptionPassword(@Context SecurityContext sc, @FormParam("oldPassword") String oldPassword, @FormParam("newPassword") String newPassword) throws HopsSecurityException {
LOGGER.log(Level.FINE, "Requested master encryption password change");
try {
Users user = jWTHelper.getUserPrincipal(sc);
certificatesMgmService.checkPassword(oldPassword, user.getEmail());
Integer operationId = certificatesMgmService.initUpdateOperation();
certificatesMgmService.resetMasterEncryptionPassword(operationId, newPassword, user.getEmail());
RESTApiJsonResponse response = noCacheResponse.buildJsonResponse(Response.Status.CREATED, String.valueOf(operationId));
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.CREATED).entity(response).build();
} catch (EncryptionMasterPasswordException ex) {
throw new HopsSecurityException(RESTCodes.SecurityErrorCode.CERT_ACCESS_DENIED, Level.SEVERE, null, ex.getMessage(), ex);
} catch (IOException ex) {
throw new HopsSecurityException(RESTCodes.SecurityErrorCode.MASTER_ENCRYPTION_PASSWORD_ACCESS_ERROR, Level.SEVERE, null, ex.getMessage(), ex);
}
}
Aggregations