@Test(expected = EncryptionException.class) public void testEncryptionException() throws Exception { String testString = "<ID>some sensitive data</ID> then some stuff then <ID>some sensitive data</ID>"; CryptoOp idOP = new CryptoOp("(?<=<ID>).*?(?=</ID>)", "unset", encryptionComponent); idOP.encrypt(testString); }
public String encrypt(String data) throws EncryptionException { Matcher matcher = pattern.matcher(data); StringBuffer encryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(encryptedData, encryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(encryptedData); return encryptedData.toString(); }
CryptoOp { public String encrypt(String data) throws EncryptionException { Matcher matcher = pattern.matcher(data); StringBuffer encryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(encryptedData, encryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(encryptedData); return encryptedData.toString(); } }
CryptoOp { public String encrypt(String data) throws EncryptionException { Matcher matcher = pattern.matcher(data); StringBuffer encryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(encryptedData, encryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(encryptedData); return encryptedData.toString(); } CryptoOp(String regex, String type, EncryptionComponent encryptionComponent);  CryptoOp(String regex, EncryptionComponent encryptionComponent); }
CryptoOp { public String encrypt(String data) throws EncryptionException { Matcher matcher = pattern.matcher(data); StringBuffer encryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(encryptedData, encryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(encryptedData); return encryptedData.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 encrypt(String data) throws EncryptionException { Matcher matcher = pattern.matcher(data); StringBuffer encryptedData = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(encryptedData, encryptOp(data.substring(matcher.start(), matcher.end()), type)); } matcher.appendTail(encryptedData); return encryptedData.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);  }