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