]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceLayout: (Bug 3170) namespace for Auth::Scheme and children
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 28 Mar 2011 10:51:53 +0000 (04:51 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 28 Mar 2011 10:51:53 +0000 (04:51 -0600)
Also,
 * fix digest shutdown process so AuthDigestConfig does the config cleanup
   and Auth::Digest::Scheme does the scheme termination
 * fix all schemes shutdown to silence scheme messages (partial bug 3170)

16 files changed:
src/AuthReg.cc
src/auth/Scheme.cc
src/auth/Scheme.h
src/auth/basic/Scheme.cc
src/auth/basic/Scheme.h
src/auth/basic/auth_basic.cc
src/auth/digest/Scheme.cc
src/auth/digest/Scheme.h
src/auth/digest/auth_digest.cc
src/auth/digest/auth_digest.h
src/auth/negotiate/Scheme.cc
src/auth/negotiate/Scheme.h
src/auth/negotiate/auth_negotiate.cc
src/auth/ntlm/Scheme.cc
src/auth/ntlm/Scheme.h
src/auth/ntlm/auth_ntlm.cc

index 19c95937e338eab08ab3ad25450a3fd0fca58ac6..d47b34cb70b5f23ccc5a29960f7e876b3d006f38 100644 (file)
@@ -27,19 +27,19 @@ InitAuthSchemes()
 {
     debugs(29,1,"Initializing Authentication Schemes ...");
 #if HAVE_AUTH_MODULE_BASIC
-    static const char *basic_type = basicScheme::GetInstance()->type();
+    static const char *basic_type = Auth::Basic::Scheme::GetInstance()->type();
     debugs(29,1,"Initialized Authentication Scheme '" << basic_type << "'");
 #endif
 #if HAVE_AUTH_MODULE_DIGEST
-    static const char *digest_type = digestScheme::GetInstance()->type();
+    static const char *digest_type = Auth::Digest::Scheme::GetInstance()->type();
     debugs(29,1,"Initialized Authentication Scheme '" << digest_type << "'");
 #endif
 #if HAVE_AUTH_MODULE_NEGOTIATE
-    static const char *negotiate_type = negotiateScheme::GetInstance()->type();
+    static const char *negotiate_type = Auth::Negotiate::Scheme::GetInstance()->type();
     debugs(29,1,"Initialized Authentication Scheme '" << negotiate_type << "'");
 #endif
 #if HAVE_AUTH_MODULE_NTLM
-    static const char *ntlm_type = ntlmScheme::GetInstance()->type();
+    static const char *ntlm_type = Auth::Ntlm::Scheme::GetInstance()->type();
     debugs(29,1,"Initialized Authentication Scheme '" << ntlm_type << "'");
 #endif
     debugs(29,1,"Initializing Authentication Schemes Complete.");
index 5a86b2edb3f21c036bff59113638d1ce90ef8b70..0ec60226f7a69fdd70195a90879f23797e1b8993 100644 (file)
@@ -57,7 +57,7 @@ AuthScheme::Pointer
 AuthScheme::Find(const char *typestr)
 {
     for (iterator i = GetSchemes().begin(); i != GetSchemes().end(); ++i) {
-        if (strcmp ((*i)->type(), typestr) == 0)
+        if (strcmp((*i)->type(), typestr) == 0)
             return *i;
     }
 
index 46fee0f510ef15e6ebeae4fd37a054db2a12df09..60940fa81989870f852600870db3653958868aa0 100644 (file)
@@ -85,7 +85,7 @@ public:
     static AuthScheme::Pointer Find(const char *);
 
     /* per scheme methods */
-    virtual char const *type () const = 0;
+    virtual char const *type() const = 0;
     virtual void done() = 0;
     virtual AuthConfig *createConfig() = 0;
 
index ba93a05f8158b0fb2998246a8c611d826d8be340..e861912d15f602f9c1044a1dd442d03f6db2c338 100644 (file)
 /* for AuthConfig */
 #include "auth/basic/auth_basic.h"
 
-AuthScheme::Pointer basicScheme::_instance = NULL;
+AuthScheme::Pointer Auth::Basic::Scheme::_instance = NULL;
 
 AuthScheme::Pointer
-basicScheme::GetInstance()
+Auth::Basic::Scheme::GetInstance()
 {
     if (_instance == NULL) {
-        _instance = new basicScheme();
+        _instance = new Auth::Basic::Scheme();
         AddScheme(_instance);
     }
     return _instance;
 }
 
 char const *
-basicScheme::type () const
+basicScheme::type() const
 {
     return "basic";
 }
 
 void
-basicScheme::done()
+Auth::Basic::Scheme::done()
 {
-    /* clear the global handle to this scheme. */
-    _instance = NULL;
+    if (_instance == NULL)
+        return;
 
-    debugs(29, DBG_CRITICAL, HERE << "Basic authentication Schema Detached.");
+    _instance = NULL;
+    debugs(29, DBG_CRITICAL, "Shutdown: Basic authentication.");
 }
 
 AuthConfig *
-basicScheme::createConfig()
+Auth::Basic::Scheme::createConfig()
 {
     AuthBasicConfig *newCfg = new AuthBasicConfig;
     return dynamic_cast<AuthConfig*>(newCfg);
index 587e49c5949aa0aba89f84febfd37a3bcc2c8019..c0d1871183e45a356cffa54e1c0741281f76395e 100644 (file)
  *
  */
 
-#ifndef SQUID_BASICSCHEME_H
-#define SQUID_BASICSCHEME_H
+#ifndef SQUID_AUTH_BASIC_SCHEME_H
+#define SQUID_AUTH_BASIC_SCHEME_H
 
 #include "auth/Scheme.h"
 #include "auth/basic/auth_basic.h"
 
+namespace Auth {
+namespace Basic {
+
 /// \ingroup AuthAPI
 /// \ingroup AuthSchemeAPI
-class basicScheme : public AuthScheme
+class Scheme : public AuthScheme
 {
 
 public:
     static AuthScheme::Pointer GetInstance();
-    basicScheme() {};
-    virtual ~basicScheme() {}
+    Scheme() {};
+    virtual ~Scheme() {}
 
     /* per scheme */
-    virtual char const *type () const;
+    virtual char const *type() const;
     virtual void done();
     virtual AuthConfig *createConfig();
     /* Not implemented */
-    basicScheme (basicScheme const &);
-    basicScheme &operator=(basicScheme const &);
+    Scheme(Scheme const &);
+    Scheme &operator=(Scheme const &);
 
 private:
     static AuthScheme::Pointer _instance;
 };
 
-#endif /* SQUID_BASICSCHEME_H */
+} // namespace Basic
+} // namespace Auth
+
+#endif /* SQUID_AUTH_BASIC_SCHEME_H */
index 299a22b8ad6554657ebcd71aff114729b953d01c..8503eadd8afc0809eb0a9d17ec2a4926a78ad93e 100644 (file)
@@ -91,7 +91,7 @@ AuthBasicConfig::configured() const
 const char *
 AuthBasicConfig::type() const
 {
-    return basicScheme::GetInstance()->type();
+    return Auth::Basic::Scheme::GetInstance()->type();
 }
 
 int32_t
index 129335d55ee5fcb0424015043c6ca22c4f14ee7f..51ef0ca83d14df0ba5a98e447412a8acc9c1acd5 100644 (file)
 #include "auth/digest/Scheme.h"
 #include "helper.h"
 
+AuthScheme::Pointer Auth::Digest::Scheme::_instance = NULL;
+
 AuthScheme::Pointer
-digestScheme::GetInstance()
+Auth::Digest::Scheme::GetInstance()
 {
     if (_instance == NULL) {
-        _instance = new digestScheme();
+        _instance = new Auth::Digest::Scheme();
         AddScheme(_instance);
     }
     return _instance;
 }
 
 char const *
-digestScheme::type () const
+Auth::Digest::Scheme::type() const
 {
     return "digest";
 }
 
-AuthScheme::Pointer digestScheme::_instance = NULL;
+void
+Auth::Digest::Scheme::done()
+{
+    if (_instance == NULL)
+        return;
+
+    PurgeCredentialsCache();
+    authenticateDigestNonceShutdown();
+
+    _instance = NULL;
+    debugs(29, DBG_CRITICAL, "Shutdown: Digest authentication.");
+}
 
 AuthConfig *
-digestScheme::createConfig()
+Auth::Digest::Scheme::createConfig()
 {
     AuthDigestConfig *digestCfg = new AuthDigestConfig;
     return dynamic_cast<AuthConfig*>(digestCfg);
 }
 
 void
-digestScheme::PurgeCredentialsCache(void)
+Auth::Digest::Scheme::PurgeCredentialsCache(void)
 {
     AuthUserHashPointer *usernamehash;
-    AuthUser::Pointer auth_user;
+
+    debugs(29, 2, HERE << "Erasing Digest authentication credentials from username cache.");
     hash_first(proxy_auth_username_cache);
 
     while ((usernamehash = static_cast<AuthUserHashPointer *>(hash_next(proxy_auth_username_cache)) )) {
-        auth_user = usernamehash->user();
+        AuthUser::Pointer auth_user = usernamehash->user();
 
         if (strcmp(auth_user->config->type(), "digest") == 0) {
             hash_remove_link(proxy_auth_username_cache, static_cast<hash_link*>(usernamehash));
index 1d7652574b26ef55ee231ae97045b5acfb00db50..f6e4f22004f463f4842736ae1adee97aee540dd4 100644 (file)
  *
  */
 
-#ifndef SQUID_DIGESTSCHEME_H
-#define SQUID_DIGESTSCHEME_H
+#ifndef SQUID_AUTH_DIGEST_SCHEME_H
+#define SQUID_AUTH_DIGEST_SCHEME_H
 
 #include "auth/Scheme.h"
 #include "auth/digest/auth_digest.h"
 
+namespace Auth {
+namespace Digest {
+
 /// \ingroup AuthSchemeAPI
 /// \ingroup AuthAPI
-class digestScheme : public AuthScheme
+class Scheme : public AuthScheme
 {
 
 public:
     static AuthScheme::Pointer GetInstance();
-    digestScheme() {};
-    virtual ~digestScheme() {}
+    Scheme() {};
+    virtual ~Scheme() {}
 
     /* per scheme */
     virtual char const *type () const;
@@ -52,8 +55,8 @@ public:
     virtual AuthConfig *createConfig();
 
     /* Not implemented */
-    digestScheme (digestScheme const &);
-    digestScheme &operator=(digestScheme const &);
+    Scheme(Scheme const &);
+    Scheme &operator=(Scheme const &);
 
 private:
     static AuthScheme::Pointer _instance;
@@ -66,4 +69,7 @@ private:
     static void PurgeCredentialsCache(void);
 };
 
-#endif /* SQUID_DIGESTSCHEME_H */
+} // namespace Digest
+} // namespace Auth
+
+#endif /* SQUID_AUTH_DIGEST_SCHEME_H */
index 05417f3b7b19f8838d1546edd18f0f8c62ba590c..e1571ca116271b305690f824de4b20a4845cd99f 100644 (file)
@@ -103,8 +103,6 @@ static digest_nonce_h *authenticateDigestNonceFindNonce(const char *nonceb64);
 static digest_nonce_h *authenticateDigestNonceNew(void);
 static void authenticateDigestNonceDelete(digest_nonce_h * nonce);
 static void authenticateDigestNonceSetup(void);
-static void authenticateDigestNonceShutdown(void);
-static void authenticateDigestNonceReconfigure(void);
 static int authDigestNonceIsStale(digest_nonce_h * nonce);
 static void authDigestNonceEncode(digest_nonce_h * nonce);
 static void authDigestNonceLink(digest_nonce_h * nonce);
@@ -231,7 +229,7 @@ authenticateDigestNonceSetup(void)
     }
 }
 
-static void
+void
 authenticateDigestNonceShutdown(void)
 {
     /*
@@ -259,10 +257,6 @@ authenticateDigestNonceShutdown(void)
     debugs(29, 2, "authenticateDigestNonceShutdown: Nonce cache shutdown");
 }
 
-static void
-authenticateDigestNonceReconfigure(void)
-{}
-
 static void
 authenticateDigestNonceCacheCleanup(void *data)
 {
@@ -509,38 +503,6 @@ AuthDigestConfig::rotateHelpers()
     /* NP: dynamic helper restart will ensure they start up again as needed. */
 }
 
-/** delete the digest request structure. Does NOT delete related structures */
-void
-digestScheme::done()
-{
-    /** \todo this should be a Config call. */
-
-    if (digestauthenticators)
-        helperShutdown(digestauthenticators);
-
-    if (DigestFieldsInfo) {
-        httpHeaderDestroyFieldsInfo(DigestFieldsInfo, DIGEST_ENUM_END);
-        DigestFieldsInfo = NULL;
-    }
-
-    authdigest_initialised = 0;
-
-    if (!shutting_down) {
-        authenticateDigestNonceReconfigure();
-        return;
-    }
-
-    delete digestauthenticators;
-    digestauthenticators = NULL;
-
-    PurgeCredentialsCache();
-    authenticateDigestNonceShutdown();
-    debugs(29, 2, "authenticateDigestDone: Digest authentication shut down.");
-
-    /* clear the global handle to this scheme. */
-    _instance = NULL;
-}
-
 void
 AuthDigestConfig::dump(StoreEntry * entry, const char *name, AuthConfig * scheme)
 {
@@ -682,6 +644,22 @@ AuthDigestConfig::registerWithCacheManager(void)
 void
 AuthDigestConfig::done()
 {
+    authdigest_initialised = 0;
+
+    if (digestauthenticators)
+        helperShutdown(digestauthenticators);
+
+    if (DigestFieldsInfo) {
+        httpHeaderDestroyFieldsInfo(DigestFieldsInfo, DIGEST_ENUM_END);
+        DigestFieldsInfo = NULL;
+    }
+        
+    if (!shutting_down)
+        return;
+
+    delete digestauthenticators;
+    digestauthenticators = NULL;
+
     if (authenticateProgram)
         wordlistDestroy(&authenticateProgram);
 
@@ -739,7 +717,7 @@ AuthDigestConfig::parse(AuthConfig * scheme, int n_configured, char *param_str)
 const char *
 AuthDigestConfig::type() const
 {
-    return digestScheme::GetInstance()->type();
+    return Auth::Digest::Scheme::GetInstance()->type();
 }
 
 
index d1fc220f599fb7edfb0b1089ecf4a0366fd9c1f6..5545345db0936c89b08b0101e26f17ddace6921b 100644 (file)
@@ -74,6 +74,7 @@ extern void authDigestNonceUnlink(digest_nonce_h * nonce);
 extern int authDigestNonceIsValid(digest_nonce_h * nonce, char nc[9]);
 extern const char *authenticateDigestNonceNonceb64(const digest_nonce_h * nonce);
 extern int authDigestNonceLastRequest(digest_nonce_h * nonce);
+extern void authenticateDigestNonceShutdown(void);
 
 /* configuration runtime data */
 
index 95c02bca78ed50ea7052fa8e5cacee7449c23bcd..70a911d204ce699e25105d05a54b3abecad1d5c3 100644 (file)
 #include "auth/negotiate/Scheme.h"
 #include "helper.h"
 
+AuthScheme::Pointer Auth::Negotiate::Scheme::_instance = NULL;
+
 AuthScheme::Pointer
-negotiateScheme::GetInstance()
+Auth::Negotiate::Scheme::GetInstance()
 {
     if (_instance == NULL) {
-        _instance = new negotiateScheme();
+        _instance = new Auth::Negotiate::Scheme();
         AddScheme(_instance);
     }
     return _instance;
 }
 
 char const *
-negotiateScheme::type () const
+Auth::Negotiate::Scheme::type() const
 {
     return "negotiate";
 }
 
-AuthScheme::Pointer negotiateScheme::_instance = NULL;
-
-/**
- \ingroup AuthNegotiateInternal
- \todo move to negotiateScheme.cc
- */
 void
-negotiateScheme::done()
+Auth::Negotiate::Scheme::done()
 {
-    /* clear the global handle to this scheme. */
-    _instance = NULL;
+    if (_instance == NULL)
+        return;
 
-    debugs(29, 2, "negotiateScheme::done: Negotiate authentication Shutdown.");
+    _instance = NULL;
+    debugs(29, DBG_CRITICAL, "Shutdown: Negotiate authentication.");
 }
 
 AuthConfig *
-negotiateScheme::createConfig()
+Auth::Negotiate::Scheme::createConfig()
 {
     AuthNegotiateConfig *negotiateCfg = new AuthNegotiateConfig;
     return dynamic_cast<AuthConfig*>(negotiateCfg);
index 89ad24495b35407dd9047c15905d7f79cde6640f..6ab2255566a766d8364be648757901a1c6503dcc 100644 (file)
  *
  */
 
-#ifndef SQUID_NEGOTIATESCHEME_H
-#define SQUID_NEGOTIATESCHEME_H
+#ifndef SQUID_AUTH_NEGOTIATE_SCHEME_H
+#define SQUID_AUTH_NEGOTIATE_SCHEME_H
 
 #include "auth/Scheme.h"
 #include "auth/negotiate/auth_negotiate.h"
 
+namespace Auth {
+namespace Negotiate {
+
 /// \ingroup AuthSchemeAPI
 /// \ingroup AuthAPI
-class negotiateScheme : public AuthScheme
+class Scheme : public AuthScheme
 {
 
 public:
     static AuthScheme::Pointer GetInstance();
-    negotiateScheme() {};
-    virtual ~negotiateScheme() {};
+    Scheme() {};
+    virtual ~Scheme() {};
 
     /* per scheme */
-    virtual char const *type () const;
+    virtual char const *type() const;
     virtual void done();
     virtual AuthConfig *createConfig();
 
     /* Not implemented */
-    negotiateScheme (negotiateScheme const &);
-    negotiateScheme &operator=(negotiateScheme const &);
+    Scheme (Scheme const &);
+    Scheme &operator=(Scheme const &);
 
 private:
     static AuthScheme::Pointer _instance;
 };
 
-#endif /* SQUID_negotiateSCHEME_H */
+} // namespace Negotiate
+} // namespace Auth
+
+#endif /* SQUID_AUTH_NEGOTIATE_SCHEME_H */
index faf9401e373904d02aa58f567e09def259d27673..f082e8158ad0d6121fc6911eb73937492741165b 100644 (file)
@@ -151,7 +151,7 @@ AuthNegotiateConfig::parse(AuthConfig * scheme, int n_configured, char *param_st
 const char *
 AuthNegotiateConfig::type() const
 {
-    return negotiateScheme::GetInstance()->type();
+    return Auth::Negotiate::Scheme::GetInstance()->type();
 }
 
 /**
index bf727d87970da7d473a75f8b05bedf0037c0ba19..9ef0fc1d2b8b4dfe49ce79653cbac18ce3700ed0 100644 (file)
 #include "auth/ntlm/Scheme.h"
 #include "helper.h"
 
+AuthScheme::Pointer Auth::Ntlm::Scheme::_instance = NULL;
+
 AuthScheme::Pointer
-ntlmScheme::GetInstance()
+Auth::Ntlm::Scheme::GetInstance()
 {
     if (_instance == NULL) {
-        _instance = new ntlmScheme();
+        _instance = new Auth::Ntlm::Scheme();
         AddScheme(_instance);
     }
     return _instance;
 }
 
 char const *
-ntlmScheme::type () const
+Auth::Ntlm::Scheme::type() const
 {
     return "ntlm";
 }
 
-AuthScheme::Pointer ntlmScheme::_instance = NULL;
-
 void
-ntlmScheme::done()
+Auth::Ntlm::Scheme::done()
 {
-    /* clear the global handle to this scheme. */
-    _instance = NULL;
+    if (_instance == NULL)
+        return;
 
-    debugs(29, 2, "ntlmScheme::done: NTLM authentication Shutdown.");
+    _instance = NULL;
+    debugs(29, DBG_CRITICAL, "Shutdown: NTLM authentication.");
 }
 
 AuthConfig *
-ntlmScheme::createConfig()
+Auth::Ntlm::Scheme::createConfig()
 {
     auth_ntlm_config *ntlmCfg = new auth_ntlm_config;
     return dynamic_cast<AuthConfig*>(ntlmCfg);
index e48bf82d4c6e3721942c8cd4deb4f6573de88f74..ee7c1c43d59011f75d0f390dc595c29d65c6ddf7 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * $Id$
  *
  *
  */
 
-#ifndef SQUID_NTLMSCHEME_H
-#define SQUID_NTLMSCHEME_H
+#ifndef SQUID_AUTH_NTLM_SCHEME_H
+#define SQUID_AUTH_NTLM_SCHEME_H
 
 #include "auth/Scheme.h"
 #include "auth/ntlm/auth_ntlm.h"
 
+namespace Auth {
+namespace Ntlm {
+
 /// \ingroup AuthSchemeAPI
 /// \ingroup AuthAPI
-class ntlmScheme : public AuthScheme
+class Scheme : public AuthScheme
 {
 
 public:
     static AuthScheme::Pointer GetInstance();
-    ntlmScheme() {};
-    virtual ~ntlmScheme() {};
+    Scheme() {};
+    virtual ~Scheme() {};
 
     /* per scheme */
-    virtual char const *type () const;
+    virtual char const *type() const;
     virtual void done();
     virtual AuthConfig *createConfig();
 
     /* Not implemented */
-    ntlmScheme (ntlmScheme const &);
-    ntlmScheme &operator=(ntlmScheme const &);
+    Scheme (Scheme const &);
+    Scheme &operator=(Scheme const &);
 
 private:
     /**
@@ -64,4 +66,7 @@ private:
     static AuthScheme::Pointer _instance;
 };
 
-#endif /* SQUID_ntlmSCHEME_H */
+} // namespace Ntlm
+} // namespace Auth
+
+#endif /* SQUID_AUTH_NTLM_SCHEME_H */
index a38d5243611bc43f35db5ce8fc0bf2ef1fe32bbe..9e3e8ebf6e1449b4ecb2650e65fc9937a84ec95a 100644 (file)
@@ -140,7 +140,7 @@ AuthNTLMConfig::parse(AuthConfig * scheme, int n_configured, char *param_str)
 const char *
 AuthNTLMConfig::type() const
 {
-    return ntlmScheme::GetInstance()->type();
+    return Auth::Ntlm::Scheme::GetInstance()->type();
 }
 
 /* Initialize helpers and the like for this auth scheme. Called AFTER parsing the