@Test public void testDecrypt(@Mocked final Key key, @Mocked final Cipher cipher) throws Exception { final String toDecrypt = "ADEF0985C"; EncryptionServiceImpl asymetricCrypting = new EncryptionServiceImpl("alias", null, key); asymetricCrypting.decrypt(toDecrypt.getBytes()); new Verifications() { { cipher.doFinal(toDecrypt.getBytes()); times = 1; } }; }
@Override public byte[] decrypt(byte[] toDecrypt) { if (this.privateKey == null) { throw SeedException.createNew(CryptoErrorCode.MISSING_PRIVATE_KEY).put("alias", alias); } return doEncryptionOrDecryption(toDecrypt, privateKey, Cipher.DECRYPT_MODE); }
EncryptionServiceImpl implements EncryptionService { @Override public byte[] decrypt(byte[] toDecrypt) { if (this.privateKey == null) { throw SeedException.createNew(CryptoErrorCode.MISSING_PRIVATE_KEY).put("alias", alias); } return doEncryptionOrDecryption(toDecrypt, privateKey, Cipher.DECRYPT_MODE); } }
EncryptionServiceImpl implements EncryptionService { @Override public byte[] decrypt(byte[] toDecrypt) { if (this.privateKey == null) { throw SeedException.createNew(CryptoErrorCode.MISSING_PRIVATE_KEY).put("alias", alias); } return doEncryptionOrDecryption(toDecrypt, privateKey, Cipher.DECRYPT_MODE); } EncryptionServiceImpl(String alias, PublicKey publicKey, Key privateKey); }
EncryptionServiceImpl implements EncryptionService { @Override public byte[] decrypt(byte[] toDecrypt) { if (this.privateKey == null) { throw SeedException.createNew(CryptoErrorCode.MISSING_PRIVATE_KEY).put("alias", alias); } return doEncryptionOrDecryption(toDecrypt, privateKey, Cipher.DECRYPT_MODE); } EncryptionServiceImpl(String alias, PublicKey publicKey, Key privateKey); @Override byte[] encrypt(byte[] toCrypt); @Override byte[] decrypt(byte[] toDecrypt); }
EncryptionServiceImpl implements EncryptionService { @Override public byte[] decrypt(byte[] toDecrypt) { if (this.privateKey == null) { throw SeedException.createNew(CryptoErrorCode.MISSING_PRIVATE_KEY).put("alias", alias); } return doEncryptionOrDecryption(toDecrypt, privateKey, Cipher.DECRYPT_MODE); } EncryptionServiceImpl(String alias, PublicKey publicKey, Key privateKey); @Override byte[] encrypt(byte[] toCrypt); @Override byte[] decrypt(byte[] toDecrypt);  }