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