Package com.googlecode.memwords.domain

Examples of com.googlecode.memwords.domain.Account


    @Test
    public void testGetAccount() {
        String userId = "userId";
        implWithRealCryptoEngine.createAccount(userId, "masterPassword");

        Account account = impl.getAccount(userId);
        assertEquals(userId, account.getUserId());
        assertNull(impl.getAccount("userId2"));
    }
View Full Code Here


        replay(mockCryptoEngine);

        impl.createAccount(userId, masterPassword);

        Account account = em.find(Account.class, userId);
        assertEquals(userId, account.getUserId());
        assertTrue(account.getCards().isEmpty());
        assertTrue(Arrays.equals(hashedTwiceUserIdAndPassword, account.getMasterPassword()));
        assertTrue(Arrays.equals(encryptedSecretKey, account.getEncryptedSecretKey()));
        assertFalse(account.isPasswordsUnmasked());
        verify(mockCryptoEngine);
    }
View Full Code Here

        byte[] notHashedUserIdAndPassword = new byte[] {2, 3};
        byte[] hashedOnceUserIdAndPassword = new byte[] {3, 4};
        byte[] iv = new byte[] {5, 6};
        SecretKey wrappingKey = new SecretKeySpec(new byte[] {5, 6}, "AES");

        Account account = em.find(Account.class, userId);

        expect(mockCryptoEngine.stringToBytes(userId + masterPassword)).andStubReturn(notHashedUserIdAndPassword);
        expect(mockCryptoEngine.hash(aryEq(notHashedUserIdAndPassword))).andStubReturn(hashedOnceUserIdAndPassword);
        expect(mockCryptoEngine.hash(aryEq(hashedOnceUserIdAndPassword))).andStubReturn(account.getMasterPassword());
        expect(mockCryptoEngine.bytesToSecretKey(aryEq(hashedOnceUserIdAndPassword))).andReturn(wrappingKey);
        expect(mockCryptoEngine.buildInitializationVector(aryEq(wrappingKey.getEncoded()))).andReturn(iv);
        expect(mockCryptoEngine.decrypt(aryEq(account.getEncryptedSecretKey()), same(wrappingKey), aryEq(iv))).andReturn(encryptionKey);
        expect(mockCryptoEngine.bytesToSecretKey(encryptionKey)).andReturn(secretKey);

        replay(mockCryptoEngine);

        UserInformation loginUserInformation = impl.login(userId, masterPassword);
View Full Code Here

                                                   null,
                                                   null),
                                   userInfo.getEncryptionKey());

        implWithRealCryptoEngine.destroyAccount(userId);
        Account account = impl.getAccount(userId);
        assertNull(account);
        card = em.find(Card.class, card.getId());
        assertNull(card);
    }
View Full Code Here

TOP

Related Classes of com.googlecode.memwords.domain.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.