@@ -32,13 +32,13 @@ public function __construct(
3232 */
3333 public function parseAndProcessStringAsCXml (string $ xml , ?Context $ context = null ): ?CXml
3434 {
35- $ this ->logger ->info ('Processing incoming CXml message ' , ['xml ' => $ xml ]);
35+ $ this ->logger ->info ('Processing incoming CXml message ' , ['xml ' => $ this -> removeSharedSecret ( $ xml) ]);
3636
3737 // validate
3838 try {
3939 $ this ->dtdValidator ->validateAgainstDtd ($ xml );
4040 } catch (CXmlInvalidException $ cXmlInvalidException ) {
41- $ this ->logger ->error ('Incoming CXml was invalid (via DTD) ' , ['xml ' => $ xml ]);
41+ $ this ->logger ->error ('Incoming CXml was invalid (via DTD) ' , ['xml ' => $ this -> removeSharedSecret ( $ xml) ]);
4242
4343 throw $ cXmlInvalidException ;
4444 }
@@ -47,7 +47,7 @@ public function parseAndProcessStringAsCXml(string $xml, ?Context $context = nul
4747 try {
4848 $ cxml = $ this ->serializer ->deserialize ($ xml );
4949 } catch (RuntimeException $ runtimeException ) {
50- $ this ->logger ->error ('Error while deserializing xml to CXml: ' . $ runtimeException ->getMessage (), ['xml ' => $ xml ]);
50+ $ this ->logger ->error ('Error while deserializing xml to CXml: ' . $ runtimeException ->getMessage (), ['xml ' => $ this -> removeSharedSecret ( $ xml) ]);
5151
5252 throw new CXmlInvalidException ('Error while deserializing xml: ' . $ runtimeException ->getMessage (), $ xml , $ runtimeException );
5353 }
@@ -56,13 +56,18 @@ public function parseAndProcessStringAsCXml(string $xml, ?Context $context = nul
5656 try {
5757 $ result = $ this ->processor ->process ($ cxml , $ context );
5858 } catch (CXmlException $ cXmlException ) {
59- $ this ->logger ->error ('Error while processing valid CXml: ' . $ cXmlException ->getMessage (), ['xml ' => $ xml ]);
59+ $ this ->logger ->error ('Error while processing valid CXml: ' . $ cXmlException ->getMessage (), ['xml ' => $ this -> removeSharedSecret ( $ xml) ]);
6060
6161 throw $ cXmlException ;
6262 }
6363
64- $ this ->logger ->info ('Success after processing incoming CXml message ' , ['xml ' => $ xml ]);
64+ $ this ->logger ->info ('Success after processing incoming CXml message ' , ['xml ' => $ this -> removeSharedSecret ( $ xml) ]);
6565
6666 return $ result ;
6767 }
68+
69+ private function removeSharedSecret (string $ xml ): string
70+ {
71+ return (string )preg_replace ('/<SharedSecret>.*?<\/SharedSecret>/s ' , '<SharedSecret>***REDACTED***</SharedSecret> ' , $ xml );
72+ }
6873}
0 commit comments