private static ProtoHumanAccountData serialize(HumanAccountData account) { Preconditions.checkNotNull(account, "account is null"); ProtoHumanAccountData.Builder builder = ProtoHumanAccountData.newBuilder(); if (account.getPasswordDigest() != null) { builder.setPasswordDigest(serialize(account.getPasswordDigest())); } return builder.build(); }
private DBObject humanToObject(HumanAccountData account) { DBObject object = new BasicDBObject(); PasswordDigest digest = account.getPasswordDigest(); if (digest != null) { DBObject digestObj = new BasicDBObject(); digestObj.put(PASSWORD_SALT_FIELD, digest.getSalt()); digestObj.put(PASSWORD_DIGEST_FIELD, digest.getDigest()); object.put(HUMAN_PASSWORD_FIELD, digestObj); } return object; }
} else if (!account.asHuman().getPasswordDigest().verify(password)) {
public void testPasswordDigestVerifies() { HumanAccountData account = new HumanAccountDataImpl(ParticipantId.ofUnsafe("captainhammer@example.com"), new PasswordDigest("wonderflownium".toCharArray())); assertNotNull(account.getPasswordDigest()); assertTrue(account.getPasswordDigest().verify("wonderflownium".toCharArray())); }
public void testPasswordDigestVerifies() { HumanAccountData account = new HumanAccountDataImpl(ParticipantId.ofUnsafe("captainhammer@example.com"), new PasswordDigest("wonderflownium".toCharArray())); assertNotNull(account.getPasswordDigest()); assertTrue(account.getPasswordDigest().verify("wonderflownium".toCharArray())); }
public void testRegisterNewUserEnabled() throws Exception { attemptToRegister(req, resp, "foo@example.com", "internet", false); verify(resp).setStatus(HttpServletResponse.SC_OK); ParticipantId participantId = ParticipantId.ofUnsafe("foo@example.com"); AccountData account = store.getAccount(participantId); assertNotNull(account); assertTrue(account.asHuman().getPasswordDigest().verify("internet".toCharArray())); verify(welcomeBot).greet(eq(participantId)); }
public void testUserWithNoPasswordHasNoPasswordDigest() { HumanAccountData account = new HumanAccountDataImpl(ParticipantId.ofUnsafe("moist@example.com")); assertNull(account.getPasswordDigest()); } }
public void testUserWithNoPasswordHasNoPasswordDigest() { HumanAccountData account = new HumanAccountDataImpl(ParticipantId.ofUnsafe("moist@example.com")); assertNull(account.getPasswordDigest()); } }
public void testRegisterNewUserEnabled() throws Exception { attemptToRegister(req, resp, "foo@example.com", "internet", false); verify(resp).setStatus(HttpServletResponse.SC_OK); ParticipantId participantId = ParticipantId.ofUnsafe("foo@example.com"); AccountData account = store.getAccount(participantId); assertNotNull(account); assertTrue(account.asHuman().getPasswordDigest().verify("internet".toCharArray())); verify(welcomeBot).greet(eq(participantId)); }
public void testNullPasswordWorks() throws Exception { attemptToRegister(req, resp, "zd@example.com", null, false); verify(resp).setStatus(HttpServletResponse.SC_OK); AccountData account = store.getAccount(ParticipantId.ofUnsafe("zd@example.com")); assertNotNull(account); assertTrue(account.asHuman().getPasswordDigest().verify("".toCharArray())); }
public void testNullPasswordWorks() throws Exception { attemptToRegister(req, resp, "zd@example.com", null, false); verify(resp).setStatus(HttpServletResponse.SC_OK); AccountData account = store.getAccount(ParticipantId.ofUnsafe("zd@example.com")); assertNotNull(account); assertTrue(account.asHuman().getPasswordDigest().verify("".toCharArray())); }
public final void testRoundtripHumanAccountWithPassword() throws Exception { AccountStore accountStore = newAccountStore(); accountStore.putAccount( new HumanAccountDataImpl(HUMAN_ID, new PasswordDigest("internet".toCharArray()))); AccountData retrievedAccount = accountStore.getAccount(HUMAN_ID); assertTrue(retrievedAccount.asHuman().getPasswordDigest().verify("internet".toCharArray())); }
public final void testRoundtripHumanAccountWithPassword() throws Exception { AccountStore accountStore = newAccountStore(); accountStore.putAccount( new HumanAccountDataImpl(HUMAN_ID, new PasswordDigest("internet".toCharArray()))); AccountData retrievedAccount = accountStore.getAccount(HUMAN_ID); assertTrue(retrievedAccount.asHuman().getPasswordDigest().verify("internet".toCharArray())); }