Guest User

Untitled

a guest
Oct 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. private String migrateFlowXmlContent(String flowXmlContent, String existingFlowPassword, String newFlowPassword, String existingAlgorithm = DEFAULT_FLOW_ALGORITHM, String existingProvider = DEFAULT_PROVIDER, String newAlgorithm = DEFAULT_FLOW_ALGORITHM, String newProvider = DEFAULT_PROVIDER) {
  2. /* ... */
  3. // additional logging statement that got added
  4. flowXmlContent.findAll(WRAPPED_FLOW_XML_CIPHER_TEXT_REGEX) {String wrappedCipherText ->
  5. logger.warn("Original: "+wrappedCipherText+"\t Decrypted:"+decryptFlowElement(wrappedCipherText, existingFlowPassword, existingAlgorithm, existingProvider))
  6. }
  7.  
  8. // Scan the XML content and identify every encrypted element, decrypt it, and replace it with the re-encrypted value
  9. String migratedFlowXmlContent = flowXmlContent.replaceAll(WRAPPED_FLOW_XML_CIPHER_TEXT_REGEX) { String wrappedCipherText ->
  10. String plaintext = decryptFlowElement(wrappedCipherText, existingFlowPassword, existingAlgorithm, existingProvider)
  11. byte[] cipherBytes = encryptCipher.doFinal(plaintext.bytes)
  12. byte[] saltAndCipherBytes = concatByteArrays(encryptionSalt, cipherBytes)
  13. elementCount++
  14. "enc{${Hex.encodeHex(saltAndCipherBytes)}}"
  15. }
  16. /* ... */
  17. migratedFlowXmlContent
  18. }
Add Comment
Please, Sign In to add comment