public synchronized boolean isDefaultAdminPasswordChanged() { if (ADMIN_PWD.compareTo(DEFAULT_ADMIN_PWD) != 0) { return true; } Users user = userFacade.findByEmail("admin@kth.se"); if (user != null) { ADMIN_PWD = user.getPassword(); } return ADMIN_PWD.compareTo(DEFAULT_ADMIN_PWD) != 0; }
userPassword = owner.getPassword(); } else if (UserCerts.class == cls) { throw new IOException(msg); userPassword = user.getPassword(); } else { String msg = "Unknown certificate type: " + cls.getName();
/** * 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; }
/** * Change password to the given password. Will generate a new salt * * @param user * @param password * @param req * @throws Exception */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public void changePassword(Users user, String password, HttpServletRequest req) throws Exception { String salt = generateSalt(); String passwordWithSalt = getPasswordHash(password, salt); String oldPassword = user.getPassword(); user.setPassword(passwordWithSalt); user.setSalt(salt); user.setPasswordChanged(new Timestamp(new Date().getTime())); userFacade.update(user); resetProjectCertPassword(user, oldPassword); }
public CertPwDTO getProjectWideCertPw(Users user, String projectGenericUsername, String keyStore) throws Exception { ProjectGenericUserCerts projectGenericUserCerts = userCertsFacade. findProjectGenericUserCerts(projectGenericUsername); if (projectGenericUserCerts == null) { throw new Exception("Found more than one or none project-wide " + "certificates for project " + projectGenericUsername); } String keypw = HopsUtils.decrypt(user.getPassword(), projectGenericUserCerts.getCertificatePassword(), certificatesMgmService.getMasterEncryptionPassword()); validateCert(Base64.decodeBase64(keyStore), keypw.toCharArray(), projectGenericUsername, false); CertPwDTO respDTO = new CertPwDTO(); respDTO.setKeyPw(keypw); respDTO.setTrustPw(keypw); return respDTO; }
newEncCertPassword = getNewUserPassword(user.getPassword(), oldPassword, oldMasterPassword, newMasterPassword); pguCert.setCertificatePassword(newEncCertPassword);
String userPwdHash = user.getPassword(); String pwdHash = getPasswordHash(password, user.getSalt()); if (!userPwdHash.equals(pwdHash)) {
public CertPwDTO getProjectSpecificCertPw(Users user, String projectName, String keyStore) throws Exception { //Compare the sent certificate with the one in the database String keypw = HopsUtils.decrypt(user.getPassword(), userCertsFacade.findUserCert(projectName, user.getUsername()). getUserKeyPwd(), certificatesMgmService.getMasterEncryptionPassword()); String projectUser = projectName + HdfsUsersController.USER_NAME_DELIMITER + user.getUsername(); validateCert(Base64.decodeBase64(keyStore), keypw.toCharArray(), projectUser, true); CertPwDTO respDTO = new CertPwDTO(); respDTO.setKeyPw(keypw); respDTO.setTrustPw(keypw); return respDTO; }
throw new Exception("Could not find Hopsworks user for certificate " + mapKey); newEncCertPassword = getNewUserPassword(user.getPassword(), oldPassword, oldMasterPassword, newMasterPassword); psCert.setUserKeyPwd(newEncCertPassword);
String certPassword = HopsUtils.decrypt(oldPass, userCert.getUserKeyPwd(), masterEncryptionPassword); String newSecret = HopsUtils.encrypt(p.getPassword(), certPassword, masterEncryptionPassword); userCert.setUserKeyPwd(newSecret); userCertsFacade.update(userCert); masterEncryptionPassword); String newPguSecret = HopsUtils.encrypt(p.getPassword(), pguCertPassword, masterEncryptionPassword); pguCert.setCertificatePassword(newPguSecret); userCertsFacade.updatePGUCert(pguCert);
boolean generateProjectWideCerts) throws Exception { String userKeyPwd = HopsUtils.randomString(64); String encryptedKey = HopsUtils.encrypt(user.getPassword(), userKeyPwd, certificatesMgmService.getMasterEncryptionPassword()); ReentrantLock lock = certificatesMgmService.getOpensslLock();