@Test public void TestHashDirectoryId() { final FileNameCryptor mock = mock(FileNameCryptor.class); final CryptorCache cryptor = new CryptorCache(mock); when(mock.hashDirectoryId(anyString())).thenReturn("hashed"); assertEquals("hashed", cryptor.hashDirectoryId("id")); assertEquals("hashed", cryptor.hashDirectoryId("id")); verify(mock, times(1)).hashDirectoryId(anyString()); verifyNoMoreInteractions(mock); }
public String hashDirectoryId(final String cleartextDirectoryId) { if(!directoryIdCache.contains(cleartextDirectoryId)) { directoryIdCache.put(cleartextDirectoryId, impl.hashDirectoryId(cleartextDirectoryId)); } return directoryIdCache.get(cleartextDirectoryId); }
CryptorCache { public String hashDirectoryId(final String cleartextDirectoryId) { if(!directoryIdCache.contains(cleartextDirectoryId)) { directoryIdCache.put(cleartextDirectoryId, impl.hashDirectoryId(cleartextDirectoryId)); } return directoryIdCache.get(cleartextDirectoryId); } }
CryptorCache { public String hashDirectoryId(final String cleartextDirectoryId) { if(!directoryIdCache.contains(cleartextDirectoryId)) { directoryIdCache.put(cleartextDirectoryId, impl.hashDirectoryId(cleartextDirectoryId)); } return directoryIdCache.get(cleartextDirectoryId); } CryptorCache(final FileNameCryptor impl); }
CryptorCache { public String hashDirectoryId(final String cleartextDirectoryId) { if(!directoryIdCache.contains(cleartextDirectoryId)) { directoryIdCache.put(cleartextDirectoryId, impl.hashDirectoryId(cleartextDirectoryId)); } return directoryIdCache.get(cleartextDirectoryId); } CryptorCache(final FileNameCryptor impl); String hashDirectoryId(final String cleartextDirectoryId); String encryptFilename(final BaseEncoding encoding, final String cleartextName, final byte[] associatedData); String decryptFilename(final BaseEncoding encoding, final String ciphertextName, final byte[] associatedData); }
CryptorCache { public String hashDirectoryId(final String cleartextDirectoryId) { if(!directoryIdCache.contains(cleartextDirectoryId)) { directoryIdCache.put(cleartextDirectoryId, impl.hashDirectoryId(cleartextDirectoryId)); } return directoryIdCache.get(cleartextDirectoryId); } CryptorCache(final FileNameCryptor impl); String hashDirectoryId(final String cleartextDirectoryId); String encryptFilename(final BaseEncoding encoding, final String cleartextName, final byte[] associatedData); String decryptFilename(final BaseEncoding encoding, final String ciphertextName, final byte[] associatedData); static final BaseEncoding BASE32; }