@Test(expected = DecryptionException.class) public void testDecryptionException() throws Exception { String testString = "<ID>encrypted {some sensitive data}</ID> then some stuff then <ID>encrypted {some other sensitive data}</ID>"; CryptoOp idOP = new CryptoOp("(?<=<ID>).*?(?=</ID>)", "unset", encryptionComponent); idOP.decrypt(testString); }
public String decrypt(String data) throws DecryptionException { Matcher matcher = pattern.matcher(data); StringBuffer decryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(decryptedData, decryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(decryptedData); return decryptedData.toString(); }
CryptoOp { public String decrypt(String data) throws DecryptionException { Matcher matcher = pattern.matcher(data); StringBuffer decryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(decryptedData, decryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(decryptedData); return decryptedData.toString(); } }
CryptoOp { public String decrypt(String data) throws DecryptionException { Matcher matcher = pattern.matcher(data); StringBuffer decryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(decryptedData, decryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(decryptedData); return decryptedData.toString(); } CryptoOp(String regex, String type, EncryptionComponent encryptionComponent);  CryptoOp(String regex, EncryptionComponent encryptionComponent); }
CryptoOp { public String decrypt(String data) throws DecryptionException { Matcher matcher = pattern.matcher(data); StringBuffer decryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(decryptedData, decryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(decryptedData); return decryptedData.toString(); } CryptoOp(String regex, String type, EncryptionComponent encryptionComponent);  CryptoOp(String regex, EncryptionComponent encryptionComponent); String getRegex(); String getType(); void setType(String type); String encrypt(String data); String decrypt(String data); }
CryptoOp { public String decrypt(String data) throws DecryptionException { Matcher matcher = pattern.matcher(data); StringBuffer decryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(decryptedData, decryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(decryptedData); return decryptedData.toString(); } CryptoOp(String regex, String type, EncryptionComponent encryptionComponent);  CryptoOp(String regex, EncryptionComponent encryptionComponent); String getRegex(); String getType(); void setType(String type); String encrypt(String data); String decrypt(String data);  }