source: squid-ssl/trunk/fuentes/src/auth/digest/Scheme.cc @ 5495

Last change on this file since 5495 was 5495, checked in by Juanma, 2 years ago

Initial release

File size: 1.8 KB
RevLine 
[5495]1/*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9#include "squid.h"
10#include "auth/digest/Config.h"
11#include "auth/digest/Scheme.h"
12#include "Debug.h"
13#include "globals.h"
14#include "helper.h"
15
16Auth::Scheme::Pointer Auth::Digest::Scheme::_instance = NULL;
17
18Auth::Scheme::Pointer
19Auth::Digest::Scheme::GetInstance()
20{
21    if (_instance == NULL) {
22        _instance = new Auth::Digest::Scheme();
23        AddScheme(_instance);
24    }
25    return _instance;
26}
27
28char const *
29Auth::Digest::Scheme::type() const
30{
31    return "digest";
32}
33
34void
35Auth::Digest::Scheme::shutdownCleanup()
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}
46
47Auth::Config *
48Auth::Digest::Scheme::createConfig()
49{
50    Auth::Digest::Config *digestCfg = new Auth::Digest::Config;
51    return dynamic_cast<Auth::Config*>(digestCfg);
52}
53
54void
55Auth::Digest::Scheme::PurgeCredentialsCache(void)
56{
57    AuthUserHashPointer *usernamehash;
58
59    debugs(29, 2, HERE << "Erasing Digest authentication credentials from username cache.");
60    hash_first(proxy_auth_username_cache);
61
62    while ((usernamehash = static_cast<AuthUserHashPointer *>(hash_next(proxy_auth_username_cache)) )) {
63        Auth::User::Pointer auth_user = usernamehash->user();
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}
71
Note: See TracBrowser for help on using the repository browser.