/usr/include/shibsp/TransactionLog.h is in libshibsp-dev 2.5.3+dfsg-2.1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | /**
* Licensed to the University Corporation for Advanced Internet
* Development, Inc. (UCAID) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*/
/**
* @file shibsp/TransactionLog.h
*
* Formatted event record logging.
*/
#if !defined (__shibsp_txlog_h__) && !defined(SHIBSP_LITE)
#define __shibsp_txlog_h__
#include <shibsp/base.h>
#include <xmltooling/logging.h>
#include <xmltooling/Lockable.h>
#include <xmltooling/io/GenericRequest.h>
#include <map>
#include <vector>
#include <iostream>
#include <boost/scoped_ptr.hpp>
namespace xmltooling {
class XMLTOOL_API Mutex;
};
namespace opensaml {
namespace saml1 {
class SAML_API AuthenticationStatement;
};
namespace saml1p {
class SAML_API Response;
};
namespace saml2 {
class SAML_API AuthnStatement;
class SAML_API NameID;
};
namespace saml2p {
class SAML_API AuthnRequest;
class SAML_API LogoutRequest;
class SAML_API LogoutResponse;
class SAML_API StatusResponseType;
};
namespace saml2md {
class SAML_API EntityDescriptor;
};
};
namespace shibsp {
class SHIBSP_API Application;
class SHIBSP_API Attribute;
class SHIBSP_API Session;
/**
* Interface to a synchronized event/audit logging object.
*
* <p>For backward compatibility, we expose a logging object directly, but
* new applications should rely on the Event callback API.
*/
class SHIBSP_API TransactionLog : public virtual xmltooling::Lockable
{
MAKE_NONCOPYABLE(TransactionLog);
public:
/**
* Constructor.
*
* @param fmt formatting string for events
* @param absent string to output when a field is empty
*/
TransactionLog(const char* fmt=nullptr, const char* absent=nullptr);
virtual ~TransactionLog();
xmltooling::Lockable* lock();
void unlock();
/** @deprecated Logging object. */
xmltooling::logging::Category& log;
/**
* Callback interface that outputs an event record to a stream using formatting tokens.
*/
class SHIBSP_API Event {
MAKE_NONCOPYABLE(Event);
protected:
/** Function that handles a formatting token. */
typedef bool (*handler_fn)(const Event& e, std::ostream&);
/** Map of tokens to handlers. */
std::map<std::string, handler_fn> m_handlers;
/**
* Constructor.
*/
Event();
public:
virtual ~Event();
/**
* Returns a type string to be used for the log category in the event log.
*
* @return type or category for the event
*/
virtual const char* getType() const=0;
/** Exception */
const std::exception* m_exception;
/** Request object associated with event. */
const xmltooling::GenericRequest* m_request;
/** Application object associated with event. */
const Application* m_app;
/** Session identifier. */
const char* m_sessionID;
/** Peer entity associated with event. */
const opensaml::saml2md::EntityDescriptor* m_peer;
/** Protocol associated with event. */
const char* m_protocol;
/** Protocol binding associated with event. */
const char* m_binding;
/** SAML 2.0 NameID. */
const opensaml::saml2::NameID* m_nameID;
/**
* Outputs an event record to a stream based on the defined formatting string.
*
* @param out stream to use
* @param field field to output
* @param absent string to output if the field is empty
* @return true iff the field was recognized and substituted
*/
virtual bool write(std::ostream& out, const char* field, const char* absent) const;
};
/**
* Write a formatted event record to the log.
* <p>This method is internally synchronized and the caller does <strong>NOT</strong>
* need to explicitly lock and unlock the object.
*
* @param e event to log
*/
virtual void write(const Event& e);
private:
boost::scoped_ptr<xmltooling::Mutex> m_lock;
std::string m_absent;
std::vector<std::string> m_formatting;
};
class SHIBSP_API LoginEvent : public TransactionLog::Event
{
public:
/**
* Constructor.
*/
LoginEvent();
virtual ~LoginEvent();
const char* getType() const;
/** SAML 2.0 AuthnStatement. */
const opensaml::saml2::AuthnStatement* m_saml2AuthnStatement;
/** SAML 2.0 Response. */
const opensaml::saml2p::StatusResponseType* m_saml2Response;
/** SAML 1.x AuthnStatement. */
const opensaml::saml1::AuthenticationStatement* m_saml1AuthnStatement;
/** SAML 1.x Response. */
const opensaml::saml1p::Response* m_saml1Response;
/** Attributes associated with event. */
const std::vector<Attribute*>* m_attributes;
};
class SHIBSP_API LogoutEvent : public TransactionLog::Event
{
public:
/**
* Constructor.
*/
LogoutEvent();
virtual ~LogoutEvent();
const char* getType() const;
/** Result of logout (local, global, partial). */
enum logout_type_t {
LOGOUT_EVENT_UNKNOWN,
LOGOUT_EVENT_INVALID,
LOGOUT_EVENT_LOCAL,
LOGOUT_EVENT_GLOBAL,
LOGOUT_EVENT_PARTIAL
} m_logoutType;
/** SAML 2.0 Request. */
const opensaml::saml2p::LogoutRequest* m_saml2Request;
/** SAML 2.0 Response. */
const opensaml::saml2p::LogoutResponse* m_saml2Response;
/** Primary session associated with event. */
const Session* m_session;
/** All sessions associated with event. */
std::vector<std::string> m_sessions;
};
class SHIBSP_API AuthnRequestEvent : public TransactionLog::Event
{
public:
/**
* Constructor.
*/
AuthnRequestEvent();
virtual ~AuthnRequestEvent();
const char* getType() const;
/** SAML 2.0 Request. */
const opensaml::saml2p::AuthnRequest* m_saml2Request;
};
/**
* Registers Event classes into the runtime.
*/
void SHIBSP_API registerEvents();
/** Login event. */
#define LOGIN_EVENT "Login"
/** Logout event. */
#define LOGOUT_EVENT "Logout"
/** AuthnRequest event. */
#define AUTHNREQUEST_EVENT "AuthnRequest"
};
#endif /* __shibsp_txlog_h__ */
|