| AnyConnect Secure Mobility Client 5.1.8.122

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# include/PromptEntryBase.h

    00001 /**************************************************************************
    00002 *   Copyright (c) 2008, 2022-2024 Cisco Systems, Inc.
    00003 *   All Rights Reserved. Cisco Highly Confidential.
    00004 ***************************************************************************
    00005 *
    00006 *   File:   PromptEntryBase.h
    00007 *   Date:   01/2008
    00008 *
    00009 ***************************************************************************
    00010 *   Prompt Entry base class implementation for the Client API.
    00011 ***************************************************************************/
    00012
    00013 #ifndef _PROMPTENTRYBASE_
    00014 #define _PROMPTENTRYBASE_
    00015
    00016
    00017 #include "api.h"
    00018 #include <list>
    00019 #include <unordered_set>
    00020
    00021
    00022 #define PROMPT_ENTRY_VALUE_TRUE  _T("true")
    00023 #define PROMPT_ENTRY_VALUE_FALSE  _T("false")
    00024
    00025 class VPN_VPNAPI PromptEntryBase
    00026 {
    00027 public:
    00028
    00029     bool setValue(const tstring& value);
    00030     bool clearValue();
    00031
    00032     const tstring &getPromptName() const;
    00033
    00034     const tstring &getPromptLabel() const;
    00035
    00036     bool isEnabled() const;
    00037
    00038     void setEnabled(bool bIsEnabled);
    00039
    00040     bool isVisible() const;
    00041
    00042     void setVisible(bool bIsVisible);
    00043
    00044     // if this is a PromptEntry that has a list of values
    00045     // (e.g. combo box style) the default will be to mark it as a group
    00046     // combo.  This method allows the group designation to be set directly.
    00047     //
    00048     void setEntryGroup(bool bIsEntryGroup);
    00049
    00050
    00051     PromptEntryBase(tstring PromptName,
    00052                     tstring PromptLabel,
    00053                     PromptType promptType = Prompt_Input,
    00054                     const tstring& DefaultValue = EmptyString,
    00055                     ApiStringMap LabelValues = EmptyLabelValues);
    00056
    00057
    00058     void setPromptLabel(tstring label);
    00059
    00060     // In cases of prompt types with options (checkbox, combobox),
    00061     // this will return the translated label (of the option).
    00062     const tstring &getValue() const;
    00063
    00064     // this function returns the internal representation of the value
    00065     const tstring &getTrueValue() const;
    00066
    00067     const std::list<tstring> &getValueOptions() const;
    00068
    00069     bool isEntryGroup() const;
    00070
    00071     bool isReadOnly() const;
    00072
    00073     PromptType getPromptType() const;
    00074
    00075     size_t GetGroupAttributesCount();
    00076
    00077
    00078     virtual ~PromptEntryBase();
    00079
    00080     static const tstring EmptyString;
    00081
    00082     static const std::list<tstring> EmptyList;
    00083
    00084     static const ApiStringMap EmptyLabelValues;
    00085
    00086     // Deep Copy Assignment Operator
    00087     //
    00088     PromptEntryBase& operator=(const PromptEntryBase& existingEntry)
    00089     {
    00090         return deepCopy(existingEntry);
    00091     }
    00092
    00093     // Deep Copy Constructor
    00094     //
    00095     explicit PromptEntryBase(const PromptEntryBase& existingEntry)
    00096     {
    00097         deepCopy(existingEntry);
    00098     }
    00099
    00100
    00101 private:
    00102
    00103     PromptEntryBase& deepCopy(const PromptEntryBase& existingEntry);
    00104
    00105     tstring ms_PromptName;
    00106     tstring ms_PromptLabel;
    00107     PromptType me_PromptType;
    00108     tstring ms_Value;
    00109     ApiStringMap msm_LabelValueMap;
    00110     std::list<tstring> mls_ValueOptions;
    00111     bool mb_IsEntryGroup;
    00112     bool mb_Enabled;
    00113     bool mb_Visible;
    00114
    00115 public:
    00116
    00117     class GroupAttributes
    00118     {
    00119     public:
    00120         GroupAttributes() :
    00121             CredRequired(true),
    00122             UsesSDIAuth(false),
    00123             UsernameEditable(true),
    00124             SecondaryUsernameEditable(true),
    00125             UsesSecondaryAuth(false)
    00126         {
    00127         }
    00128
    00129         // Deep Copy Constructor
    00130         //
    00131         explicit GroupAttributes(
    00132             const GroupAttributes& existingGroupAttr)
    00133         {
    00134             deepCopy(existingGroupAttr);
    00135         }
    00136
    00137         // Deep Copy Assignment Operator
    00138         //
    00139         GroupAttributes& operator=(
    00140             const GroupAttributes& existingGroupAttr)
    00141         {
    00142             return deepCopy(existingGroupAttr);
    00143         }
    00144
    00145         bool CredRequired;
    00146         bool UsesSDIAuth;
    00147         bool UsernameEditable;
    00148         tstring Username;
    00149         bool SecondaryUsernameEditable;
    00150         tstring SecondaryUsername;
    00151         bool UsesSecondaryAuth;
    00152
    00153     private:
    00154         GroupAttributes& deepCopy(const GroupAttributes& existingGroupAttr)
    00155         {
    00156             if (std::addressof(existingGroupAttr) != this)
    00157             {
    00158                 CredRequired = existingGroupAttr.CredRequired;
    00159                 UsesSDIAuth = existingGroupAttr.UsesSDIAuth;
    00160                 UsernameEditable = existingGroupAttr.UsernameEditable;
    00161                 Username = existingGroupAttr.Username.c_str();
    00162                 SecondaryUsernameEditable = existingGroupAttr.SecondaryUsernameEditable;
    00163                 SecondaryUsername = existingGroupAttr.SecondaryUsername.c_str();
    00164                 UsesSecondaryAuth = existingGroupAttr.UsesSecondaryAuth;
    00165             }
    00166             return *this;
    00167         }
    00168     };
    00169
    00170     class SingleAttributes
    00171     {
    00172     public:
    00173         SingleAttributes() :
    00174             SecondaryAuthEntry(false),
    00175             SSOTimeoutSeconds(0),
    00176             SSOIsExternalBrowser(false)
    00177         {
    00178         }
    00179
    00180         // Deep Copy Constructor
    00181         //
    00182         explicit SingleAttributes(
    00183             const SingleAttributes& existingSingleAttr)
    00184         {
    00185             deepCopy(existingSingleAttr);
    00186         }
    00187
    00188         // Deep Copy Assignment Operator
    00189         //
    00190         SingleAttributes& operator=(
    00191             const SingleAttributes& existingSingleAttr)
    00192         {
    00193             return deepCopy(existingSingleAttr);
    00194         }
    00195
    00196         bool SecondaryAuthEntry;
    00197         tstring SSOURL;
    00198         tstring SSOFinalURL;
    00199         tstring SSOTokenCookieName;
    00200         tstring SSOErrorCookieName;
    00201         unsigned int SSOTimeoutSeconds;
    00202         tstring SSOUserAgent;
    00203         bool SSOIsExternalBrowser;
    00204         std::unordered_set<tstring> SSOClientCertReqIgnoredFqdns;
    00205
    00206     private:
    00207         SingleAttributes& deepCopy(const SingleAttributes& existingSingleAttr)
    00208         {
    00209             if (std::addressof(existingSingleAttr) != this)
    00210             {
    00211                 SecondaryAuthEntry = existingSingleAttr.SecondaryAuthEntry;
    00212                 SSOURL = existingSingleAttr.SSOURL.c_str();
    00213                 SSOFinalURL = existingSingleAttr.SSOFinalURL.c_str();
    00214                 SSOTokenCookieName = existingSingleAttr.SSOTokenCookieName.c_str();
    00215                 SSOErrorCookieName = existingSingleAttr.SSOErrorCookieName.c_str();
    00216                 SSOTimeoutSeconds = existingSingleAttr.SSOTimeoutSeconds;
    00217                 SSOUserAgent = existingSingleAttr.SSOUserAgent.c_str();
    00218                 SSOIsExternalBrowser = existingSingleAttr.SSOIsExternalBrowser;
    00219                 for (const auto& fqdn : existingSingleAttr.SSOClientCertReqIgnoredFqdns)
    00220                 {
    00221                     SSOClientCertReqIgnoredFqdns.insert(fqdn.c_str());
    00222                 }
    00223             }
    00224             return *this;
    00225         }
    00226     };
    00227
    00228     typedef std::map<tstring, GroupAttributes> GroupAttributesMap;
    00229
    00230     const GroupAttributes& getGroupAttributes(const tstring& group) const;
    00231     void setGroupAttributesMap(const GroupAttributesMap& groupAttributesMap);
    00232
    00233     const SingleAttributes& getSingleAttributes() const;
    00234     void setSingleAttributes(const SingleAttributes& singleAttributes);
    00235
    00236 private:
    00237
    00238     void copyGroupAttributesMap (const GroupAttributesMap &srcMap,
    00239                                  GroupAttributesMap &dstMap);
    00240
    00241     static const GroupAttributes DefaultGroupAttributes;
    00242     GroupAttributesMap m_GroupAttributesMap;
    00243     SingleAttributes m_SingleAttributes;
    00244 };
    00245
    00246
    00247 #endif // _PROMPTENTRYBASE_