use of io.hops.hopsworks.exceptions.UserException in project hopsworks by logicalclocks.
the class OnlineFeaturestoreController method initConnection.
/**
* Initializes a JDBC connection MySQL Server using an online featurestore user and password
*
* @param databaseName name of the MySQL database to open a connection to
* @param project the project of the user making the request
* @param user the user making the request
* @return conn the JDBC connection
* @throws FeaturestoreException
*/
private Connection initConnection(String databaseName, Project project, Users user) throws FeaturestoreException {
String jdbcString = "";
String dbUsername = onlineDbUsername(project, user);
String password = "";
try {
password = secretsController.get(user, dbUsername).getPlaintext();
} catch (UserException e) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATURESTORE_ONLINE_SECRETS_ERROR, Level.SEVERE, "Problem getting secrets for the JDBC connection to the online FS");
}
try {
return DriverManager.getConnection(getJdbcURL(databaseName), dbUsername, password);
} catch (SQLException | ServiceDiscoveryException e) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.COULD_NOT_INITIATE_MYSQL_CONNECTION_TO_ONLINE_FEATURESTORE, Level.SEVERE, "project: " + project.getName() + ", database: " + databaseName + ", db user:" + dbUsername + ", jdbcString: " + jdbcString, e.getMessage(), e);
}
}
use of io.hops.hopsworks.exceptions.UserException in project hopsworks by logicalclocks.
the class OnlineFeaturestoreController method createOnlineFeaturestoreUserSecret.
/**
* Stores the online-featurestore password as a Hopsworks secret for the user
*
* @param dbuser the database-user
* @param user the user to store the secret for
* @param project the project of the online feature store
* @return the password
* @throws FeaturestoreException
*/
private String createOnlineFeaturestoreUserSecret(String dbuser, Users user, Project project) throws FeaturestoreException {
String onlineFsPw = RandomStringUtils.randomAlphabetic(FeaturestoreConstants.ONLINE_FEATURESTORE_PW_LENGTH);
try {
// Delete if the secret already exsits
secretsController.delete(user, dbuser);
secretsController.add(user, dbuser, onlineFsPw, VisibilityType.PRIVATE, project.getId());
} catch (UserException e) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATURESTORE_ONLINE_SECRETS_ERROR, Level.SEVERE, "Problem adding online featurestore password to hopsworks secretsmgr");
}
return onlineFsPw;
}
use of io.hops.hopsworks.exceptions.UserException in project hopsworks by logicalclocks.
the class LoginBean method login.
public String login() {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
this.user = userFacade.findByEmail(this.credentials.getUsername());
if (user == null) {
context.addMessage(null, new FacesMessage("Login failed. User " + this.credentials.getUsername()));
return "";
}
try {
auditedUserAuth.login(user, this.credentials.getPassword(), this.credentials.getOtp(), request);
} catch (UserException ex) {
LOGGER.log(Level.SEVERE, null, ex);
context.addMessage(null, new FacesMessage("Login failed."));
return "";
} catch (EJBException ie) {
String msg = ie.getCausedByException().getMessage();
if (msg != null && !msg.isEmpty() && msg.contains("Second factor required.")) {
setTwoFactor(true);
}
context.addMessage(null, new FacesMessage(msg));
return "login";
} catch (ServletException e) {
authController.registerAuthenticationFailure(user);
context.addMessage(null, new FacesMessage("Login failed."));
return "";
}
return "monitoring";
}
use of io.hops.hopsworks.exceptions.UserException in project hopsworks by logicalclocks.
the class AccountVerification method validate.
private boolean validate(String key) {
FacesContext ctx = FacesContext.getCurrentInstance();
HttpServletRequest req = (HttpServletRequest) ctx.getExternalContext().getRequest();
try {
auditedUserAccountAction.validateKey(key, req);
return true;
} catch (PersistenceException ex) {
dbDown = true;
} catch (EJBException | IllegalArgumentException e) {
return false;
} catch (UserException ue) {
if (RESTCodes.UserErrorCode.ACCOUNT_INACTIVE.equals(ue.getErrorCode())) {
this.alreadyValidated = true;
} else if (RESTCodes.UserErrorCode.ACCOUNT_ALREADY_VERIFIED.equals(ue.getErrorCode())) {
this.alreadyRegistered = true;
} else {
this.userNotFound = true;
}
}
return false;
}
use of io.hops.hopsworks.exceptions.UserException in project hopsworks by logicalclocks.
the class ConfigureLdap method deleteRemoteUserFromAllProjects.
public void deleteRemoteUserFromAllProjects(Users user) {
RemoteUser remoteUser = remoteUserFacade.findByUsers(user);
try {
ldapConfigHelper.getRemoteGroupMappingHelper().removeFromAllProjects(remoteUser);
initRemoteUsers();
MessagesController.addInfoMessage("Removing user from all projects completed with success.");
} catch (UserException e) {
MessagesController.addErrorMessage(e.getMessage());
}
}
Aggregations