| AnyConnect Secure Mobility Client 5.1.10.233

PromptEntryBase.h
1/**************************************************************************
2* Copyright (c) 2008, 2022-2024 Cisco Systems, Inc.
3* All Rights Reserved. Cisco Highly Confidential.
4***************************************************************************
5*
6* File: PromptEntryBase.h
7* Date: 01/2008
8*
9***************************************************************************
10* Prompt Entry base class implementation for the Client API.
11***************************************************************************/
12
13#ifndef _PROMPTENTRYBASE_
14#define _PROMPTENTRYBASE_
15
16
17#include "api.h"
18#include <list>
19#include <unordered_set>
20
21
22#define PROMPT_ENTRY_VALUE_TRUE _T("true")
23#define PROMPT_ENTRY_VALUE_FALSE _T("false")
24
25 class VPN_VPNAPI PromptEntryBase
26{
27 public:
28
29 bool setValue(const tstring& value);
30 bool clearValue();
31
32 const tstring &getPromptName() const;
33
34 const tstring &getPromptLabel() const;
35
36 bool isEnabled() const;
37
38 void setEnabled(bool bIsEnabled);
39
40 bool isVisible() const;
41
42 void setVisible(bool bIsVisible);
43
44 // if this is a PromptEntry that has a list of values
45 // (e.g. combo box style) the default will be to mark it as a group
46 // combo. This method allows the group designation to be set directly.
47 //
48 void setEntryGroup(bool bIsEntryGroup);
49
50
51 PromptEntryBase(tstring PromptName,
52 tstring PromptLabel,
53 PromptType promptType = Prompt_Input,
54 const tstring& DefaultValue = EmptyString,
55 ApiStringMap LabelValues = EmptyLabelValues);
56
57
58 void setPromptLabel(tstring label);
59
60 // In cases of prompt types with options (checkbox, combobox),
61 // this will return the translated label (of the option).
62 const tstring &getValue() const;
63
64 // this function returns the internal representation of the value
65 const tstring &getTrueValue() const;
66
67 const std::list<tstring> &getValueOptions() const;
68
69 bool isEntryGroup() const;
70
71 bool isReadOnly() const;
72
73 PromptType getPromptType() const;
74
75 size_t GetGroupAttributesCount();
76
77
78 virtual ~PromptEntryBase();
79
80 static const tstring EmptyString;
81
82 static const std::list<tstring> EmptyList;
83
84 static const ApiStringMap EmptyLabelValues;
85
86 // Deep Copy Assignment Operator
87 //
88 PromptEntryBase& operator=(const PromptEntryBase& existingEntry)
89 {
90 return deepCopy(existingEntry);
91 }
92
93 // Deep Copy Constructor
94 //
95 explicit PromptEntryBase(const PromptEntryBase& existingEntry)
96 {
97 deepCopy(existingEntry);
98 }
99
100
101 private:
102
103 PromptEntryBase& deepCopy(const PromptEntryBase& existingEntry);
104
105 tstring ms_PromptName;
106 tstring ms_PromptLabel;
107 PromptType me_PromptType;
108 tstring ms_Value;
109 ApiStringMap msm_LabelValueMap;
110 std::list<tstring> mls_ValueOptions;
111 bool mb_IsEntryGroup;
112 bool mb_Enabled;
113 bool mb_Visible;
114
115 public:
116
117 class GroupAttributes
118 {
119 public:
120 GroupAttributes() :
121 CredRequired(true),
122 UsesSDIAuth(false),
123 UsernameEditable(true),
124 SecondaryUsernameEditable(true),
125 UsesSecondaryAuth(false)
126 {
127 }
128
129 // Deep Copy Constructor
130 //
131 explicit GroupAttributes(
132 const GroupAttributes& existingGroupAttr)
133 {
134 deepCopy(existingGroupAttr);
135 }
136
137 // Deep Copy Assignment Operator
138 //
139 GroupAttributes& operator=(
140 const GroupAttributes& existingGroupAttr)
141 {
142 return deepCopy(existingGroupAttr);
143 }
144
145 bool CredRequired;
146 bool UsesSDIAuth;
147 bool UsernameEditable;
148 tstring Username;
149 bool SecondaryUsernameEditable;
150 tstring SecondaryUsername;
151 bool UsesSecondaryAuth;
152
153 private:
154 GroupAttributes& deepCopy(const GroupAttributes& existingGroupAttr)
155 {
156 if (std::addressof(existingGroupAttr) != this)
157 {
158 CredRequired = existingGroupAttr.CredRequired;
159 UsesSDIAuth = existingGroupAttr.UsesSDIAuth;
160 UsernameEditable = existingGroupAttr.UsernameEditable;
161 Username = existingGroupAttr.Username.c_str();
162 SecondaryUsernameEditable = existingGroupAttr.SecondaryUsernameEditable;
163 SecondaryUsername = existingGroupAttr.SecondaryUsername.c_str();
164 UsesSecondaryAuth = existingGroupAttr.UsesSecondaryAuth;
165 }
166 return *this;
167 }
168 };
169
170 class SingleAttributes
171 {
172 public:
173 SingleAttributes() :
174 SecondaryAuthEntry(false),
175 SSOTimeoutSeconds(0),
176 SSOIsExternalBrowser(false)
177 {
178 }
179
180 // Deep Copy Constructor
181 //
182 explicit SingleAttributes(
183 const SingleAttributes& existingSingleAttr)
184 {
185 deepCopy(existingSingleAttr);
186 }
187
188 // Deep Copy Assignment Operator
189 //
190 SingleAttributes& operator=(
191 const SingleAttributes& existingSingleAttr)
192 {
193 return deepCopy(existingSingleAttr);
194 }
195
196 bool SecondaryAuthEntry;
197 tstring SSOURL;
198 tstring SSOFinalURL;
199 tstring SSOTokenCookieName;
200 tstring SSOErrorCookieName;
201 unsigned int SSOTimeoutSeconds;
202 tstring SSOUserAgent;
203 bool SSOIsExternalBrowser;
204 std::unordered_set<tstring> SSOClientCertReqIgnoredFqdns;
205
206 private:
207 SingleAttributes& deepCopy(const SingleAttributes& existingSingleAttr)
208 {
209 if (std::addressof(existingSingleAttr) != this)
210 {
211 SecondaryAuthEntry = existingSingleAttr.SecondaryAuthEntry;
212 SSOURL = existingSingleAttr.SSOURL.c_str();
213 SSOFinalURL = existingSingleAttr.SSOFinalURL.c_str();
214 SSOTokenCookieName = existingSingleAttr.SSOTokenCookieName.c_str();
215 SSOErrorCookieName = existingSingleAttr.SSOErrorCookieName.c_str();
216 SSOTimeoutSeconds = existingSingleAttr.SSOTimeoutSeconds;
217 SSOUserAgent = existingSingleAttr.SSOUserAgent.c_str();
218 SSOIsExternalBrowser = existingSingleAttr.SSOIsExternalBrowser;
219 for (const auto& fqdn : existingSingleAttr.SSOClientCertReqIgnoredFqdns)
220 {
221 SSOClientCertReqIgnoredFqdns.insert(fqdn.c_str());
222 }
223 }
224 return *this;
225 }
226 };
227
228 typedef std::map<tstring, GroupAttributes> GroupAttributesMap;
229
230 const GroupAttributes& getGroupAttributes(const tstring& group) const;
231 void setGroupAttributesMap(const GroupAttributesMap& groupAttributesMap);
232
233 const SingleAttributes& getSingleAttributes() const;
234 void setSingleAttributes(const SingleAttributes& singleAttributes);
235
236 private:
237
238 void copyGroupAttributesMap (const GroupAttributesMap &srcMap,
239 GroupAttributesMap &dstMap);
240
241 static const GroupAttributes DefaultGroupAttributes;
242 GroupAttributesMap m_GroupAttributesMap;
243 SingleAttributes m_SingleAttributes;
244};
245
246
247#endif // _PROMPTENTRYBASE_
api.h
PromptType
PromptType
Definition api.h:258
Prompt_Input
@ Prompt_Input
Definition api.h:258
tstring
#define tstring
Definition api.h:35
PromptEntryBase::GroupAttributes
Definition PromptEntryBase.h:118
PromptEntryBase::SingleAttributes
Definition PromptEntryBase.h:171