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