]> git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/Scheme.cc
Merge from trunk
[thirdparty/squid.git] / src / auth / Scheme.cc
1 /*
2 * DEBUG: section 29 Authenticator
3 * AUTHOR: Robert Collins
4 *
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
7 *
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
30 *
31 * Copyright (c) 2004, Robert Collins <robertc@squid-cache.org>
32 */
33
34 #include "squid.h"
35 #include "auth/Config.h"
36 #include "auth/Gadgets.h"
37 #include "auth/Scheme.h"
38 #include "globals.h"
39
40 std::vector<Auth::Scheme::Pointer> *Auth::Scheme::_Schemes = NULL;
41
42 void
43 Auth::Scheme::AddScheme(Auth::Scheme::Pointer instance)
44 {
45 iterator i = GetSchemes().begin();
46
47 while (i != GetSchemes().end()) {
48 assert(strcmp((*i)->type(), instance->type()) != 0);
49 ++i;
50 }
51
52 GetSchemes().push_back(instance);
53 }
54
55 Auth::Scheme::Pointer
56 Auth::Scheme::Find(const char *typestr)
57 {
58 for (iterator i = GetSchemes().begin(); i != GetSchemes().end(); ++i) {
59 if (strcmp((*i)->type(), typestr) == 0)
60 return *i;
61 }
62
63 return Auth::Scheme::Pointer(NULL);
64 }
65
66 std::vector<Auth::Scheme::Pointer> &
67 Auth::Scheme::GetSchemes()
68 {
69 if (!_Schemes)
70 _Schemes = new std::vector<Auth::Scheme::Pointer>;
71
72 return *_Schemes;
73 }
74
75 /**
76 * Called when a graceful shutdown is to occur of each scheme module.
77 * On completion the auth components are to be considered deleted.
78 * None will be available globally. Some may remain around for their
79 * currently active connections to close, but only those active
80 * connections will retain pointers to them.
81 */
82 void
83 Auth::Scheme::FreeAll()
84 {
85 assert(shutting_down);
86
87 while (GetSchemes().size()) {
88 Auth::Scheme::Pointer scheme = GetSchemes().back();
89 GetSchemes().pop_back();
90 scheme->shutdownCleanup();
91 }
92 }