/** * Get the owner of the given project. * <p/> * @param project The project for which to get the current owner. * @return The primary key of the owner of the project. * @deprecated Use project.getOwner().getEmail(); instead. */ public String findOwner(Project project) { return project.getOwner().getEmail(); }
@Override public void remove(Users user) { if (user != null && user.getEmail() != null && em.contains(user)) { em.remove(user); } }
public void registerLoginInfo(Users user, String action, String outcome, HttpServletRequest req) { if (!whitelistUserLogins.contains(user.getEmail())) { Userlogins userlogin = new Userlogins(req.getRemoteHost(), extractUserAgent(req), user, action, outcome, new Date()); em.persist(userlogin); } }
public UserCardDTO(Users user) { this.firstname = user.getFname(); this.lastname = user.getLname(); this.email = user.getEmail(); }
public ProjectTeam(Project project, Users user) { this.projectTeamPK = new ProjectTeamPK(project.getId(), user.getEmail()); }
public void deleteUser(Users u) { if (u != null) { List<RolesAudit> results1 = rolesAuditFacade.findByInitiator(u); List<RolesAudit> results2 = rolesAuditFacade.findByTarget(u); results1.addAll(results2); for (Iterator<RolesAudit> iterator = results1.iterator(); iterator.hasNext();) { RolesAudit next = iterator.next(); rolesAuditFacade.remove(next); } List<AccountAudit> resultsAA1 = accountAuditFacade.findByInitiator(u); List<AccountAudit> resultsAA2 = accountAuditFacade.findByTarget(u); resultsAA1.addAll(resultsAA2); for (Iterator<AccountAudit> iterator = resultsAA1.iterator(); iterator.hasNext();) { AccountAudit next = iterator.next(); accountAuditFacade.remove(next); } userFacade.removeByEmail(u.getEmail()); } }
/** * Register authentication failure and register login audit info * * @param user * @param req */ public void registerAuthenticationFailure(Users user, HttpServletRequest req) { registerFalseLogin(user, req); accountAuditFacade.registerLoginInfo(user, UserAuditActions.LOGIN.name(), UserAuditActions.FAILED.name(), req); LOGGER.log(Level.INFO, "Authentication failure user: {0}. ", user.getEmail()); }
/** * Set user offline and register login audit info * * @param user * @param req */ public void registerLogout(Users user, HttpServletRequest req) { setUserOnlineStatus(user, Settings.IS_OFFLINE); accountAuditFacade.registerLoginInfo(user, UserAuditActions.LOGOUT.name(), UserAuditActions.SUCCESS.name(), req); LOGGER.log(Level.INFO, "Logged out user: {0}. ", user.getEmail()); }
/** * Set user online, resets false login attempts and register login audit info * * @param user * @param req */ public void registerLogin(Users user, HttpServletRequest req) { resetFalseLogin(user); setUserOnlineStatus(user, Settings.IS_ONLINE); accountAuditFacade.registerLoginInfo(user, UserAuditActions.LOGIN.name(), UserAuditActions.SUCCESS.name(), req); LOGGER.log(Level.INFO, "Logged in user: {0}. ", user.getEmail()); }
public List<AclDTO> getTopicAcls(String topicName, Integer projectId) throws AppException { ProjectTopics pt = em.find(ProjectTopics.class, new ProjectTopicsPK(topicName, projectId)); if (pt == null) { throw new AppException(Response.Status.NOT_FOUND.getStatusCode(), "Kafka topic does not exist in database."); } TypedQuery<TopicAcls> query = em.createNamedQuery( "TopicAcls.findByTopicName", TopicAcls.class) .setParameter("topicName", topicName); List<TopicAcls> acls = query.getResultList(); List<AclDTO> aclDtos = new ArrayList<>(); String projectName; for (TopicAcls ta : acls) { projectName = ta.getPrincipal().split(PROJECT_DELIMITER)[0]; aclDtos.add(new AclDTO(ta.getId(), projectName, ta.getUser().getEmail(), ta.getPermissionType(), ta.getOperationType(), ta.getHost(), ta.getRole())); } return aclDtos; }
public DataSetDTO(String name, int inodeId, Project project) { this.inodeId = inodeId; this.name = name; this.projectName = project.getName(); this.projectTeam = new ArrayList<>(); //this have to be done because project team contains too much info. for (ProjectTeam member : project.getProjectTeamCollection()) { projectTeam.add(new UserCardDTO(member.getUser().getFname(), member. getUser().getLname(), member.getUser().getEmail())); } }
/** * Stores an instance in the database. * <p/> * @param user * @param jobDesc * @param executionId * @param appId */ public void persist(Users user, Jobs jobDesc, int executionId, String appId) { SparkJobConfiguration configuration = (SparkJobConfiguration) jobDesc. getJobConfig(); String inodePath = configuration.getAppPath(); String patternString = "hdfs://(.*)\\s"; Pattern p = Pattern.compile(patternString); Matcher m = p.matcher(inodePath); String[] parts = inodePath.split("/"); String pathOfInode = inodePath.replace("hdfs://" + parts[2], ""); Inode inode = inodeFacade.getInodeAtPath(pathOfInode); String jarFile = inode.getInodePK().getName(); String blocks = checkArguments(configuration.getArgs()); this.persist(jobDesc.getId(), jarFile, executionId, appId, jobDesc, blocks, configuration, user.getEmail()); }
public void changePassword(String email, String oldPassword, String newPassword, String confirmedPassword, HttpServletRequest req) throws AppException { Users user = userFacade.findByEmail(email); if (user == null) { throw new AppException(Response.Status.NOT_FOUND.getStatusCode(), ResponseMessages.USER_WAS_NOT_FOUND); } if (!authController.validatePassword(user, oldPassword, req)) { throw new AppException(Response.Status.BAD_REQUEST.getStatusCode(), ResponseMessages.PASSWORD_INCORRECT); } if (userValidator.isValidPassword(newPassword, confirmedPassword)) { try { authController.changePassword(user, newPassword, req); } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Error while changing password: ", ex); throw new AppException(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), ResponseMessages.PASSWORD_RESET_UNSUCCESSFUL); } accountAuditFacade.registerAccountChange(user, AccountsAuditActions.PASSWORDCHANGE.name(), AccountsAuditActions.SUCCESS.name(), "Changed password.", user, req); if (user.getEmail().compareTo("admin@kth.se") == 0) { settings.setAdminPasswordChanged(); } } }
/** * Sends new activation key to the given user. * * @param user * @param req * @throws MessagingException */ public void sendNewValidationKey(Users user, HttpServletRequest req) throws MessagingException { if (user == null) { throw new IllegalArgumentException("User not set."); } String activationKey = SecurityUtils.getRandomPassword(RANDOM_PWD_LEN); emailBean.sendEmail(user.getEmail(), Message.RecipientType.TO, UserAccountsEmailMessages.ACCOUNT_REQUEST_SUBJECT, UserAccountsEmailMessages.buildMobileRequestMessageRest(settings.getVerificationEndpoint(), user.getUsername() + activationKey)); user.setValidationKey(activationKey); userFacade.update(user); }
public void setProjectOwnerAndQuotas(Project project, long diskspaceQuotaInMB, DistributedFileSystemOps dfso, Users user) throws IOException { this.yarnProjectsQuotaFacade.persistYarnProjectsQuota( new YarnProjectsQuota(project.getName(), Integer.parseInt( settings.getYarnDefaultQuota()), 0)); this.yarnProjectsQuotaFacade.flushEm(); setHdfsSpaceQuotasInMBs(project, diskspaceQuotaInMB, null, dfso); projectFacade.setTimestampQuotaUpdate(project, new Date()); //Add the activity information logActivity(ActivityFacade.NEW_PROJECT + project.getName(), ActivityFacade.FLAG_PROJECT, user, project); //update role information in project addProjectOwner(project.getId(), user.getEmail()); LOGGER.log(Level.FINE, "{0} - project created successfully.", project. getName()); }
/** * Reset password with random string and send email to user with the new password. * * @param user * @param req * @throws AppException * @throws MessagingException * @throws Exception */ public void resetPassword(Users user, HttpServletRequest req) throws AppException, MessagingException, Exception { if (user == null) { throw new IllegalArgumentException("User not set."); } if (userStatusValidator.isBlockedAccount(user)) { throw new IllegalStateException("User is blocked."); } String randomPassword = SecurityUtils.getRandomPassword(UserValidator.PASSWORD_MIN_LENGTH); String message = UserAccountsEmailMessages.buildTempResetMessage(randomPassword); emailBean.sendEmail(user.getEmail(), Message.RecipientType.TO, UserAccountsEmailMessages.ACCOUNT_PASSWORD_RESET, message); changePassword(user, randomPassword, req); resetFalseLogin(user); accountAuditFacade.registerAccountChange(user, AccountsAuditActions.RECOVERY.name(), UserAuditActions.SUCCESS. name(), "Password reset.", user, req); }
public ProjectDTO(Project project, Integer inodeid, List<String> services, List<ProjectTeam> projectTeam, List<InodeView> datasets) { this.projectId = project.getId(); //the inodeid of the current project comes from hops database this.inodeid = inodeid; this.projectName = project.getName(); this.owner = project.getOwner().getEmail(); this.retentionPeriod = project.getRetentionPeriod(); this.created = project.getCreated(); this.archived = project.getArchived(); this.description = project.getDescription(); this.services = services; this.projectTeam = projectTeam; this.datasets = datasets; }
public ProjectDTO(Project project, Integer inodeid, List<String> services, List<ProjectTeam> projectTeam, QuotasDTO quotas, String hopsExamples) { this.projectId = project.getId(); this.inodeid = inodeid; this.projectName = project.getName(); this.owner = project.getOwner().getEmail(); this.retentionPeriod = project.getRetentionPeriod(); this.created = project.getCreated(); this.archived = project.getArchived(); this.description = project.getDescription(); this.services = services; this.projectTeam = projectTeam; this.quotas = quotas; this.hopsExamples = hopsExamples; }
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public int createPythonKernelForProjectUser(Project project, Users user) { JupyterSettings js = jupyterSettingsFacade.findByProjectUser(project.getId(), user.getEmail()); String hdfsUser = hdfsUsersController.getHdfsUserName(project, user); String privateDir = this.settings.getJupyterDir() + Settings.DIR_ROOT + File.separator + project.getName() + File.separator + hdfsUser + File.separator + js.getSecret(); return executeJupyterCommand("kernel-add", privateDir, hdfsUser); }
public DataSetDTO(Dataset ds, Project project, List<String> sharedWith) { this.inodeId = ds.getInode().getId(); this.name = ds.getInode().getInodePK().getName(); this.description = ds.getDescription(); this.projectName = project.getName(); this.sharedWith = sharedWith; this.projectTeam = new ArrayList<>(); this.isPublic = ds.isPublicDs(); this.searchable = ds.isSearchable(); //this have to be done because project team contains too much info. for (ProjectTeam member : project.getProjectTeamCollection()) { projectTeam.add(new UserCardDTO(member.getUser().getFname(), member. getUser().getLname(), member.getUser().getEmail())); } this.type = ds.getType(); }