@Test(expected = SeedException.class) public void testDecryptWithoutPrivateKey() { final String toDecrypt = "ADEF0985C"; EncryptionServiceImpl asymetricCrypting = new EncryptionServiceImpl("alias", null, null); asymetricCrypting.decrypt(toDecrypt.getBytes()); }
@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);  }