From 40ba37a1dc92307cb1983cc13034ea878ee9522d Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Wed, 14 Oct 2009 01:51:46 +0000 Subject: [PATCH] Reducing header overuse, non-inlining selected methods (CPPOST-35). --- isapi_shib/isapi_shib.cpp | 13 +++--- nsapi_shib/nsapi_shib.cpp | 13 +++--- shibsp/AbstractSPRequest.cpp | 2 + shibsp/AbstractSPRequest.h | 9 ++-- shibsp/SPConfig.cpp | 62 ++++++++++++++++++++++++++ shibsp/SPConfig.h | 31 ++++--------- shibsp/SessionCache.h | 4 ++ shibsp/TransactionLog.h | 25 ++++------- shibsp/attribute/Attribute.cpp | 4 ++ shibsp/attribute/Attribute.h | 3 +- shibsp/attribute/resolver/AttributeExtractor.h | 7 +++ shibsp/attribute/resolver/AttributeResolver.h | 2 + shibsp/attribute/resolver/ResolutionContext.h | 2 + shibsp/impl/StorageServiceSessionCache.cpp | 1 + shibsp/remoting/ddf.h | 12 ++--- shibsp/remoting/impl/ddf.cpp | 19 ++++++++ 16 files changed, 144 insertions(+), 65 deletions(-) diff --git a/isapi_shib/isapi_shib.cpp b/isapi_shib/isapi_shib.cpp index 2a1130d..dd571f7 100644 --- a/isapi_shib/isapi_shib.cpp +++ b/isapi_shib/isapi_shib.cpp @@ -27,9 +27,16 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_RAND_S +#include #include #include #include + +#include +#include +#include +#include +#include #include #include #include @@ -38,12 +45,6 @@ #include #include -#include -#include -#include -#include -#include - #include #include #include diff --git a/nsapi_shib/nsapi_shib.cpp b/nsapi_shib/nsapi_shib.cpp index 2d90a83..b18e914 100644 --- a/nsapi_shib/nsapi_shib.cpp +++ b/nsapi_shib/nsapi_shib.cpp @@ -34,22 +34,23 @@ # define _CRT_RAND_S #endif +#include #include #include #include #include -#include -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include +#include +#include #ifdef WIN32 # include diff --git a/shibsp/AbstractSPRequest.cpp b/shibsp/AbstractSPRequest.cpp index 78b2ae9..7f880ba 100644 --- a/shibsp/AbstractSPRequest.cpp +++ b/shibsp/AbstractSPRequest.cpp @@ -21,10 +21,12 @@ */ #include "internal.h" +#include "exceptions.h" #include "AbstractSPRequest.h" #include "Application.h" #include "ServiceProvider.h" #include "SessionCache.h" +#include "util/CGIParser.h" using namespace shibsp; using namespace opensaml; diff --git a/shibsp/AbstractSPRequest.h b/shibsp/AbstractSPRequest.h index eed7516..318f68c 100644 --- a/shibsp/AbstractSPRequest.h +++ b/shibsp/AbstractSPRequest.h @@ -17,18 +17,18 @@ /** * @file shibsp/AbstractSPRequest.h * - * Abstract base for SPRequest implementations + * Abstract base for SPRequest implementations. */ #ifndef __shibsp_abstreq_h__ #define __shibsp_abstreq_h__ -#include #include -#include namespace shibsp { + class SHIBSP_API CGIParser; + #if defined (_MSC_VER) #pragma warning( push ) #pragma warning( disable : 4251 ) @@ -49,7 +49,7 @@ namespace shibsp { /** * Stores a normalized request URI to ensure it contains no %-encoded characters - * or other undesirable artifacts, such as ;jsessionid appendage. + * or other undesirable artifacts. * * @param uri the request URI as obtained from the client */ @@ -58,6 +58,7 @@ namespace shibsp { public: virtual ~AbstractSPRequest(); + // Virtual function overrides. const ServiceProvider& getServiceProvider() const; RequestMapper::Settings getRequestSettings() const; const Application& getApplication() const; diff --git a/shibsp/SPConfig.cpp b/shibsp/SPConfig.cpp index 8c1fa44..c5c8d4e 100644 --- a/shibsp/SPConfig.cpp +++ b/shibsp/SPConfig.cpp @@ -41,6 +41,7 @@ #include "ServiceProvider.h" #include "SessionCache.h" #include "SPConfig.h" +#include "TransactionLog.h" #include "attribute/Attribute.h" #include "handler/SessionInitiator.h" #include "remoting/ListenerService.h" @@ -64,6 +65,7 @@ #include #include #include +#include #include using namespace shibsp; @@ -96,12 +98,52 @@ SPConfig& SPConfig::getConfig() return g_config; } +SPConfig::SPConfig() : attribute_value_delimeter(';'), m_serviceProvider(NULL), +#ifndef SHIBSP_LITE + m_artifactResolver(NULL), +#endif + m_features(0), m_configDoc(NULL) +{ +} + +SPConfig::~SPConfig() +{ +} + +void SPConfig::setFeatures(unsigned long enabled) +{ + m_features = enabled; +} + +bool SPConfig::isEnabled(components_t feature) +{ + return (m_features & feature)>0; +} + +ServiceProvider* SPConfig::getServiceProvider() const +{ + return m_serviceProvider; +} + void SPConfig::setServiceProvider(ServiceProvider* serviceProvider) { delete m_serviceProvider; m_serviceProvider = serviceProvider; } +#ifndef SHIBSP_LITE +void SPConfig::setArtifactResolver(MessageDecoder::ArtifactResolver* artifactResolver) +{ + delete m_artifactResolver; + m_artifactResolver = artifactResolver; +} + +const MessageDecoder::ArtifactResolver* SPConfig::getArtifactResolver() const +{ + return m_artifactResolver; +} +#endif + bool SPConfig::init(const char* catalog_path, const char* inst_prefix) { #ifdef _DEBUG @@ -342,3 +384,23 @@ bool SPConfig::instantiate(const char* config, bool rethrow) } return false; } + +TransactionLog::TransactionLog() : log(logging::Category::getInstance(SHIBSP_TX_LOGCAT)), m_lock(Mutex::create()) +{ +} + +TransactionLog::~TransactionLog() +{ + delete m_lock; +} + +Lockable* TransactionLog::lock() +{ + m_lock->lock(); + return this; +} + +void TransactionLog::unlock() +{ + m_lock->unlock(); +} diff --git a/shibsp/SPConfig.h b/shibsp/SPConfig.h index c9985a9..3764eda 100644 --- a/shibsp/SPConfig.h +++ b/shibsp/SPConfig.h @@ -25,6 +25,7 @@ #include +#include #ifndef SHIBSP_LITE # include # include @@ -68,14 +69,9 @@ namespace shibsp { { MAKE_NONCOPYABLE(SPConfig); public: - SPConfig() : attribute_value_delimeter(';'), m_serviceProvider(NULL), -#ifndef SHIBSP_LITE - m_artifactResolver(NULL), -#endif - m_features(0), m_configDoc(NULL) { - } + SPConfig(); - virtual ~SPConfig() {} + virtual ~SPConfig(); /** * Returns the global configuration object for the library. @@ -108,9 +104,7 @@ namespace shibsp { * * @param enabled bitmask of component constants */ - void setFeatures(unsigned long enabled) { - m_features = enabled; - } + void setFeatures(unsigned long enabled); /** * Test whether a subsystem is enabled. @@ -118,9 +112,7 @@ namespace shibsp { * @param feature subsystem/component to test * @return true iff feature is enabled */ - bool isEnabled(components_t feature) { - return (m_features & feature)>0; - } + bool isEnabled(components_t feature); /** * Initializes library @@ -156,9 +148,7 @@ namespace shibsp { * * @return global ServiceProvider or NULL */ - ServiceProvider* getServiceProvider() const { - return m_serviceProvider; - } + ServiceProvider* getServiceProvider() const; /** * Instantiates and installs a ServiceProvider instance based on an XML configuration string @@ -179,19 +169,14 @@ namespace shibsp { * * @param artifactResolver new ArtifactResolver instance to store */ - void setArtifactResolver(opensaml::MessageDecoder::ArtifactResolver* artifactResolver) { - delete m_artifactResolver; - m_artifactResolver = artifactResolver; - } + void setArtifactResolver(opensaml::MessageDecoder::ArtifactResolver* artifactResolver); /** * Returns the global ArtifactResolver instance. * * @return global ArtifactResolver or NULL */ - const opensaml::MessageDecoder::ArtifactResolver* getArtifactResolver() const { - return m_artifactResolver; - } + const opensaml::MessageDecoder::ArtifactResolver* getArtifactResolver() const; #endif /** Separator for serialized values of multi-valued attributes. */ diff --git a/shibsp/SessionCache.h b/shibsp/SessionCache.h index b69e065..38fa126 100644 --- a/shibsp/SessionCache.h +++ b/shibsp/SessionCache.h @@ -25,7 +25,11 @@ #include +#include +#include +#include #include +#include #include namespace xmltooling { diff --git a/shibsp/TransactionLog.h b/shibsp/TransactionLog.h index 64ba2bc..96461c7 100644 --- a/shibsp/TransactionLog.h +++ b/shibsp/TransactionLog.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,12 @@ #include #include #include -#include -namespace shibsp { +namespace xmltooling { + class XMLTOOL_API Mutex; +}; +namespace shibsp { /** * Interface to a synchronized logging object. * @@ -39,22 +41,13 @@ namespace shibsp { { MAKE_NONCOPYABLE(TransactionLog); public: - TransactionLog() - : log(xmltooling::logging::Category::getInstance(SHIBSP_TX_LOGCAT)), m_lock(xmltooling::Mutex::create()) { - } + TransactionLog(); - virtual ~TransactionLog() { - delete m_lock; - } + virtual ~TransactionLog(); - xmltooling::Lockable* lock() { - m_lock->lock(); - return this; - } + xmltooling::Lockable* lock(); - void unlock() { - m_lock->unlock(); - } + void unlock(); /** Logging object. */ xmltooling::logging::Category& log; diff --git a/shibsp/attribute/Attribute.cpp b/shibsp/attribute/Attribute.cpp index a6a0c65..70bff1f 100644 --- a/shibsp/attribute/Attribute.cpp +++ b/shibsp/attribute/Attribute.cpp @@ -141,6 +141,10 @@ void Attribute::deregisterFactories() m_factoryMap.clear(); } +Attribute::Attribute(const vector& ids) : m_id(ids), m_caseSensitive(true), m_internal(false) +{ +} + Attribute::Attribute(DDF& in) : m_caseSensitive(in["case_insensitive"].isnull()), m_internal(!in["internal"].isnull()) { const char* id = in.first().name(); diff --git a/shibsp/attribute/Attribute.h b/shibsp/attribute/Attribute.h index a9886f4..39dae79 100644 --- a/shibsp/attribute/Attribute.h +++ b/shibsp/attribute/Attribute.h @@ -58,8 +58,7 @@ namespace shibsp { * * @param ids array with primary identifier in first position, followed by any aliases */ - Attribute(const std::vector& ids) : m_id(ids), m_caseSensitive(true), m_internal(false) { - } + Attribute(const std::vector& ids); /** * Constructs based on a remoted Attribute. diff --git a/shibsp/attribute/resolver/AttributeExtractor.h b/shibsp/attribute/resolver/AttributeExtractor.h index faa8bf2..9e4f217 100644 --- a/shibsp/attribute/resolver/AttributeExtractor.h +++ b/shibsp/attribute/resolver/AttributeExtractor.h @@ -24,8 +24,15 @@ #define __shibsp_extractor_h__ #include + +#include +#include #include +namespace xmltooling { + class XMLTOOL_API XMLObject; +}; + namespace opensaml { namespace saml2md { class SAML_API RoleDescriptor; diff --git a/shibsp/attribute/resolver/AttributeResolver.h b/shibsp/attribute/resolver/AttributeResolver.h index 6123eb9..bcf0232 100644 --- a/shibsp/attribute/resolver/AttributeResolver.h +++ b/shibsp/attribute/resolver/AttributeResolver.h @@ -25,6 +25,8 @@ #include +#include +#include #include namespace opensaml { diff --git a/shibsp/attribute/resolver/ResolutionContext.h b/shibsp/attribute/resolver/ResolutionContext.h index 022e2dc..6eab48a 100644 --- a/shibsp/attribute/resolver/ResolutionContext.h +++ b/shibsp/attribute/resolver/ResolutionContext.h @@ -25,6 +25,8 @@ #include +#include + namespace opensaml { class SAML_API Assertion; }; diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp index fa018bb..16cf5e5 100644 --- a/shibsp/impl/StorageServiceSessionCache.cpp +++ b/shibsp/impl/StorageServiceSessionCache.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include diff --git a/shibsp/remoting/ddf.h b/shibsp/remoting/ddf.h index b361ec0..abcc045 100644 --- a/shibsp/remoting/ddf.h +++ b/shibsp/remoting/ddf.h @@ -42,7 +42,7 @@ namespace shibsp { public: /// @cond OFF // constructors - DDF() : m_handle(NULL) {} + DDF(); DDF(const char* n); DDF(const char* n, const char* val, bool safe=true); DDF(const char* n, long val); @@ -77,13 +77,9 @@ namespace shibsp { // destructive node conversion methods DDF& empty(); - DDF& string(const char* val) { - return string(const_cast(val), true); - } - DDF& unsafe_string(const char* val) { - return string(const_cast(val), true, false); - } DDF& string(char* val, bool copyit=true, bool safe=true); + DDF& string(const char* val); + DDF& unsafe_string(const char* val); DDF& string(long val); DDF& string(double val); DDF& integer(long val); @@ -110,7 +106,7 @@ namespace shibsp { // indexed operators DDF operator[](unsigned long index) const; - DDF operator[](const char* path) const { return getmember(path); } + DDF operator[](const char* path) const; // named member access/creation DDF addmember(const char* path); diff --git a/shibsp/remoting/impl/ddf.cpp b/shibsp/remoting/impl/ddf.cpp index ae44d4f..d134c5a 100644 --- a/shibsp/remoting/impl/ddf.cpp +++ b/shibsp/remoting/impl/ddf.cpp @@ -119,6 +119,10 @@ struct shibsp::ddf_body_t { // library implementation +DDF::DDF() : m_handle(NULL) +{ +} + DDF::DDF(const char* n) { m_handle=new(nothrow) ddf_body_t; @@ -365,6 +369,16 @@ DDF& DDF::string(char* val, bool copyit, bool safe) return *this; } +DDF& DDF::string(const char* val) +{ + return string(const_cast(val), true); +} + +DDF& DDF::unsafe_string(const char* val) +{ + return string(const_cast(val), true, false); +} + DDF& DDF::string(long val) { char buf[20]; @@ -600,6 +614,11 @@ DDF DDF::previous() return p; } +DDF DDF::operator[](const char* path) const +{ + return getmember(path); +} + DDF DDF::operator[](unsigned long index) const { DDF d; -- 2.1.4