Search in sources :

Example 6 with EncryptionMasterPasswordException

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);
    }
}
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)

Aggregations

EncryptionMasterPasswordException (io.hops.hopsworks.exceptions.EncryptionMasterPasswordException)6 Users (io.hops.hopsworks.persistence.entity.user.Users)3 HashMap (java.util.HashMap)3 IOException (java.io.IOException)2 RESTApiJsonResponse (io.hops.hopsworks.api.util.RESTApiJsonResponse)1 MasterPasswordChangeResult (io.hops.hopsworks.common.security.MasterPasswordChangeResult)1 SymmetricEncryptionDescriptor (io.hops.hopsworks.common.security.SymmetricEncryptionDescriptor)1 HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)1 UserCerts (io.hops.hopsworks.persistence.entity.certificates.UserCerts)1 ClusterCertificate (io.hops.hopsworks.persistence.entity.dela.certs.ClusterCertificate)1 Secret (io.hops.hopsworks.persistence.entity.user.security.secrets.Secret)1 SecretId (io.hops.hopsworks.persistence.entity.user.security.secrets.SecretId)1 List (java.util.List)1 Map (java.util.Map)1 AccessTimeout (javax.ejb.AccessTimeout)1 Lock (javax.ejb.Lock)1 FacesContext (javax.faces.context.FacesContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1