[cpp-sp] branch main updated: Start sketching out new Agent infra.
Scott Cantor
cantor.2 at osu.edu
Fri Dec 6 13:47:49 UTC 2024
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=cce9dbc9c19de468b06bcb8d036a7810d685be2a
The following commit(s) were added to refs/heads/main by this push:
new cce9dbc9 Start sketching out new Agent infra.
cce9dbc9 is described below
commit cce9dbc9c19de468b06bcb8d036a7810d685be2a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Dec 6 08:47:45 2024 -0500
Start sketching out new Agent infra.
---
shibsp/Agent.h | 154 ++++++++++++++++++++++++++++++++++++++++++++
shibsp/AgentConfig.h | 12 ++++
shibsp/Makefile.am | 1 +
shibsp/impl/AgentConfig.cpp | 26 ++++----
4 files changed, 179 insertions(+), 14 deletions(-)
diff --git a/shibsp/Agent.h b/shibsp/Agent.h
new file mode 100644
index 00000000..5b81ae03
--- /dev/null
+++ b/shibsp/Agent.h
@@ -0,0 +1,154 @@
+/**
+ * Licensed 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/Agent.h
+ *
+ * Interface to a Shibboleth SP agent.
+ */
+
+#ifndef __shibsp_agent_h__
+#define __shibsp_agent_h__
+
+#include <shibsp/util/Lockable.h>
+#include <shibsp/util/PropertySet.h>
+
+#include <set>
+
+namespace shibsp {
+
+ class SHIBSP_API Application;
+ class SHIBSP_API Handler;
+ class SHIBSP_API ListenerService;
+ class SHIBSP_API RequestMapper;
+ class SHIBSP_API SessionCache;
+ class SHIBSP_API AgentRequest;
+
+#if defined (_MSC_VER)
+ #pragma warning( push )
+ #pragma warning( disable : 4251 )
+#endif
+
+ /**
+ * Interface to a Shibboleth ServiceProvider instance.
+ *
+ * <p>A ServiceProvider exposes configuration and infrastructure services required
+ * by the SP implementation, allowing a flexible configuration format.
+ */
+ class SHIBSP_API Agent : public virtual SharedLockable, public virtual PropertySet
+ {
+ MAKE_NONCOPYABLE(Agent);
+ protected:
+ Agent();
+ public:
+ virtual ~Agent();
+
+ /**
+ * Loads a configuration and prepares the instance for use.
+ *
+ * <p>Implemented as a separate method so that services can rely on
+ * other services while they initialize by accessing the ServiceProvider
+ * from the SPConfig singleton.
+ */
+ virtual void init()=0;
+
+ /**
+ * Returns a SessionCache instance.
+ *
+ * @param required true iff an exception should be thrown if no SessionCache is available
+ * @return a SessionCache
+ */
+ virtual SessionCache* getSessionCache(bool required=true) const=0;
+
+ /**
+ * Returns a ListenerService instance.
+ *
+ * @param required true iff an exception should be thrown if no ListenerService is available
+ * @return a ListenerService
+ */
+ virtual ListenerService* getListenerService(bool required=true) const=0;
+
+ /**
+ * Returns a RequestMapper instance.
+ *
+ * @param required true iff an exception should be thrown if no RequestMapper is available
+ * @return a RequestMapper
+ */
+ virtual RequestMapper* getRequestMapper(bool required=true) const=0;
+
+ /**
+ * Enforces requirements for an authenticated session.
+ *
+ * <p>If the return value's first member is true, then request processing should terminate
+ * with the second member as a status value. If false, processing can continue.
+ *
+ * @param request SP request interface
+ * @param handler true iff a request to a registered Handler location can be directly executed
+ * @return a pair containing a "request completed" indicator and a server-specific response code
+ */
+ virtual std::pair<bool,long> doAuthentication(AgentRequest& request, bool handler=false) const;
+
+ /**
+ * Enforces authorization requirements based on the authenticated session.
+ *
+ * <p>If the return value's first member is true, then request processing should terminate
+ * with the second member as a status value. If false, processing can continue.
+ *
+ * @param request SP request interface
+ * @return a pair containing a "request completed" indicator and a server-specific response code
+ */
+ virtual std::pair<bool,long> doAuthorization(AgentRequest& request) const;
+
+ /**
+ * Publishes session contents to the request in the form of headers or environment variables.
+ *
+ * <p>If the return value's first member is true, then request processing should terminate
+ * with the second member as a status value. If false, processing can continue.
+ *
+ * @param request SP request interface
+ * @param requireSession set to true iff an error should result if no session exists
+ * @return a pair containing a "request completed" indicator and a server-specific response code
+ */
+ virtual std::pair<bool,long> doExport(AgentRequest& request, bool requireSession=true) const;
+
+ /**
+ * Services requests for registered Handler locations.
+ *
+ * <p>If the return value's first member is true, then request processing should terminate
+ * with the second member as a status value. If false, processing can continue.
+ *
+ * @param request SP request interface
+ * @return a pair containing a "request completed" indicator and a server-specific response code
+ */
+ virtual std::pair<bool,long> doHandler(AgentRequest& request) const;
+
+ protected:
+ /** The AuthTypes to "recognize" (defaults to "shibboleth"). */
+ std::set<std::string> m_authTypes;
+ };
+
+#if defined (_MSC_VER)
+ #pragma warning( pop )
+#endif
+
+ /**
+ * Registers Agent plugins into the runtime.
+ */
+ void SHIBSP_API registerAgents();
+
+ /** Default agent implementation. */
+ #define DEFAULT_AGENT "Default"
+};
+
+#endif /* __shibsp_agent_h__ */
diff --git a/shibsp/AgentConfig.h b/shibsp/AgentConfig.h
index f4dbff24..f3b996dd 100644
--- a/shibsp/AgentConfig.h
+++ b/shibsp/AgentConfig.h
@@ -28,10 +28,12 @@
namespace shibsp {
+ class SHIBSP_API AccessControl;
class SHIBSP_API Agent;
class SHIBSP_API Category;
class SHIBSP_API LoggingService;
class SHIBSP_API PathResolver;
+ class SHIBSP_API RequestMapper;
class SHIBSP_API URLEncoder;
#if defined (_MSC_VER)
@@ -91,11 +93,21 @@ namespace shibsp {
*/
virtual bool load_library(const char* path, void* context=nullptr)=0;
+ /**
+ * Manages factories for AccessControl plugins.
+ */
+ PluginManager<AccessControl,std::string,const boost::property_tree::ptree&> AccessControlManager;
+
/**
* Manages factories for LoggingService plugins.
*/
PluginManager<LoggingService,std::string,const boost::property_tree::ptree&> LoggingServiceManager;
+ /**
+ * Manages factories for RequestMapper plugins.
+ */
+ PluginManager<RequestMapper,std::string,const boost::property_tree::ptree&> RequestMapperManager;
+
/**
* Returns a PathResolver instance.
*
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index c4ed8976..45bd0d3e 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -23,6 +23,7 @@ nodist_libshibspinclude_HEADERS = \
libshibspinclude_HEADERS = \
AbstractSPRequest.h \
AccessControl.h \
+ Agent.h \
AgentConfig.h \
Application.h \
base.h \
diff --git a/shibsp/impl/AgentConfig.cpp b/shibsp/impl/AgentConfig.cpp
index 89c33f42..8f232507 100644
--- a/shibsp/impl/AgentConfig.cpp
+++ b/shibsp/impl/AgentConfig.cpp
@@ -22,7 +22,10 @@
#include "exceptions.h"
#include "version.h"
+#include "AccessControl.h"
+#include "Agent.h"
#include "AgentConfig.h"
+#include "RequestMapper.h"
#include "logging/LoggingService.h"
#include "util/PathResolver.h"
#include "util/URLEncoder.h"
@@ -79,7 +82,7 @@ namespace shibsp {
URLEncoder m_urlEncoder;
vector<void*> m_libhandles;
unique_ptr<LoggingService> m_logging;
- //unique_ptr<Agent> m_agent;
+ unique_ptr<Agent> m_agent;
};
static AgentInternalConfig g_agentConfig;
@@ -113,9 +116,9 @@ LoggingService& AgentInternalConfig::getLoggingService() const
Agent& AgentInternalConfig::getAgent() const
{
-// if (m_agent) {
-// return *m_agent;
-// }
+ if (m_agent) {
+ return *m_agent;
+ }
throw logic_error("Agent not initialized.");
}
@@ -213,6 +216,9 @@ bool AgentInternalConfig::_init(const char* inst_prefix, const char* config_file
Category& log=Category::getInstance(SHIBSP_LOGCAT ".AgentConfig");
log.info("%s agent initialization underway", PACKAGE_STRING);
+ registerAccessControls();
+ registerRequestMappers();
+
/*
XMLToolingConfig::getConfig().user_agent = string(PACKAGE_NAME) + '/' + PACKAGE_VERSION;
@@ -229,11 +235,6 @@ bool AgentInternalConfig::_init(const char* inst_prefix, const char* config_file
if (isEnabled(Listener))
registerListenerServices();
- if (isEnabled(RequestMapping)) {
- registerAccessControls();
- registerRequestMappers();
- }
-
if (isEnabled(Caching))
registerSessionCaches();
@@ -283,6 +284,8 @@ void AgentInternalConfig::_term()
Category& log=Category::getInstance(SHIBSP_LOGCAT ".AgentConfig");
log.info("%s agent shutting down", PACKAGE_STRING);
+ AccessControlManager.deregisterFactories();
+ RequestMapperManager.deregisterFactories();
LoggingServiceManager.deregisterFactories();
for (vector<void*>::reverse_iterator i=m_libhandles.rbegin(); i!=m_libhandles.rend(); i++) {
@@ -326,11 +329,6 @@ void AgentInternalConfig::_term()
if (isEnabled(Listener))
ListenerServiceManager.deregisterFactories();
- if (isEnabled(RequestMapping)) {
- AccessControlManager.deregisterFactories();
- RequestMapperManager.deregisterFactories();
- }
-
if (isEnabled(Caching))
SessionCacheManager.deregisterFactories();
*/
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list