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