use of io.hops.hopsworks.exceptions.HopsSecurityException 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);
}
}
use of io.hops.hopsworks.exceptions.HopsSecurityException in project hopsworks by logicalclocks.
the class PreviewBuilder method build.
public PreviewDTO build(UriInfo uriInfo, Users user, Project project, Featuregroup featuregroup, String partition, boolean online, int limit) throws FeaturestoreException, HopsSecurityException {
FeaturegroupPreview preview = null;
try {
preview = cachedFeaturegroupController.getFeaturegroupPreview(featuregroup, project, user, partition, online, limit);
} catch (SQLException e) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.COULD_NOT_PREVIEW_FEATUREGROUP, Level.SEVERE, "Feature Group id: " + featuregroup.getId(), e.getMessage(), e);
}
FeatureGroupStorage storage = online ? FeatureGroupStorage.ONLINE : FeatureGroupStorage.OFFLINE;
PreviewDTO previewDTO = new PreviewDTO();
previewDTO.setHref(uri(uriInfo, project, featuregroup));
previewDTO.setExpand(true);
previewDTO.setItems(preview.getPreview().stream().map(r -> r.getValues().stream().map(c -> new ColumnDTO(c.getValue0(), c.getValue1())).collect(Collectors.toList())).map(c -> new PreviewDTO(c, storage)).collect(Collectors.toList()));
return previewDTO;
}
Aggregations