Search in sources :

Example 31 with HopsSecurityException

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);
    }
}
Also used : RESTApiJsonResponse(io.hops.hopsworks.api.util.RESTApiJsonResponse) Users(io.hops.hopsworks.persistence.entity.user.Users) IOException(java.io.IOException) EncryptionMasterPasswordException(io.hops.hopsworks.exceptions.EncryptionMasterPasswordException) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 32 with HopsSecurityException

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;
}
Also used : Stateless(javax.ejb.Stateless) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException) FeaturegroupPreview(io.hops.hopsworks.common.featurestore.featuregroup.cached.FeaturegroupPreview) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) RESTCodes(io.hops.hopsworks.restutils.RESTCodes) Collectors(java.util.stream.Collectors) Project(io.hops.hopsworks.persistence.entity.project.Project) Level(java.util.logging.Level) CachedFeaturegroupController(io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupController) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) SQLException(java.sql.SQLException) TransactionAttributeType(javax.ejb.TransactionAttributeType) TransactionAttribute(javax.ejb.TransactionAttribute) FeatureGroupStorage(io.hops.hopsworks.common.featurestore.featuregroup.cached.FeatureGroupStorage) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) UriInfo(javax.ws.rs.core.UriInfo) URI(java.net.URI) Users(io.hops.hopsworks.persistence.entity.user.Users) EJB(javax.ejb.EJB) FeaturegroupPreview(io.hops.hopsworks.common.featurestore.featuregroup.cached.FeaturegroupPreview) SQLException(java.sql.SQLException) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) FeatureGroupStorage(io.hops.hopsworks.common.featurestore.featuregroup.cached.FeatureGroupStorage)

Aggregations

HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)32 IOException (java.io.IOException)22 Users (io.hops.hopsworks.persistence.entity.user.Users)13 DatasetException (io.hops.hopsworks.exceptions.DatasetException)11 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)11 GenericException (io.hops.hopsworks.exceptions.GenericException)10 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)9 ProjectException (io.hops.hopsworks.exceptions.ProjectException)9 ServiceException (io.hops.hopsworks.exceptions.ServiceException)9 SQLException (java.sql.SQLException)9 Path (javax.ws.rs.Path)9 UserException (io.hops.hopsworks.exceptions.UserException)8 Produces (javax.ws.rs.Produces)8 Project (io.hops.hopsworks.persistence.entity.project.Project)7 ElasticException (io.hops.hopsworks.exceptions.ElasticException)6 KafkaException (io.hops.hopsworks.exceptions.KafkaException)6 ProvenanceException (io.hops.hopsworks.exceptions.ProvenanceException)6 SchemaException (io.hops.hopsworks.exceptions.SchemaException)6 POST (javax.ws.rs.POST)6 Path (org.apache.hadoop.fs.Path)6