[cpp-sp] branch master updated: Collapse extended SessionCache interface.
Scott Cantor
cantor.2 at osu.edu
Mon Feb 5 15:07:38 EST 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=dbc806d18e7d6d8f49c397f36b8eba433b22d3a6
The following commit(s) were added to refs/heads/master by this push:
new dbc806d Collapse extended SessionCache interface.
dbc806d is described below
commit dbc806d18e7d6d8f49c397f36b8eba433b22d3a6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Feb 5 15:07:34 2018 -0500
Collapse extended SessionCache interface.
---
Projects/vc15/shibsp/shibsp.vcxproj | 3 +-
Projects/vc15/shibsp/shibsp.vcxproj.filters | 3 -
shibsp/Makefile.am | 1 -
shibsp/SessionCache.h | 48 +++++++++++++++
shibsp/SessionCacheEx.h | 96 -----------------------------
shibsp/handler/impl/SAML2Logout.cpp | 28 +++------
shibsp/impl/StorageServiceSessionCache.cpp | 12 +---
7 files changed, 61 insertions(+), 130 deletions(-)
diff --git a/Projects/vc15/shibsp/shibsp.vcxproj b/Projects/vc15/shibsp/shibsp.vcxproj
index 6d53173..e6aa525 100644
--- a/Projects/vc15/shibsp/shibsp.vcxproj
+++ b/Projects/vc15/shibsp/shibsp.vcxproj
@@ -326,7 +326,6 @@
<ClInclude Include="..\..\..\shibsp\security\SecurityPolicyProvider.h" />
<ClInclude Include="..\..\..\shibsp\ServiceProvider.h" />
<ClInclude Include="..\..\..\shibsp\SessionCache.h" />
- <ClInclude Include="..\..\..\shibsp\SessionCacheEx.h" />
<ClInclude Include="..\..\..\shibsp\SPConfig.h" />
<ClInclude Include="..\..\..\shibsp\SPRequest.h" />
<ClInclude Include="..\..\..\shibsp\TransactionLog.h" />
@@ -381,4 +380,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/Projects/vc15/shibsp/shibsp.vcxproj.filters b/Projects/vc15/shibsp/shibsp.vcxproj.filters
index 54bce91..9f78f16 100644
--- a/Projects/vc15/shibsp/shibsp.vcxproj.filters
+++ b/Projects/vc15/shibsp/shibsp.vcxproj.filters
@@ -470,9 +470,6 @@
<ClInclude Include="..\..\..\shibsp\SessionCache.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\shibsp\SessionCacheEx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\shibsp\SPConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index 9858162..728742d 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -36,7 +36,6 @@ libshibspinclude_HEADERS = \
RequestMapper.h \
ServiceProvider.h \
SessionCache.h \
- SessionCacheEx.h \
SPConfig.h \
SPRequest.h \
TransactionLog.h \
diff --git a/shibsp/SessionCache.h b/shibsp/SessionCache.h
index 35d3ec6..a2f1f3e 100644
--- a/shibsp/SessionCache.h
+++ b/shibsp/SessionCache.h
@@ -290,6 +290,32 @@ namespace shibsp {
)=0;
/**
+ * Returns active sessions that match particular parameters and records the logout
+ * to prevent race conditions.
+ *
+ * <p>On exit, the mapping between these sessions and the associated information MAY be
+ * removed by the cache, so subsequent calls to this method may not return anything.
+ *
+ * <p>Until logout expiration, any attempt to create a session with the same parameters
+ * will be blocked by the cache.
+ *
+ * @param application reference to Application that owns the session(s)
+ * @param issuer source of session(s)
+ * @param nameid name identifier associated with the session(s) to terminate
+ * @param indexes indexes of sessions, or nullptr for all sessions associated with other parameters
+ * @param expires logout expiration
+ * @param sessions on exit, contains the IDs of the matching sessions found
+ */
+ virtual std::vector<std::string>::size_type logout(
+ const Application& application,
+ const opensaml::saml2md::EntityDescriptor* issuer,
+ const opensaml::saml2::NameID& nameid,
+ const std::set<std::string>* indexes,
+ time_t expires,
+ std::vector<std::string>& sessions
+ )=0;
+
+ /**
* Executes a test of the cache's general health.
*/
virtual void test()=0;
@@ -353,6 +379,28 @@ namespace shibsp {
* @param response optional response to client enabling removal of session or reference
*/
virtual void remove(const Application& application, const xmltooling::HTTPRequest& request, xmltooling::HTTPResponse* response=nullptr)=0;
+
+ /**
+ * Locates an existing session by ID.
+ *
+ * <p>If the client address is supplied, then a check will be performed against
+ * the address recorded in the record.
+ *
+ * @param application reference to Application that owns the Session
+ * @param key session key
+ * @param client_addr network address of client (if known)
+ * @param timeout inactivity timeout to enforce (0 for none, nullptr to bypass check/update of last access)
+ * @return pointer to locked Session, or nullptr
+ */
+ virtual Session* find(const Application& application, const char* key, const char* client_addr = nullptr, time_t* timeout = nullptr)=0;
+
+ /**
+ * Deletes an existing session.
+ *
+ * @param application reference to Application that owns the Session
+ * @param key session key
+ */
+ virtual void remove(const Application& application, const char* key)=0;
};
/** SessionCache implementation backed by a StorageService. */
diff --git a/shibsp/SessionCacheEx.h b/shibsp/SessionCacheEx.h
deleted file mode 100644
index 682e54c..0000000
--- a/shibsp/SessionCacheEx.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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/SessionCacheEx.h
- *
- * Extended SessionCache API with additional capabilities
- */
-
-#ifndef __shibsp_sessioncacheex_h__
-#define __shibsp_sessioncacheex_h__
-
-#include <shibsp/SessionCache.h>
-
-namespace shibsp {
-
- /**
- * Extended SessionCache API with additional capabilities
- */
- class SHIBSP_API SessionCacheEx : public SessionCache
- {
- protected:
- SessionCacheEx();
- public:
- virtual ~SessionCacheEx();
-
-#ifndef SHIBSP_LITE
- /**
- * Returns active sessions that match particular parameters and records the logout
- * to prevent race conditions.
- *
- * <p>On exit, the mapping between these sessions and the associated information MAY be
- * removed by the cache, so subsequent calls to this method may not return anything.
- *
- * <p>Until logout expiration, any attempt to create a session with the same parameters
- * will be blocked by the cache.
- *
- * @param application reference to Application that owns the session(s)
- * @param issuer source of session(s)
- * @param nameid name identifier associated with the session(s) to terminate
- * @param indexes indexes of sessions, or nullptr for all sessions associated with other parameters
- * @param expires logout expiration
- * @param sessions on exit, contains the IDs of the matching sessions found
- */
- virtual std::vector<std::string>::size_type logout(
- const Application& application,
- const opensaml::saml2md::EntityDescriptor* issuer,
- const opensaml::saml2::NameID& nameid,
- const std::set<std::string>* indexes,
- time_t expires,
- std::vector<std::string>& sessions
- )=0;
-#endif
-
- /**
- * Locates an existing session by ID.
- *
- * <p>If the client address is supplied, then a check will be performed against
- * the address recorded in the record.
- *
- * @param application reference to Application that owns the Session
- * @param key session key
- * @param client_addr network address of client (if known)
- * @param timeout inactivity timeout to enforce (0 for none, nullptr to bypass check/update of last access)
- * @return pointer to locked Session, or nullptr
- */
- virtual Session* find(const Application& application, const char* key, const char* client_addr=nullptr, time_t* timeout=nullptr)=0;
-
- /**
- * Deletes an existing session.
- *
- * @param application reference to Application that owns the Session
- * @param key session key
- */
- virtual void remove(const Application& application, const char* key)=0;
- };
-};
-
-#endif /* __shibsp_sessioncacheex_h__ */
diff --git a/shibsp/handler/impl/SAML2Logout.cpp b/shibsp/handler/impl/SAML2Logout.cpp
index 190add6..389e18a 100644
--- a/shibsp/handler/impl/SAML2Logout.cpp
+++ b/shibsp/handler/impl/SAML2Logout.cpp
@@ -34,7 +34,7 @@
#include "util/SPConstants.h"
#ifndef SHIBSP_LITE
-# include "SessionCacheEx.h"
+# include "SessionCache.h"
# include "security/SecurityPolicy.h"
# include "security/SecurityPolicyProvider.h"
# include "metadata/MetadataProviderCriteria.h"
@@ -271,7 +271,6 @@ pair<bool,long> SAML2Logout::doRequest(const Application& application, const HTT
#ifndef SHIBSP_LITE
// First capture the active session ID.
SessionCache* cache = application.getServiceProvider().getSessionCache();
- SessionCacheEx* cacheex = dynamic_cast<SessionCacheEx*>(cache);
string session_id = cache->active(application, request);
scoped_ptr<LogoutEvent> logout_event(newLogoutEvent(application, &request));
@@ -470,22 +469,15 @@ pair<bool,long> SAML2Logout::doRequest(const Application& application, const HTT
// Now we perform "logout" by finding the matching sessions.
vector<string> sessions;
try {
- if (cacheex) {
- time_t expires = logoutRequest->getNotOnOrAfter() ? logoutRequest->getNotOnOrAfterEpoch() : 0;
- cacheex->logout(application, entity, *nameid, &indexes, expires, sessions);
- m_log.debug("session cache returned %d sessions bound to NameID in logout request", sessions.size());
-
- // Now we actually terminate everything except for the active session,
- // if this is front-channel, for notification purposes.
- for (vector<string>::const_iterator sit = sessions.begin(); sit != sessions.end(); ++sit)
- if (*sit != session_id)
- cacheex->remove(application, sit->c_str()); // using the ID-based removal operation
- }
- else {
- m_log.warn("session cache does not support extended API, can't implement indirect logout of sessions");
- if (!session_id.empty())
- sessions.push_back(session_id);
- }
+ time_t expires = logoutRequest->getNotOnOrAfter() ? logoutRequest->getNotOnOrAfterEpoch() : 0;
+ cache->logout(application, entity, *nameid, &indexes, expires, sessions);
+ m_log.debug("session cache returned %d sessions bound to NameID in logout request", sessions.size());
+
+ // Now we actually terminate everything except for the active session,
+ // if this is front-channel, for notification purposes.
+ for (vector<string>::const_iterator sit = sessions.begin(); sit != sessions.end(); ++sit)
+ if (*sit != session_id)
+ cache->remove(application, sit->c_str()); // using the ID-based removal operation
}
catch (std::exception& ex) {
m_log.error("error while logging out matching sessions: %s", ex.what());
diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp
index d8e5039..0af5f6e 100644
--- a/shibsp/impl/StorageServiceSessionCache.cpp
+++ b/shibsp/impl/StorageServiceSessionCache.cpp
@@ -36,7 +36,7 @@
#include "Application.h"
#include "exceptions.h"
#include "ServiceProvider.h"
-#include "SessionCacheEx.h"
+#include "SessionCache.h"
#include "TransactionLog.h"
#include "attribute/Attribute.h"
#include "handler/RemotedHandler.h"
@@ -86,7 +86,7 @@ namespace {
}
class StoredSession;
- class SSCache : public SessionCacheEx
+ class SSCache : public SessionCache
#ifndef SHIBSP_LITE
,public virtual Remoted
#endif
@@ -856,14 +856,6 @@ SessionCache::~SessionCache()
{
}
-SessionCacheEx::SessionCacheEx()
-{
-}
-
-SessionCacheEx::~SessionCacheEx()
-{
-}
-
SSCache::SSCache(const DOMElement* e)
: m_log(Category::getInstance(SHIBSP_LOGCAT ".SessionCache")), inproc(true),
#ifndef SHIBSP_LITE
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list