+
+# ifdef XMLTOOLING_XMLSEC_DEBUGLOGGING
+ class TXFMOutputLog : public TXFMBase {
+ TXFMOutputLog();
+ public:
+ TXFMOutputLog(DOMDocument* doc) : TXFMBase(doc), m_log(Category::getInstance(XMLTOOLING_LOGCAT".Signature.Debugger")) {
+ input = nullptr;
+ }
+ ~TXFMOutputLog() {
+ m_log.debug("\n----- END SIGNATURE DEBUG -----\n");
+ }
+
+ void setInput(TXFMBase *newInput) {
+ input = newInput;
+ if (newInput->getOutputType() != TXFMBase::BYTE_STREAM)
+ throw XSECException(XSECException::TransformInputOutputFail, "OutputLog transform requires BYTE_STREAM input");
+ keepComments = input->getCommentsStatus();
+ m_log.debug("\n----- BEGIN SIGNATURE DEBUG -----\n");
+ }
+
+ TXFMBase::ioType getInputType() {
+ return TXFMBase::BYTE_STREAM;
+ }
+ TXFMBase::ioType getOutputType() {
+ return TXFMBase::BYTE_STREAM;
+ }
+ TXFMBase::nodeType getNodeType() {
+ return TXFMBase::DOM_NODE_NONE;
+ }
+
+ unsigned int readBytes(XMLByte * const toFill, const unsigned int maxToFill) {
+ unsigned int sz = input->readBytes(toFill, maxToFill);
+ m_log.debug(string(reinterpret_cast<char* const>(toFill), sz));
+ return sz;
+ }
+
+ DOMDocument* getDocument() {
+ return nullptr;
+ }
+ DOMNode* getFragmentNode() {
+ return nullptr;
+ }
+ const XMLCh* getFragmentId() {
+ return nullptr;
+ }
+
+ private:
+ Category& m_log;
+ };
+
+ TXFMBase* TXFMOutputLogFactory(DOMDocument* doc) {
+ if (Category::getInstance(XMLTOOLING_LOGCAT".Signature.Debugger").isDebugEnabled())
+ return new TXFMOutputLog(doc);
+ return nullptr;
+ }
+# endif
+
+#endif
+
+#ifdef WIN32
+ BOOL LogEvent(
+ LPCSTR lpUNCServerName,
+ WORD wType,
+ DWORD dwEventID,
+ PSID lpUserSid,
+ LPCSTR message)
+ {
+ LPCSTR messages[] = {message, nullptr};
+
+ HANDLE hElog = RegisterEventSource(lpUNCServerName, "OpenSAML XMLTooling Library");
+ BOOL res = ReportEvent(hElog, wType, 0, dwEventID, lpUserSid, 1, 0, messages, nullptr);
+ return (DeregisterEventSource(hElog) && res);
+ }