PasswordEncryptionService extends InternalEncryptionService { @Override public KeyProxy createKeyProxy(final EncryptionKeyMetadata encryptionKeyMetadata) { return passwordKeyProxyFactory.createPasswordKeyProxy(encryptionKeyMetadata, this); } PasswordEncryptionService(final PasswordKeyProxyFactory passwordKeyProxyFactory); @Override CipherWrapper getCipher(); @Override AlgorithmParameterSpec generateParameterSpec(final byte[] nonce); @Override KeyProxy createKeyProxy(final EncryptionKeyMetadata encryptionKeyMetadata); static final int GCM_TAG_LENGTH; }
@Test public void createsPasswordBasedKeyProxy() throws Exception { final PasswordEncryptionService subject = new PasswordEncryptionService(new TestPasswordKeyProxyFactory()); final EncryptionKeyMetadata keyMetadata = new EncryptionKeyMetadata(); keyMetadata.setEncryptionPassword("foobar"); final KeyProxy keyProxy = subject.createKeyProxy(keyMetadata); assertThat(keyProxy, instanceOf(PasswordBasedKeyProxy.class)); }