const HTTPRequest& httpRequest,
HTTPResponse& httpResponse,
time_t expires,
- const saml2md::EntityDescriptor* issuer=NULL,
- const XMLCh* protocol=NULL,
- const saml2::NameID* nameid=NULL,
- const XMLCh* authn_instant=NULL,
- const XMLCh* session_index=NULL,
- const XMLCh* authncontext_class=NULL,
- const XMLCh* authncontext_decl=NULL,
- const vector<const Assertion*>* tokens=NULL,
- const vector<Attribute*>* attributes=NULL
+ const saml2md::EntityDescriptor* issuer=nullptr,
+ const XMLCh* protocol=nullptr,
+ const saml2::NameID* nameid=nullptr,
+ const XMLCh* authn_instant=nullptr,
+ const XMLCh* session_index=nullptr,
+ const XMLCh* authncontext_class=nullptr,
+ const XMLCh* authncontext_decl=nullptr,
+ const vector<const Assertion*>* tokens=nullptr,
+ const vector<Attribute*>* attributes=nullptr
);
vector<string>::size_type logout(
const Application& application,
const set<string>* indexes
);
#endif
- Session* find(const Application& application, const char* key, const char* client_addr=NULL, time_t* timeout=NULL);
+ Session* find(const Application& application, const char* key, const char* client_addr=nullptr, time_t* timeout=nullptr);
void remove(const Application& application, const char* key);
void test();
return (session_id ? session_id : "");
}
- Session* find(const Application& application, const HTTPRequest& request, const char* client_addr=NULL, time_t* timeout=NULL) {
+ Session* find(const Application& application, const HTTPRequest& request, const char* client_addr=nullptr, time_t* timeout=nullptr) {
string id = active(application, request);
if (!id.empty())
return find(application, id.c_str(), client_addr, timeout);
- return NULL;
+ return nullptr;
}
- Session* find(const Application& application, HTTPRequest& request, const char* client_addr=NULL, time_t* timeout=NULL) {
+ Session* find(const Application& application, HTTPRequest& request, const char* client_addr=nullptr, time_t* timeout=nullptr) {
string id = active(application, request);
if (id.empty())
- return NULL;
+ return nullptr;
try {
Session* session = find(application, id.c_str(), client_addr, timeout);
if (session)
}
throw;
}
- return NULL;
+ return nullptr;
}
- void remove(const Application& application, const HTTPRequest& request, HTTPResponse* response=NULL) {
+ void remove(const Application& application, const HTTPRequest& request, HTTPResponse* response=nullptr) {
pair<string,const char*> shib_cookie = application.getCookieNameProps("_shibsession_");
const char* session_id = request.getCookie(shib_cookie.first.c_str());
if (session_id && *session_id) {
public:
StoredSession(SSCache* cache, DDF& obj) : m_obj(obj),
#ifndef SHIBSP_LITE
- m_nameid(NULL),
+ m_nameid(nullptr),
#endif
- m_cache(cache), m_expires(0), m_lastAccess(time(NULL)), m_lock(NULL) {
+ m_cache(cache), m_expires(0), m_lastAccess(time(nullptr)), m_lock(nullptr) {
auto_ptr_XMLCh exp(m_obj["expires"].string());
if (exp.get()) {
DateTime iso(exp.get());
void StoredSession::validate(const Application& application, const char* client_addr, time_t* timeout)
{
- time_t now = time(NULL);
+ time_t now = time(nullptr);
// Basic expiration?
if (m_expires > 0) {
else if (ver < 0) {
// Out of sync.
m_cache->m_log.warn("storage service indicates the record is out of sync, updating with a fresh copy...");
- ver = m_cache->m_storage->readText(getID(), "session", &record, NULL);
+ ver = m_cache->m_storage->readText(getID(), "session", &record, nullptr);
if (!ver) {
m_cache->m_log.error("readText failed on StorageService for session (%s)", getID());
throw IOException("Unable to read back stored session.");
return i->second;
string tokenstr;
- if (!m_cache->m_storage->readText(getID(), id, &tokenstr, NULL))
+ if (!m_cache->m_storage->readText(getID(), id, &tokenstr, nullptr))
throw FatalProfileException("Assertion not found in cache.");
// Parse and bind the document into an XMLObject.
m_cache->m_log.debug("adding assertion (%s) to session (%s)", id.get(), getID());
time_t exp;
- if (!m_cache->m_storage->readText(getID(), "session", NULL, &exp))
+ if (!m_cache->m_storage->readText(getID(), "session", nullptr, &exp))
throw IOException("Unable to load expiration time for stored session.");
ostringstream tokenstr;
int ver;
do {
- DDF token = DDF(NULL).string(id.get());
+ DDF token = DDF(nullptr).string(id.get());
m_obj["assertions"].add(token);
// Tentatively increment the version.
else if (ver < 0) {
// Out of sync.
m_cache->m_log.warn("storage service indicates the record is out of sync, updating with a fresh copy...");
- ver = m_cache->m_storage->readText(getID(), "session", &record, NULL);
+ ver = m_cache->m_storage->readText(getID(), "session", &record, nullptr);
if (!ver) {
m_cache->m_log.error("readText failed on StorageService for session (%s)", getID());
m_cache->m_storage->deleteText(getID(), id.get());
SSCache::SSCache(const DOMElement* e)
: m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), inproc(true), m_cacheTimeout(28800),
#ifndef SHIBSP_LITE
- m_storage(NULL), m_storage_lite(NULL), m_cacheAssertions(true),
+ m_storage(nullptr), m_storage_lite(nullptr), m_cacheAssertions(true),
#endif
- m_root(e), m_inprocTimeout(900), m_lock(NULL), shutdown(false), shutdown_wait(NULL), cleanup_thread(NULL)
+ m_root(e), m_inprocTimeout(900), m_lock(nullptr), shutdown(false), shutdown_wait(nullptr), cleanup_thread(nullptr)
{
static const XMLCh cacheAssertions[] = UNICODE_LITERAL_15(c,a,c,h,e,A,s,s,e,r,t,i,o,n,s);
static const XMLCh cacheTimeout[] = UNICODE_LITERAL_12(c,a,c,h,e,T,i,m,e,o,u,t);
inproc = conf.isEnabled(SPConfig::InProcess);
if (e) {
- const XMLCh* tag=e->getAttributeNS(NULL,cacheTimeout);
+ const XMLCh* tag=e->getAttributeNS(nullptr,cacheTimeout);
if (tag && *tag) {
m_cacheTimeout = XMLString::parseInt(tag);
if (!m_cacheTimeout)
m_cacheTimeout=28800;
}
if (inproc) {
- const XMLCh* tag=e->getAttributeNS(NULL,inprocTimeout);
+ const XMLCh* tag=e->getAttributeNS(nullptr,inprocTimeout);
if (tag && *tag) {
m_inprocTimeout = XMLString::parseInt(tag);
if (!m_inprocTimeout)
#ifndef SHIBSP_LITE
if (conf.isEnabled(SPConfig::OutOfProcess)) {
- const XMLCh* tag = e ? e->getAttributeNS(NULL,_StorageService) : NULL;
+ const XMLCh* tag = e ? e->getAttributeNS(nullptr,_StorageService) : nullptr;
if (tag && *tag) {
auto_ptr_char ssid(tag);
m_storage = conf.getServiceProvider()->getStorageService(ssid.get());
if (!m_storage)
throw ConfigurationException("SessionCache unable to locate StorageService, check configuration.");
- tag = e ? e->getAttributeNS(NULL,_StorageServiceLite) : NULL;
+ tag = e ? e->getAttributeNS(nullptr,_StorageServiceLite) : nullptr;
if (tag && *tag) {
auto_ptr_char ssid(tag);
m_storage_lite = conf.getServiceProvider()->getStorageService(ssid.get());
m_log.info("No StorageServiceLite specified. Using standard StorageService.");
m_storage_lite = m_storage;
}
- tag = e ? e->getAttributeNS(NULL, cacheAssertions) : NULL;
+ tag = e ? e->getAttributeNS(nullptr, cacheAssertions) : nullptr;
if (tag && (*tag == chLatin_f || *tag == chDigit_0))
m_cacheAssertions = false;
}
// Shut down the cleanup thread and let it know...
shutdown = true;
shutdown_wait->signal();
- cleanup_thread->join(NULL);
+ cleanup_thread->join(nullptr);
for_each(m_hashtable.begin(),m_hashtable.end(),cleanup_pair<string,StoredSession>());
delete m_lock;
void SSCache::test()
{
auto_ptr_char temp(SAMLConfig::getConfig().generateIdentifier());
- m_storage->createString("SessionCacheTest", temp.get(), "Test", time(NULL) + 60);
+ m_storage->createString("SessionCacheTest", temp.get(), "Test", time(nullptr) + 60);
m_storage->deleteString("SessionCacheTest", temp.get());
}
}
else {
// New record.
- obj = DDF(NULL).structure();
+ obj = DDF(nullptr).structure();
}
if (!index || !*index)
DDF sessions = obj.addmember(index);
if (!sessions.islist())
sessions.list();
- DDF session = DDF(NULL).string(key);
+ DDF session = DDF(nullptr).string(key);
sessions.add(session);
// Remarshall the record.
m_log.debug("creating new session");
- time_t now = time(NULL);
+ time_t now = time(nullptr);
auto_ptr_char index(session_index);
- auto_ptr_char entity_id(issuer ? issuer->getEntityID() : NULL);
- auto_ptr_char name(nameid ? nameid->getName() : NULL);
+ auto_ptr_char entity_id(issuer ? issuer->getEntityID() : nullptr);
+ auto_ptr_char name(nameid ? nameid->getName() : nullptr);
if (nameid) {
// Check for a pending logout.
// IdP.SP.index contains logout expiration, if any.
DDF deadmenwalking = pendobj[issuer ? entity_id.get() : "_shibnull"][application.getRelyingParty(issuer)->getString("entityID").second];
const char* logexpstr = deadmenwalking[session_index ? index.get() : "_shibnull"].string();
- if (!logexpstr && session_index) // we tried an exact session match, now try for NULL
+ if (!logexpstr && session_index) // we tried an exact session match, now try for nullptr
logexpstr = deadmenwalking["_shibnull"].string();
if (logexpstr) {
auto_ptr_XMLCh dt(logexpstr);
obj.addmember("assertions").list();
for (vector<const Assertion*>::const_iterator t = tokens->begin(); t!=tokens->end(); ++t) {
auto_ptr_char tokenid((*t)->getID());
- DDF tokid = DDF(NULL).string(tokenid.get());
+ DDF tokid = DDF(nullptr).string(tokenid.get());
obj["assertions"].add(tokid);
}
}
const set<string>* indexes
)
{
- auto_ptr_char entityID(issuer ? issuer->getEntityID() : NULL);
+ auto_ptr_char entityID(issuer ? issuer->getEntityID() : nullptr);
try {
Session* session = find(application, request);
if (session) {
if (!m_storage)
throw ConfigurationException("SessionCache insertion requires a StorageService.");
- auto_ptr_char entityID(issuer ? issuer->getEntityID() : NULL);
+ auto_ptr_char entityID(issuer ? issuer->getEntityID() : nullptr);
auto_ptr_char name(nameid.getName());
m_log.info("request to logout sessions from (%s) for (%s)", entityID.get() ? entityID.get() : "unknown", name.get());
lin >> obj;
}
else {
- obj = DDF(NULL).structure();
+ obj = DDF(nullptr).structure();
}
// Structure is keyed by the IdP and SP, with a member per session index containing the expiration.
key = sessions.first();
while (key.isstring()) {
// Fetch the session for comparison.
- Session* session = NULL;
+ Session* session = nullptr;
try {
session = find(application, key.string());
}
#ifdef _DEBUG
xmltooling::NDC ndc("find");
#endif
- StoredSession* session=NULL;
+ StoredSession* session=nullptr;
if (inproc) {
m_log.debug("searching local cache for session (%s)", key);
if (!out.isstruct()) {
out.destroy();
m_log.debug("session not found in remote cache");
- return NULL;
+ return nullptr;
}
// Wrap the results in a local entry and save it.
session = new StoredSession(this, out);
// The remote end has handled timeout issues, we handle address and expiration checks.
- timeout = NULL;
+ timeout = nullptr;
}
catch (...) {
out.destroy();
string record;
int ver = m_storage->readText(key, "session", &record, &lastAccess);
if (!ver)
- return NULL;
+ return nullptr;
m_log.debug("reconstituting session and checking validity");
in >> obj;
lastAccess -= m_cacheTimeout; // adjusts it back to the last time the record's timestamp was touched
- time_t now=time(NULL);
+ time_t now=time(nullptr);
if (timeout && *timeout > 0 && now - lastAccess >= *timeout) {
m_log.info("session timed out (ID: %s)", key);
// Wrap the results in a local entry and save it.
session = new StoredSession(this, obj);
// We handled timeout issues, still need to handle address and expiration checks.
- timeout = NULL;
+ timeout = nullptr;
#else
throw ConfigurationException("SessionCache search requires a StorageService.");
#endif
if (!XMLString::equals(session->getApplicationID(), application.getId())) {
m_log.error("an application (%s) tried to access another application's session", application.getId());
session->unlock();
- return NULL;
+ return nullptr;
}
// Verify currency and update the timestamp if indicated by caller.
// Load our configuration details...
static const XMLCh cleanupInterval[] = UNICODE_LITERAL_15(c,l,e,a,n,u,p,I,n,t,e,r,v,a,l);
- const XMLCh* tag=m_root ? m_root->getAttributeNS(NULL,cleanupInterval) : NULL;
+ const XMLCh* tag=m_root ? m_root->getAttributeNS(nullptr,cleanupInterval) : nullptr;
int rerun_timer = 900;
if (tag && *tag) {
rerun_timer = XMLString::parseInt(tag);
// Pass 1: iterate over the map and find all entries that have not been
// used in the allotted timeout.
vector<string> stale_keys;
- time_t stale = time(NULL) - m_inprocTimeout;
+ time_t stale = time(nullptr) - m_inprocTimeout;
m_log.debug("cleanup thread running");
mutex->unlock();
delete mutex;
- Thread::exit(NULL);
+ Thread::exit(nullptr);
}
void* SSCache::cleanup_fn(void* cache_p)
// Now run the cleanup process.
reinterpret_cast<SSCache*>(cache_p)->cleanup();
- return NULL;
+ return nullptr;
}
#ifndef SHIBSP_LITE
string record;
time_t lastAccess;
if (!m_storage->readText(key, "session", &record, &lastAccess)) {
- DDF ret(NULL);
+ DDF ret(nullptr);
DDFJanitor jan(ret);
out << ret;
return;
// Adjust for expiration to recover last access time and check timeout.
lastAccess -= m_cacheTimeout;
- time_t now=time(NULL);
+ time_t now=time(nullptr);
// See if we need to check for a timeout.
if (in["timeout"].string()) {
// Adjust for expiration to recover last access time and check timeout.
lastAccess -= m_cacheTimeout;
- time_t now=time(NULL);
+ time_t now=time(nullptr);
// See if we need to check for a timeout.
time_t timeout = 0;
out << record;
}
else {
- DDF ret(NULL);
+ DDF ret(nullptr);
DDFJanitor jan(ret);
out << ret;
}
throw ConfigurationException("Application not found, check configuration?");
remove(*app, key);
- DDF ret(NULL);
+ DDF ret(nullptr);
DDFJanitor jan(ret);
out << ret;
}