public String preLdapLoginCheck(Users user, String password, HttpServletRequest req) { if (user == null) { throw new IllegalArgumentException("User not set."); } if (!user.getMode().equals(UserAccountType.LDAP_ACCOUNT_TYPE)) { throw new IllegalArgumentException("User is not registerd as ldap user."); } String newPassword = getPasswordPlusSalt(password, user.getSalt()) + Settings.MOBILE_OTP_PADDING; return newPassword; }
throw new IllegalArgumentException("User not set."); if (user.getMode().equals(UserAccountType.LDAP_ACCOUNT_TYPE)) { throw new IllegalArgumentException("Can not login ldap user. Use LDAP login."); if ((otp == null || otp.isEmpty()) && user.getMode().equals(UserAccountType.M_ACCOUNT_TYPE)) { if (checkPasswordAndStatus(user, password, req)) { throw new IllegalStateException("Second factor required."); if (otp == null || otp.isEmpty() && user.getMode().equals(UserAccountType.M_ACCOUNT_TYPE)) { otp = Settings.MOBILE_OTP_PADDING; if (otp.length() == Settings.MOBILE_OTP_PADDING.length() && user.getMode().equals(UserAccountType.M_ACCOUNT_TYPE)) { newPassword = newPassword + otp; } else {
/** * Validate security question and update false login attempts * * @param user * @param securityQ * @param securityAnswer * @param req * @return */ public boolean validateSecurityQA(Users user, String securityQ, String securityAnswer, HttpServletRequest req) { if (user == null) { throw new IllegalArgumentException("User not set."); } if (user.getMode().equals(UserAccountType.LDAP_ACCOUNT_TYPE)) { throw new IllegalArgumentException("Operation not allowed for LDAP account."); } if (securityQ == null || securityQ.isEmpty() || securityAnswer == null || securityAnswer.isEmpty()) { return false; } if (!user.getSecurityQuestion().getValue().equalsIgnoreCase(securityQ) || !user.getSecurityAnswer().equals(DigestUtils.sha256Hex(securityAnswer.toLowerCase()))) { registerFalseLogin(user, req); LOGGER.log(Level.WARNING, "False Security Question attempt by user: {0}", user.getEmail()); return false; } return true; }
/** * Validates password and update account audit. Use validatePwd if ldap user. * * @param user * @param password * @param req * @return */ public boolean validatePassword(Users user, String password, HttpServletRequest req) { if (user == null) { throw new IllegalArgumentException("User not set."); } if (user.getMode().equals(UserAccountType.LDAP_ACCOUNT_TYPE)) { throw new IllegalArgumentException("Operation not allowed for LDAP account."); } String userPwdHash = user.getPassword(); String pwdHash = getPasswordHash(password, user.getSalt()); if (!userPwdHash.equals(pwdHash)) { registerFalseLogin(user, req); LOGGER.log(Level.WARNING, "False login attempt by user: {0}", user.getEmail()); return false; } resetFalseLogin(user); return true; }
throw new IllegalArgumentException("User not set."); if (user.getMode().equals(UserAccountType.LDAP_ACCOUNT_TYPE)) { LdapUser ldapUser = ldapUserFacade.findByUsers(user); if (ldapUser == null) {
public UserDTO(Users user) { this.username = user.getUsername(); this.email = user.getEmail(); this.firstName = user.getFname(); this.lastName = user.getLname(); this.telephoneNum = user.getMobile(); if (user.getOrganization() != null) { this.orgName = user.getOrganization().getOrgName(); this.dep = user.getOrganization().getDepartment(); } if (user.getAddress() != null) { this.street = user.getAddress().getAddress2(); this.city = user.getAddress().getCity(); this.postCode = user.getAddress().getPostalcode(); this.country = user.getAddress().getCountry(); } this.maxNumProjects = user.getMaxNumProjects(); this.numCreatedProjects = user.getNumCreatedProjects(); this.twoFactor = user.getTwoFactor(); this.toursState = user.getToursState(); this.userAccountType = user.getMode().toString(); this.numActiveProjects = user.getNumActiveProjects(); numRemainingProjects = maxNumProjects-numCreatedProjects; }