]>
Commit | Line | Data |
---|---|---|
f5691f9c | 1 | /* |
bde978a6 | 2 | * Copyright (C) 1996-2015 The Squid Software Foundation and contributors |
f5691f9c | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
f5691f9c | 7 | */ |
8 | ||
f7f3304a | 9 | #include "squid.h" |
12daeef6 | 10 | #include "auth/digest/Config.h" |
616cfc4c | 11 | #include "auth/digest/Scheme.h" |
582c2af2 FC |
12 | #include "Debug.h" |
13 | #include "globals.h" | |
5817ee13 | 14 | #include "helper.h" |
f5691f9c | 15 | |
c6cf8dee | 16 | Auth::Scheme::Pointer Auth::Digest::Scheme::_instance = NULL; |
d6374be6 | 17 | |
c6cf8dee | 18 | Auth::Scheme::Pointer |
d6374be6 | 19 | Auth::Digest::Scheme::GetInstance() |
f5691f9c | 20 | { |
5817ee13 | 21 | if (_instance == NULL) { |
d6374be6 | 22 | _instance = new Auth::Digest::Scheme(); |
5817ee13 AJ |
23 | AddScheme(_instance); |
24 | } | |
25 | return _instance; | |
f5691f9c | 26 | } |
27 | ||
28 | char const * | |
d6374be6 | 29 | Auth::Digest::Scheme::type() const |
f5691f9c | 30 | { |
31 | return "digest"; | |
32 | } | |
33 | ||
d6374be6 | 34 | void |
c6cf8dee | 35 | Auth::Digest::Scheme::shutdownCleanup() |
d6374be6 AJ |
36 | { |
37 | if (_instance == NULL) | |
38 | return; | |
39 | ||
40 | PurgeCredentialsCache(); | |
41 | authenticateDigestNonceShutdown(); | |
42 | ||
43 | _instance = NULL; | |
44 | debugs(29, DBG_CRITICAL, "Shutdown: Digest authentication."); | |
45 | } | |
5817ee13 | 46 | |
9f3d2b2e | 47 | Auth::Config * |
d6374be6 | 48 | Auth::Digest::Scheme::createConfig() |
5817ee13 | 49 | { |
372fccd6 | 50 | Auth::Digest::Config *digestCfg = new Auth::Digest::Config; |
9f3d2b2e | 51 | return dynamic_cast<Auth::Config*>(digestCfg); |
5817ee13 | 52 | } |
56a49fda AJ |
53 | |
54 | void | |
d6374be6 | 55 | Auth::Digest::Scheme::PurgeCredentialsCache(void) |
56a49fda AJ |
56 | { |
57 | AuthUserHashPointer *usernamehash; | |
d6374be6 AJ |
58 | |
59 | debugs(29, 2, HERE << "Erasing Digest authentication credentials from username cache."); | |
56a49fda AJ |
60 | hash_first(proxy_auth_username_cache); |
61 | ||
62 | while ((usernamehash = static_cast<AuthUserHashPointer *>(hash_next(proxy_auth_username_cache)) )) { | |
d87154ee | 63 | Auth::User::Pointer auth_user = usernamehash->user(); |
56a49fda AJ |
64 | |
65 | if (strcmp(auth_user->config->type(), "digest") == 0) { | |
66 | hash_remove_link(proxy_auth_username_cache, static_cast<hash_link*>(usernamehash)); | |
67 | delete usernamehash; | |
68 | } | |
69 | } | |
70 | } | |
f53969cc | 71 |