AESEncryption { public static String decrypt(final String src) throws GeneralSecurityException { final Cipher c = Cipher.getInstance(ALGO); c.init(Cipher.DECRYPT_MODE, secretKey); final byte[] decodedValue = Base64.getDecoder().decode(src); final byte[] decValue = c.doFinal(decodedValue); try { return new String(decValue, ENCODING); } catch (UnsupportedEncodingException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } } private  AESEncryption(); static String encrypt(final String src); static String decrypt(final String src); static String decryptUriPassword(final String rawUri); static String encryptUriPassword(final String rawUri); static String decrypt(final String name, final String src);  }
@Test(expected = IllegalBlockSizeException.class) public void should_throw_an_exception_when_trying_to_decrypt_a_non_encrypted_value() throws Exception { String src = "Dataprep"; String encrypted = AESEncryption.decrypt(src); Assert.fail("should not reach this point"); }