From: Amos Jeffries Date: Mon, 28 Mar 2011 13:47:37 +0000 (-0600) Subject: SourceLayout: namespace for Auth::Scheme top layer X-Git-Tag: take06~27^2~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c6cf8dee7a05893f951821071fd45779a9dc3324;p=thirdparty%2Fsquid.git SourceLayout: namespace for Auth::Scheme top layer Also, rename Scheme::done() to shutdownCleanup() - naming it for what it actually does rather than when to call it. Also includes the typo fix for revno 11319 basic auth child. --- diff --git a/src/auth/Config.cc b/src/auth/Config.cc index 20fe9dbf7e..83704a2c03 100644 --- a/src/auth/Config.cc +++ b/src/auth/Config.cc @@ -53,7 +53,7 @@ AuthConfig::CreateAuthUser(const char *proxy_auth) AuthConfig *config = Find(proxy_auth); if (config == NULL || !config->active()) { - debugs(29, (shutting_down?3:DBG_IMPORTANT), (shutting_down?"":"WARNING: ") << + debugs(29, (shutting_down?3:DBG_IMPORTANT), (shutting_down?"":"WARNING: ") << "Unsupported or unconfigured/inactive proxy-auth scheme, '" << proxy_auth << "'"); return NULL; } diff --git a/src/auth/Gadgets.cc b/src/auth/Gadgets.cc index d9a312c4b3..63781bd8f9 100644 --- a/src/auth/Gadgets.cc +++ b/src/auth/Gadgets.cc @@ -68,7 +68,7 @@ authenticateActiveSchemeCount(void) int authenticateSchemeCount(void) { - int rv = AuthScheme::GetSchemes().size(); + int rv = Auth::Scheme::GetSchemes().size(); debugs(29, 9, HERE << rv << " active."); diff --git a/src/auth/Gadgets.h b/src/auth/Gadgets.h index f7c3f752a0..72cecfa41c 100644 --- a/src/auth/Gadgets.h +++ b/src/auth/Gadgets.h @@ -72,8 +72,11 @@ private: MEMPROXY_CLASS_INLINE(AuthUserHashPointer); +namespace Auth +{ +class Scheme; +} class ConnStateData; -class AuthScheme; class StoreEntry; /** diff --git a/src/auth/Scheme.cc b/src/auth/Scheme.cc index 0ec60226f7..414551eab4 100644 --- a/src/auth/Scheme.cc +++ b/src/auth/Scheme.cc @@ -38,10 +38,10 @@ #include "auth/Gadgets.h" #include "auth/Config.h" -Vector *AuthScheme::_Schemes = NULL; +Vector *Auth::Scheme::_Schemes = NULL; void -AuthScheme::AddScheme(AuthScheme::Pointer instance) +Auth::Scheme::AddScheme(Auth::Scheme::Pointer instance) { iterator i = GetSchemes().begin(); @@ -53,22 +53,22 @@ AuthScheme::AddScheme(AuthScheme::Pointer instance) GetSchemes().push_back(instance); } -AuthScheme::Pointer -AuthScheme::Find(const char *typestr) +Auth::Scheme::Pointer +Auth::Scheme::Find(const char *typestr) { for (iterator i = GetSchemes().begin(); i != GetSchemes().end(); ++i) { if (strcmp((*i)->type(), typestr) == 0) return *i; } - return AuthScheme::Pointer(NULL); + return Auth::Scheme::Pointer(NULL); } -Vector & -AuthScheme::GetSchemes() +Vector & +Auth::Scheme::GetSchemes() { if (!_Schemes) - _Schemes = new Vector; + _Schemes = new Vector; return *_Schemes; } @@ -81,13 +81,13 @@ AuthScheme::GetSchemes() * connections will retain pointers to them. */ void -AuthScheme::FreeAll() +Auth::Scheme::FreeAll() { assert(shutting_down); while (GetSchemes().size()) { - AuthScheme::Pointer scheme = GetSchemes().back(); + Auth::Scheme::Pointer scheme = GetSchemes().back(); GetSchemes().pop_back(); - scheme->done(); + scheme->shutdownCleanup(); } } diff --git a/src/auth/Scheme.h b/src/auth/Scheme.h index 60940fa819..d901293a71 100644 --- a/src/auth/Scheme.h +++ b/src/auth/Scheme.h @@ -30,8 +30,8 @@ * */ -#ifndef SQUID_AUTHSCHEME_H -#define SQUID_AUTHSCHEME_H +#ifndef SQUID_AUTH_SCHEME_H +#define SQUID_AUTH_SCHEME_H #if USE_AUTH @@ -45,6 +45,9 @@ class AuthConfig; \ingroup AuthAPI */ +namespace Auth +{ + /** * \ingroup AuthAPI * \ingroup AuthSchemeAPI @@ -54,20 +57,20 @@ class AuthConfig; * \par * Should we need multiple configs of a single scheme, * a new class AuthConfiguration should be made, and the - * config specific calls on AuthScheme moved to it. + * config specific calls on Auth::Scheme moved to it. */ -class AuthScheme : public RefCountable +class Scheme : public RefCountable { public: - typedef RefCount Pointer; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + typedef RefCount Pointer; + typedef Vector::iterator iterator; + typedef Vector::const_iterator const_iterator; public: - AuthScheme() : initialised (false) {}; - virtual ~AuthScheme() {}; + Scheme() : initialised (false) {}; + virtual ~Scheme() {}; - static void AddScheme(AuthScheme::Pointer); + static void AddScheme(Scheme::Pointer); /** * Final termination of all authentication components. @@ -82,25 +85,27 @@ public: /** * Locate an authentication scheme component by Name. */ - static AuthScheme::Pointer Find(const char *); + static Scheme::Pointer Find(const char *); /* per scheme methods */ virtual char const *type() const = 0; - virtual void done() = 0; + virtual void shutdownCleanup() = 0; virtual AuthConfig *createConfig() = 0; // Not implemented - AuthScheme(AuthScheme const &); - AuthScheme &operator=(AuthScheme const&); + Scheme(Scheme const &); + Scheme &operator=(Scheme const&); - static Vector &GetSchemes(); + static Vector &GetSchemes(); protected: bool initialised; private: - static Vector *_Schemes; + static Vector *_Schemes; }; +} // namespace Auth + #endif /* USE_AUTH */ -#endif /* SQUID_AUTHSCHEME_H */ +#endif /* SQUID_AUTH_SCHEME_H */ diff --git a/src/auth/Type.h b/src/auth/Type.h index 3f26b8c301..1c02f29a05 100644 --- a/src/auth/Type.h +++ b/src/auth/Type.h @@ -3,7 +3,8 @@ #if USE_AUTH -namespace Auth { +namespace Auth +{ typedef enum { AUTH_UNKNOWN, /* default */ diff --git a/src/auth/UserRequest.cc b/src/auth/UserRequest.cc index d0d65af890..da2be768fc 100644 --- a/src/auth/UserRequest.cc +++ b/src/auth/UserRequest.cc @@ -564,9 +564,8 @@ authenticateAddTrailer(HttpReply * rep, AuthUserRequest::Pointer auth_user_reque auth_user_request->addTrailer(rep, accelerated); } -AuthScheme::Pointer +Auth::Scheme::Pointer AuthUserRequest::scheme() const { - /* TODO: this should be overriden by the child and be essentially a no-op */ - return AuthScheme::Find(user()->config->type()); + return Auth::Scheme::Find(user()->config->type()); } diff --git a/src/auth/UserRequest.h b/src/auth/UserRequest.h index 0c40449a2f..3a119634b3 100644 --- a/src/auth/UserRequest.h +++ b/src/auth/UserRequest.h @@ -162,7 +162,7 @@ public: */ char const *username() const; - AuthScheme::Pointer scheme() const; + Auth::Scheme::Pointer scheme() const; virtual const char * connLastHeader(); diff --git a/src/auth/basic/Scheme.cc b/src/auth/basic/Scheme.cc index e861912d15..420ebf12a4 100644 --- a/src/auth/basic/Scheme.cc +++ b/src/auth/basic/Scheme.cc @@ -37,9 +37,9 @@ /* for AuthConfig */ #include "auth/basic/auth_basic.h" -AuthScheme::Pointer Auth::Basic::Scheme::_instance = NULL; +Auth::Scheme::Pointer Auth::Basic::Scheme::_instance = NULL; -AuthScheme::Pointer +Auth::Scheme::Pointer Auth::Basic::Scheme::GetInstance() { if (_instance == NULL) { @@ -50,13 +50,13 @@ Auth::Basic::Scheme::GetInstance() } char const * -basicScheme::type() const +Auth::Basic::Scheme::type() const { return "basic"; } void -Auth::Basic::Scheme::done() +Auth::Basic::Scheme::shutdownCleanup() { if (_instance == NULL) return; diff --git a/src/auth/basic/Scheme.h b/src/auth/basic/Scheme.h index c0d1871183..863f88dfff 100644 --- a/src/auth/basic/Scheme.h +++ b/src/auth/basic/Scheme.h @@ -36,29 +36,31 @@ #include "auth/Scheme.h" #include "auth/basic/auth_basic.h" -namespace Auth { -namespace Basic { +namespace Auth +{ +namespace Basic +{ /// \ingroup AuthAPI /// \ingroup AuthSchemeAPI -class Scheme : public AuthScheme +class Scheme : public Auth::Scheme { public: - static AuthScheme::Pointer GetInstance(); + static Auth::Scheme::Pointer GetInstance(); Scheme() {}; virtual ~Scheme() {} /* per scheme */ virtual char const *type() const; - virtual void done(); + virtual void shutdownCleanup(); virtual AuthConfig *createConfig(); /* Not implemented */ Scheme(Scheme const &); Scheme &operator=(Scheme const &); private: - static AuthScheme::Pointer _instance; + static Auth::Scheme::Pointer _instance; }; } // namespace Basic diff --git a/src/auth/digest/Scheme.cc b/src/auth/digest/Scheme.cc index 51ef0ca83d..3cbf2f8127 100644 --- a/src/auth/digest/Scheme.cc +++ b/src/auth/digest/Scheme.cc @@ -34,9 +34,9 @@ #include "auth/digest/Scheme.h" #include "helper.h" -AuthScheme::Pointer Auth::Digest::Scheme::_instance = NULL; +Auth::Scheme::Pointer Auth::Digest::Scheme::_instance = NULL; -AuthScheme::Pointer +Auth::Scheme::Pointer Auth::Digest::Scheme::GetInstance() { if (_instance == NULL) { @@ -53,7 +53,7 @@ Auth::Digest::Scheme::type() const } void -Auth::Digest::Scheme::done() +Auth::Digest::Scheme::shutdownCleanup() { if (_instance == NULL) return; diff --git a/src/auth/digest/Scheme.h b/src/auth/digest/Scheme.h index f6e4f22004..1b361a9721 100644 --- a/src/auth/digest/Scheme.h +++ b/src/auth/digest/Scheme.h @@ -36,22 +36,24 @@ #include "auth/Scheme.h" #include "auth/digest/auth_digest.h" -namespace Auth { -namespace Digest { +namespace Auth +{ +namespace Digest +{ /// \ingroup AuthSchemeAPI /// \ingroup AuthAPI -class Scheme : public AuthScheme +class Scheme : public Auth::Scheme { public: - static AuthScheme::Pointer GetInstance(); + static Auth::Scheme::Pointer GetInstance(); Scheme() {}; virtual ~Scheme() {} /* per scheme */ virtual char const *type () const; - virtual void done(); + virtual void shutdownCleanup(); virtual AuthConfig *createConfig(); /* Not implemented */ @@ -59,7 +61,7 @@ public: Scheme &operator=(Scheme const &); private: - static AuthScheme::Pointer _instance; + static Auth::Scheme::Pointer _instance; /** * Remove all cached user credentials from circulation. diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index e1571ca116..013680c603 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -653,7 +653,7 @@ AuthDigestConfig::done() httpHeaderDestroyFieldsInfo(DigestFieldsInfo, DIGEST_ENUM_END); DigestFieldsInfo = NULL; } - + if (!shutting_down) return; diff --git a/src/auth/negotiate/Scheme.cc b/src/auth/negotiate/Scheme.cc index 70a911d204..d6d77d9e5a 100644 --- a/src/auth/negotiate/Scheme.cc +++ b/src/auth/negotiate/Scheme.cc @@ -34,9 +34,9 @@ #include "auth/negotiate/Scheme.h" #include "helper.h" -AuthScheme::Pointer Auth::Negotiate::Scheme::_instance = NULL; +Auth::Scheme::Pointer Auth::Negotiate::Scheme::_instance = NULL; -AuthScheme::Pointer +Auth::Scheme::Pointer Auth::Negotiate::Scheme::GetInstance() { if (_instance == NULL) { @@ -53,7 +53,7 @@ Auth::Negotiate::Scheme::type() const } void -Auth::Negotiate::Scheme::done() +Auth::Negotiate::Scheme::shutdownCleanup() { if (_instance == NULL) return; diff --git a/src/auth/negotiate/Scheme.h b/src/auth/negotiate/Scheme.h index 6ab2255566..b65cb5748f 100644 --- a/src/auth/negotiate/Scheme.h +++ b/src/auth/negotiate/Scheme.h @@ -36,22 +36,24 @@ #include "auth/Scheme.h" #include "auth/negotiate/auth_negotiate.h" -namespace Auth { -namespace Negotiate { +namespace Auth +{ +namespace Negotiate +{ /// \ingroup AuthSchemeAPI /// \ingroup AuthAPI -class Scheme : public AuthScheme +class Scheme : public Auth::Scheme { public: - static AuthScheme::Pointer GetInstance(); + static Auth::Scheme::Pointer GetInstance(); Scheme() {}; virtual ~Scheme() {}; /* per scheme */ virtual char const *type() const; - virtual void done(); + virtual void shutdownCleanup(); virtual AuthConfig *createConfig(); /* Not implemented */ @@ -59,7 +61,7 @@ public: Scheme &operator=(Scheme const &); private: - static AuthScheme::Pointer _instance; + static Auth::Scheme::Pointer _instance; }; } // namespace Negotiate diff --git a/src/auth/negotiate/UserRequest.cc b/src/auth/negotiate/UserRequest.cc index b6df1b6cdd..a7177e9c75 100644 --- a/src/auth/negotiate/UserRequest.cc +++ b/src/auth/negotiate/UserRequest.cc @@ -348,7 +348,7 @@ AuthNegotiateUserRequest::HandleReply(void *data, void *lastserver, char *reply) AuthUserHashPointer *usernamehash = static_cast(hash_lookup(proxy_auth_username_cache, auth_user_request->user()->username())); AuthUser::Pointer local_auth_user = negotiate_request->user(); while (usernamehash && (usernamehash->user()->auth_type != Auth::AUTH_NEGOTIATE || - strcmp(usernamehash->user()->username(), auth_user_request->user()->username()) != 0)) + strcmp(usernamehash->user()->username(), auth_user_request->user()->username()) != 0)) usernamehash = static_cast(usernamehash->next); if (usernamehash) { /* we can't seamlessly recheck the username due to the diff --git a/src/auth/ntlm/Scheme.cc b/src/auth/ntlm/Scheme.cc index 9ef0fc1d2b..fa25c9c445 100644 --- a/src/auth/ntlm/Scheme.cc +++ b/src/auth/ntlm/Scheme.cc @@ -35,9 +35,9 @@ #include "auth/ntlm/Scheme.h" #include "helper.h" -AuthScheme::Pointer Auth::Ntlm::Scheme::_instance = NULL; +Auth::Scheme::Pointer Auth::Ntlm::Scheme::_instance = NULL; -AuthScheme::Pointer +Auth::Scheme::Pointer Auth::Ntlm::Scheme::GetInstance() { if (_instance == NULL) { @@ -54,7 +54,7 @@ Auth::Ntlm::Scheme::type() const } void -Auth::Ntlm::Scheme::done() +Auth::Ntlm::Scheme::shutdownCleanup() { if (_instance == NULL) return; diff --git a/src/auth/ntlm/Scheme.h b/src/auth/ntlm/Scheme.h index ee7c1c43d5..cdbf794fc9 100644 --- a/src/auth/ntlm/Scheme.h +++ b/src/auth/ntlm/Scheme.h @@ -36,22 +36,24 @@ #include "auth/Scheme.h" #include "auth/ntlm/auth_ntlm.h" -namespace Auth { -namespace Ntlm { +namespace Auth +{ +namespace Ntlm +{ /// \ingroup AuthSchemeAPI /// \ingroup AuthAPI -class Scheme : public AuthScheme +class Scheme : public Auth::Scheme { public: - static AuthScheme::Pointer GetInstance(); + static Auth::Scheme::Pointer GetInstance(); Scheme() {}; virtual ~Scheme() {}; /* per scheme */ virtual char const *type() const; - virtual void done(); + virtual void shutdownCleanup(); virtual AuthConfig *createConfig(); /* Not implemented */ @@ -63,7 +65,7 @@ private: * Main instance of this authentication Scheme. * NULL when the scheme is not being used. */ - static AuthScheme::Pointer _instance; + static Auth::Scheme::Pointer _instance; }; } // namespace Ntlm diff --git a/src/auth/ntlm/UserRequest.cc b/src/auth/ntlm/UserRequest.cc index 6aa7bd8d25..f655831852 100644 --- a/src/auth/ntlm/UserRequest.cc +++ b/src/auth/ntlm/UserRequest.cc @@ -308,7 +308,7 @@ AuthNTLMUserRequest::HandleReply(void *data, void *lastserver, char *reply) auth_user_hash_pointer *usernamehash = static_cast(hash_lookup(proxy_auth_username_cache, auth_user_request->user()->username())); AuthUser::Pointer local_auth_user = ntlm_request->user(); while (usernamehash && (usernamehash->user()->auth_type != Auth::AUTH_NTLM || - strcmp(usernamehash->user()->username(), auth_user_request->user()->username()) != 0)) + strcmp(usernamehash->user()->username(), auth_user_request->user()->username()) != 0)) usernamehash = static_cast(usernamehash->next); if (usernamehash) { /* we can't seamlessly recheck the username due to the diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 9d97688e6c..7b5ae5be24 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1851,7 +1851,7 @@ parse_authparam(Auth::authConfig * config) if (schemeCfg == NULL) { /* Create a configuration based on the scheme info */ - AuthScheme::Pointer theScheme = AuthScheme::Find(type_str); + Auth::Scheme::Pointer theScheme = Auth::Scheme::Find(type_str); if (theScheme == NULL) { debugs(3, DBG_CRITICAL, "Parsing Config File: Unknown authentication scheme '" << type_str << "'."); diff --git a/src/main.cc b/src/main.cc index 8672de6f83..1c2d8ca772 100644 --- a/src/main.cc +++ b/src/main.cc @@ -235,7 +235,7 @@ SignalEngine::doShutdown(time_t wait) serverConnectionsClose(); #if USE_AUTH /* detach the auth components (only do this on full shutdown) */ - AuthScheme::FreeAll(); + Auth::Scheme::FreeAll(); #endif eventAdd("SquidShutdown", &StopEventLoop, this, (double) (wait + 1), 1, false); } diff --git a/src/tests/testAuth.cc b/src/tests/testAuth.cc index db233cd166..0476220c10 100644 --- a/src/tests/testAuth.cc +++ b/src/tests/testAuth.cc @@ -68,7 +68,7 @@ getConfig(char const *type_str) if (scheme == NULL) { /* Create a configuration */ - AuthScheme::Pointer theScheme = AuthScheme::Find(type_str); + Auth::Scheme::Pointer theScheme = Auth::Scheme::Find(type_str); if (theScheme == NULL) { return NULL; @@ -158,7 +158,7 @@ testAuthConfig::create() Debug::Levels[29]=9; fake_auth_setup(); - for (AuthScheme::iterator i = AuthScheme::GetSchemes().begin(); i != AuthScheme::GetSchemes().end(); ++i) { + for (Auth::Scheme::iterator i = Auth::Scheme::GetSchemes().begin(); i != Auth::Scheme::GetSchemes().end(); ++i) { AuthUserRequest::Pointer authRequest = AuthConfig::CreateAuthUser(find_proxy_auth((*i)->type())); CPPUNIT_ASSERT(authRequest != NULL); } @@ -177,7 +177,7 @@ testAuthUserRequest::scheme() Debug::Levels[29]=9; fake_auth_setup(); - for (AuthScheme::iterator i = AuthScheme::GetSchemes().begin(); i != AuthScheme::GetSchemes().end(); ++i) { + for (Auth::Scheme::iterator i = Auth::Scheme::GetSchemes().begin(); i != Auth::Scheme::GetSchemes().end(); ++i) { // create a user request // check its scheme matches *i AuthUserRequest::Pointer authRequest = AuthConfig::CreateAuthUser(find_proxy_auth((*i)->type()));