@Test public void testDecrypt() throws Exception { String testString1 = "<ID>encrypted {some sensitive data}</ID> and then some data and then <CARD>encrypted {some card data}</CARD> and some more data and then <CARD>encrypted {some other card data}</CARD> and then finally <ID>encrypted {some other sensitive data}</ID> and the something."; CryptoOp idOp = new CryptoOp("(?<=<ID>).*?(?=</ID>)", TEST_ENCRYPT, encryptionComponent); assertTrue(idOp.decrypt(testString1).contentEquals("<ID>some sensitive data</ID> and then some data and then <CARD>encrypted {some card data}</CARD> and some more data and then <CARD>encrypted {some other card data}</CARD> and then finally <ID>some other sensitive data</ID> and the something.")); }
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);  }