/** * Change a user's password * A check should be made prior to this call to ensure a Profile exists * @param username the username * @param password the password */ public synchronized void setPassword(String username, String password) { UserProfile userProfile = getUserProfile(username); userProfile.setPassword(PasswordHasher.hashPassword(password)); try { uosw.store(userProfile); } catch (ObjectStoreException e) { throw new RuntimeException(e); } }
/** * Change a user's password * A check should be made prior to this call to ensure a Profile exists * @param username the username * @param password the password */ public synchronized void setPassword(String username, String password) { UserProfile userProfile = getUserProfile(username); userProfile.setPassword(PasswordHasher.hashPassword(password)); try { uosw.store(userProfile); } catch (ObjectStoreException e) { throw new RuntimeException(e); } }
/** * Creates a profile in the userprofile database without adding bag. * Method used by the ProfileReadXml. * * @param profile a Profile object */ public synchronized void createProfileWithoutBags(Profile profile) { UserProfile userProfile = new UserProfile(); userProfile.setUsername(profile.getUsername()); if (profile.getPassword() != null) { userProfile.setPassword(PasswordHasher.hashPassword(profile.getPassword())); } userProfile.setSuperuser(profile.isSuperUser); try { uosw.store(userProfile); profile.setUserId(userProfile.getId()); } catch (ObjectStoreException e) { throw new RuntimeException(e); } saveProfile(profile); }
/** * Creates a profile in the userprofile database without adding bag. * Method used by the ProfileReadXml. * * @param profile a Profile object */ public synchronized void createProfileWithoutBags(Profile profile) { UserProfile userProfile = new UserProfile(); userProfile.setUsername(profile.getUsername()); if (profile.getPassword() != null) { userProfile.setPassword(PasswordHasher.hashPassword(profile.getPassword())); } userProfile.setSuperuser(profile.isSuperUser); try { uosw.store(userProfile); profile.setUserId(userProfile.getId()); } catch (ObjectStoreException e) { throw new RuntimeException(e); } saveProfile(profile); }
/** * Creates a profile in the userprofile database. * * @param profile a Profile object */ public synchronized void createProfile(Profile profile) { UserProfile userProfile = new UserProfile(); userProfile.setUsername(profile.getUsername()); userProfile.setLocalAccount(profile.isLocal()); if (profile.isLocal() && profile.getPassword() != null) { userProfile.setPassword(PasswordHasher.hashPassword(profile.getPassword())); } userProfile.setSuperuser(profile.isSuperUser); try { uosw.store(userProfile); profile.setUserId(userProfile.getId()); for (InterMineBag bag : profile.getSavedBags().values()) { bag.setProfileId(userProfile.getId()); } } catch (ObjectStoreException e) { throw new RuntimeException(e); } saveProfile(profile); }
/** * Creates a profile in the userprofile database. * * @param profile a Profile object */ public synchronized void createProfile(Profile profile) { UserProfile userProfile = new UserProfile(); userProfile.setUsername(profile.getUsername()); userProfile.setLocalAccount(profile.isLocal()); if (profile.isLocal() && profile.getPassword() != null) { userProfile.setPassword(PasswordHasher.hashPassword(profile.getPassword())); } userProfile.setSuperuser(profile.isSuperUser); try { uosw.store(userProfile); profile.setUserId(userProfile.getId()); for (InterMineBag bag : profile.getSavedBags().values()) { bag.setProfileId(userProfile.getId()); } } catch (ObjectStoreException e) { throw new RuntimeException(e); } saveProfile(profile); }
public void test1() throws Exception { String hashed = PasswordHasher.hashPassword("flibble"); assertTrue(PasswordHasher.checkPassword("flibble", hashed)); assertFalse(PasswordHasher.checkPassword("flibble", "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")); assertTrue(PasswordHasher.checkPassword("flibble", "flibble")); assertFalse(PasswordHasher.checkPassword("flibble", hashed + " ")); assertFalse(PasswordHasher.checkPassword("flibble", "flobble")); } }