]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ssl/ErrorDetailManager.h
Bug 3605: memory leak in Negotiate authentication
[thirdparty/squid.git] / src / ssl / ErrorDetailManager.h
CommitLineData
02259ff8
CT
1#ifndef _SQUID_SSL_ERRORDETAILMANAGER_H
2#define _SQUID_SSL_ERRORDETAILMANAGER_H
3
4#include "ssl/support.h"
5#include "ssl/gadgets.h"
6#if HAVE_MAP
7#include <map>
8#endif
9#if HAVE_STRING
10#include <string>
11#endif
12
13namespace Ssl
14{
15
dc49061a
A
16class ErrorDetailEntry
17{
02259ff8
CT
18public:
19 Ssl::ssl_error_t error_no; ///< The SSL error code
20 String name; ///< a name for the error
21 String detail; ///< for error page %D macro expansion; may contain macros
22 String descr; ///< short error description (for use in debug messages or error pages)
23};
24
25/**
26 * Used to hold an error-details.txt template in ram. An error-details,.txt is represented
27 * by a list of error detail entries (ErrorDetailEntry objects).
28 */
29class ErrorDetailsList : public RefCountable
30{
31public:
32 typedef RefCount<ErrorDetailsList> Pointer;
33 /**
34 * Retrieves the error details for a given error to "entry" object
35 * \return true on success, false otherwise
36 */
37 bool getRecord(Ssl::ssl_error_t value, ErrorDetailEntry &entry);
38 const char *getErrorDescr(Ssl::ssl_error_t value); ///< an error description for an error if exist in list.
39 const char *getErrorDetail(Ssl::ssl_error_t value); ///< an error details for an error if exist in list.
40
41 String errLanguage; ///< The language of the error-details.txt template, if any
42 typedef std::map<Ssl::ssl_error_t, ErrorDetailEntry> ErrorDetails;
43 ErrorDetails theList; ///< The list of error details entries
44};
45
46/**
47 * It is used to load, manage and query multiple ErrorDetailLists
48 * objects.
49 */
dc49061a
A
50class ErrorDetailsManager
51{
02259ff8
CT
52public:
53 ErrorDetailsManager();
54
55 static ErrorDetailsManager &GetInstance(); ///< Instance class
56 static void Shutdown(); ///< reset the ErrorDetailsManager instance
57
58 /**
59 * Retrieve error details for an error. This method examine the Accept-Language
60 * of the request to retrieve the error details for requested language else return
61 * the default error details.
62 * \param vale the error code
63 * \param request the current HTTP request.
64 * \param entry where to store error details
65 * \return true on success, false otherwise
66 */
67 bool getErrorDetail(Ssl::ssl_error_t value, HttpRequest *request, ErrorDetailEntry &entry);
68 const char *getDefaultErrorDescr(Ssl::ssl_error_t value); ///< the default error description for a given error
69 const char *getDefaultErrorDetail(Ssl::ssl_error_t value); ///< the default error details for a given error
70
71private:
72 /// Return cached error details list for a given language if exist
73 ErrorDetailsList::Pointer getCachedDetails(const char *lang);
74 /// cache the given error details list.
75 void cacheDetails(ErrorDetailsList::Pointer &errorDetails);
76
77 typedef std::map<std::string, ErrorDetailsList::Pointer> Cache;
78 Cache cache; ///< the error details list cache
79 ErrorDetailsList::Pointer theDefaultErrorDetails; ///< the default error details list
80
81 /// An instance of ErrorDetailsManager to be used by squid (ssl/ErrorDetails.*)
82 static ErrorDetailsManager *TheDetailsManager;
83};
84
85
86void errorDetailInitialize();
87void errorDetailClean();
88} //namespace Ssl
89#endif