AnyConnect Secure Mobility Client  5.0.00556
ClientIfcBase.h
1 /**************************************************************************
2 * Copyright (c) 2006, 2021 Cisco Systems, Inc.
3 * All Rights Reserved. Cisco Highly Confidential.
4 ***************************************************************************
5 *
6 * File: ClientIfcBase.h
7 * Author: Chris Fitzgerald
8 * Date: 08/2007
9 *
10 ***************************************************************************
11 * Client Interface Base class implementation for the Client API.
12 ***************************************************************************/
13 
14 // The ClientIfcBase class contains the majority of private methods and members.
15 // The purpose of this class is to hide all but the necessary methods from
16 // being exposed.
17 //
18 
19 #ifndef _CLIENTIFCBASE_
20 #define _CLIENTIFCBASE_
21 
22 #include <list>
23 #include <vector>
24 #include <memory>
25 
26 
27 /*
28  * SCRIPTING_SUPPORTED, INTERPROCESS_COMMUNICATION_SUPPORTED macro is a copy of corresponding
29  * #define from GenDefs.h. Any change in #define for the macro in GenDefs.h must propogated to
30  * this header file too. We duplicate this definition here due to the manner in which we distribute
31  * our code to partners; we cannot include GenDefs.h from here.
32  */
33 #if !defined(PLATFORM_APPLE_SSLVPN) && !defined(PLATFORM_ANDROID) && !defined(PLATFORM_WIN_APP)
34 #define SCRIPTING_SUPPORTED
35 #endif
36 #if !defined(PLATFORM_WIN_APP)
37 #define INTERPROCESS_COMMUNICATION_SUPPORTED
38 #endif
39 
40 /*
41  * SCEP_CERTIFICATE_ENROLLMENT_SUPPORTED macro is a copy of corresponding #define from GenDefs.h.
42  * Any change in #define for the macro in GenDefs.h must propogated to this header file too. We
43  * duplicate this definition here due to the manner in which we distribute our code to partners;
44  * we cannot include GenDefs.h from here.
45  */
46 #if defined(_WIN32) || defined(_WIN32_WCE) || defined(PLATFORM_DARWIN) || defined(PLATFORM_LINUX) || defined(PLATFORM_ANDROID) || defined(PLATFORM_APPLE_SSLVPN)
47 #define SCEP_CERTIFICATE_ENROLLMENT_SUPPORTED
48 #endif
49 
50 /*
51  * HOST_DATA_SUPPORTED macro is a copy of corresponding #define from GenDefs.h. Any change
52  * in #define for the macro in GenDefs.h must propogated to this header file too. We duplicate
53  * this definition here due to the manner in which we distribute our code to partners;
54  * we cannot include GenDefs.h from here.
55  */
56 #if defined(PLATFORM_ANDROID) || defined(PLATFORM_APPLE_SSLVPN) || defined(PLATFORM_CHROMEBOOK)
57 #define HOST_DATA_SUPPORTED
58 #endif
59 
60 /*
61  * MANUAL_PKCS12_IMPORT_SUPPORTED macro is a copy of corresponding #define from GenDefs.h.
62  * Any change in #define for the macro in GenDefs.h must propogated to this header file too.
63  * We duplicate this definition here due to the manner in which we distribute our
64  * code to partners; we cannot include GenDefs.h from here.
65  */
66 #if defined(PLATFORM_APPLE_SSLVPN) || defined(PLATFORM_ANDROID) || defined(PRODUCT_TYPE_SSA)
67 #define MANUAL_PKCS12_IMPORT_SUPPORTED
68 #endif
69 
70 /*
71  * PROGRAM_DATA_IMPORT_SUPPORTED macro is a copy of corresponding #define from GenDefs.h.
72  * Any change in #define for the macro in GenDefs.h must propogated to this header file too.
73  * We duplicate this definition here due to the manner in which we distribute our
74  * code to partners; we cannot include GenDefs.h from here.
75  */
76 #if defined(PLATFORM_ANDROID)
77 #define PROGRAM_DATA_IMPORT_SUPPORTED
78 #endif
79 
80 /*
81  * CREDENTIAL_PREFILL_SUPPORTED macro is a copy of corresponding #define from GenDefs.h.
82  * Any change in #define for the macro in GenDefs.h must propogated to this header file too.
83  * We duplicate this definition here due to the manner in which we distribute our
84  * code to partners; we cannot include GenDefs.h from here.
85  */
86 #if defined(PLATFORM_ANDROID)
87 #define CREDENTIAL_PREFILL_SUPPORTED
88 #endif
89 
90 #if defined(MANUAL_PKCS12_IMPORT_SUPPORTED) && !defined(__GENDEFS_H)
91 #if defined(HAVE_STDINT_H)
92 #include <stdint.h>
93 #else
94 typedef unsigned char uint8_t;
95 #endif // HAVE_STDINT_H
96 #endif // MANUAL_PKCS12_IMPORT_SUPPORTED
97 
98 #include "api.h"
99 #include "PreferenceUpdate.h"
100 
101 #if defined(PLATFORM_WIN_APP)
102 typedef unsigned char uint8_t;
103 #endif
104 
105 #if defined(HOST_DATA_SUPPORTED)
106 #include "IHostData.h"
107 #endif
108 
109 #if defined(ANYCONNECT_USE_SNAK)
110 #include "Utility/PluginLoader.h"
111 #include "SNAK_CertPlugin.h"
112 #include "SNAK_SocketPlugin.h"
113 #include "SNAK_StoragePlugin.h"
114 #endif
115 
116 class ConnectPromptInfo;
117 class ConnectMgr;
118 class MsgWithArg;
119 class VPNStats;
120 class AgentIfc;
121 class ProfileMgr;
122 class ApiThread;
123 class EventMgr;
124 class PreferenceMgr;
125 class PreferenceInfo;
126 class UserPreferences;
127 class CScriptingMgr;
128 class CManualLock;
129 class ProxyIfc;
130 class CIpcMessage;
131 class SCEPIfc;
132 class CertObj;
133 class CExecutionContext;
134 class HostEntry;
135 class CAppLog;
136 
137 #if defined(CREDENTIAL_PREFILL_SUPPORTED)
138 class CredentialPrefill;
139 #endif
140 
141 #if !defined(PLATFORM_APPLE_SSLVPN)
142 class CStoragePath;
143 #endif
144 
145 #ifdef ANYCONNECT_USE_SNAK
146 class PluginLoader;
147 class SNAK_StoragePlugin;
148 class SNAK_CertPlugin;
149 class SNAK_SocketPlugin;
150 class SNAK_DeviceInfoPlugin;
151 class SNAKDeviceInfoPluginCBImpl;
152 #endif // ANYCONNECT_USE_SNAK
153 
154 #if defined(ANYCONNECT_USE_SNAK) || defined(PLATFORM_APPLE_SSLVPN)
155 class ManagedCertificate;
156 class ManagedCertHandle;
157 #endif // ANYCONNECT_USE_SNAK || PLATFORM_APPLE_SSLVPN
158 
159 #if defined(PROGRAM_DATA_IMPORT_SUPPORTED)
160 class IACImporterAsync;
161 class IACImporterAsyncCB;
162 #endif
163 
164 class VPN_VPNAPI ClientIfcBase : private IPreferenceUpdateCB
165 {
166  friend class EventMgr;
167 
168  protected:
169 
170  /**
171  * Callback used to deliver new statistics related to the VPN
172  * connection.
173  *
174  * When a connection is active, a new set of statistics is
175  * delivered each second.
176  *
177  * @see resetStats(), stopStats() and startStats()
178  *
179  */
180  virtual void StatsCB(VPNStats &stats) = 0;
181 
182 
183  /**
184  * Callback used to deliver VPN state and state change string.
185  * The stateString delivered by this method is localized.
186  *
187  * See the ::VPNState enum found in api.h for set of valid states.
188  */
189  virtual void StateCB(const VPNState state,
190  const VPNSubState subState,
191  const tstring stateString) = 0;
192 
193 
194  /**
195  * If a banner needs to be acknowledged, this CB delivers the banner
196  * to the client.
197  *
198  * NOTE: Connection establishment will block until the method
199  * setBannerResponse() is called.
200  *
201  * In a GUI, a banner would typically be displayed in a modal dialog
202  * with an accept or decline button selection.
203  *
204  * @see setBannerResponse() to set the user response to the banner.
205  */
206  virtual void BannerCB(const tstring &banner) = 0;
207 
208  /**
209  * If a pre-connect reminder needs to be acknowledged, this CB delivers
210  * the pre-connect reminder to the client.
211  *
212  * NOTE: Connection establishment will block until the method
213  * setPreConnectReminderResponse() is called.
214  *
215  * In a GUI, a pre-connect reminder would typically be displayed in a modal
216  * dialog with an OK button selection.
217  *
218  * @see setPreConnectReminderResponse() to set the user acknowledgement to
219  * the pre-connect reminder message.
220  */
221  virtual void PreConnectReminderCB(const tstring &rtstrPreConnectReminder);
222 
223  /**
224  * Messages are delivered via the NoticeCB and can come from multiple
225  * sources. There are four message types (error, warning, info and
226  * status). See the ::MessageType enum in api.h for the list.
227  *
228  * Clients using the API as an embedded application (not
229  * user visible) might want to further characterize
230  * messages. One option here is to use the AnyConnect message
231  * catalog and assign message codes as the translations for
232  * various messages. An application could then track messages based
233  * on its own error code scheme.
234  */
235  virtual void NoticeCB(const tstring &notice,
236  const MessageType type,
237  const bool bSensitive = false) = 0;
238 
239 #if defined(PLATFORM_APPLE_SSLVPN) || defined(PLATFORM_ANDROID) || defined(PLATFORM_CHROMEBOOK)
240  virtual void CertBannerCB(const tstring &certBannerSummary,
241  const uint32_t nCertBannerCertLen,
242  const uint8_t *pCertBannerCertDer,
243  const std::list<tstring> &confirmReasons,
244  const std::list<CertConfirmReason> &confirmReasonEnums,
245  bool bImportAllowed = true) = 0;
246 #endif
247 
248  /**
249  * This CB would likely occur only during a connection when it was
250  * detected that the software needed to be upgraded, or when Start
251  * Before Logon (SBL) is being used.
252  *
253  * Unlike the other callback methods, this method provides a default
254  * implementation (calling the system's exit() function).
255  * If clients of the API wish to override this behavior, they are
256  * responsible for ensuring that the current running process exits with
257  * the return code specified by returnCode.
258  *
259  * <b>Caution</b>: IF YOU OVERRIDE THIS METHOD AND DO NOT EXIT WITH
260  * THE PROPER CODE SOFTWARE UPDATE FUNCTIONALITY IN YOUR CLIENT WILL
261  * BREAK
262  */
263  virtual void ExitNoticeCB(const tstring &tstrNotice,
264  const int returnCode);
265 
266 
267  /**
268  * Under normal operating conditions, this CB is called as soon
269  * as the attach method completes. In case the service (vpn agent)
270  * is not ready, this CB is not called until it is.
271  *
272  * Any API calls made prior to this CB being called will result in a
273  * NoticeCB error message.
274  */
275  virtual void ServiceReadyCB() = 0;
276 
277 
278 
279  /**
280  * This method supports prompting for single or multiple values. All
281  * prompts are considered mandatory.
282  *
283  * The ConnectPromptInfo object contains a list of PromptEntry
284  * instances. The labels and their default values (if any) can be
285  * found in these instances. After the data has been collected from the user
286  * it can be set into these same instances. When ready, the client
287  * application should call the method UserSubmit() to have the
288  * responses read by the API.
289  */
290  virtual void UserPromptCB(ConnectPromptInfo &ConnectPrompt) = 0;
291 
292 
293  /**
294  * Use this method to provide Window Manager hints to GUI
295  * applications. To receive these hints, the application must
296  * identify itself as a GUI in the attach method. In addition, this
297  * method should be overriden to receive any generated events.
298  *
299  * Event that can be received include those indicating that a user is
300  * starting a second instance of the GUI application. This information
301  * can be used to tell the already running application to un-minimize
302  * itself and let the new program know that it should Quit (since a GUI
303  * is already running).
304  */
305  virtual void WMHintCB(const WMHint hint,
306  const WMHintReason reason);
307 
308 
309  /**
310  * This method is useful when the connection to the secure gateway
311  * has been established as part of a web-launch of the VPN tunnel.
312  *
313  * If the client application wishes to be notified of the secure
314  * gateway to which the VPN has been established, this method should
315  * be overriden.
316  *
317  * If the client application is started and a tunnel is already active,
318  * this method also delivers the name of the secure gateway host.
319  */
320  virtual void deliverWebLaunchHostCB(const tstring &activeHost);
321 
322  /**
323  * This method is called when the preference to block untrusted
324  * servers is enabled and the current VPN server being connected
325  * to is untrusted. Clients should present an error to the user
326  * notifying them that the current connection to rtstrUntrustedServer
327  * is being blocked. The client should also provide a way for the
328  * user to change the preference to block untrusted servers.
329  *
330  * The user response must be indicated using setCertBlockedResponse
331  */
332  virtual void CertBlockedCB(const tstring &rtstrUntrustedServer) = 0;
333 
334  /**
335  * This method is called when connections to untrusted VPN servers
336  * is allowed by policies and the current VPN server being connected
337  * to is untrusted. Clients should present a warning to the user
338  * notifying them that the current connection to rtstrUntrustedServer
339  * is unsafe. The reason the VPN server is untrusted is provided in
340  * rltstrCertErrors. The client should provide a way for the user to
341  * connect once, connect and always trust or cancel the connection.
342  * If bAllowImport is set to false then the always trust option should
343  * not be presented to users.
344  *
345  * The user response must be indicated using setCertWarningResponse
346  */
347  virtual void CertWarningCB(const tstring &rtstrUntrustedServer,
348  const std::list<tstring> &rltstrCertErrors,
349  bool bAllowImport) = 0;
350 
351 #if defined(PLATFORM_WIN_APP)
352  /**
353  * Same as above but also passes the Server certificate DER for details display
354  */
355  virtual void CertWarningCB(const tstring &rtstrUntrustedServer,
356  const std::list<tstring> &rltstrCertErrors,
357  const std::vector<uint8_t> &rvServerCertDER,
358  bool bAllowImport) = 0;
359 #endif
360 
361  /**
362  * This method can be overriden if the client application wishes to
363  * exercise some control over the delivery of events from the other
364  * protected methods in this class.
365  *
366  * This might be necessary in cases where a GUI is being written and
367  * the data from this API needs to be delivered in the GUI or main
368  * thread. In this case, you should override this method and when it
369  * is called by the API post an event to your event queue (message
370  * pump, etc.). After this event executes in your GUI or main thread,
371  * call the method ClientIfc::ProcessEvents to have events delivered
372  * to your client application.
373  */
374  virtual void EventAvailable();
375 
376 #ifdef MANUAL_PKCS12_IMPORT_SUPPORTED
377  virtual void ImportPKCS12ResultCB(const std::vector<uint8_t> &certHash, const tstring &tstrError);
378 #endif
379 #ifdef PLATFORM_ANDROID
380  virtual void ClientCertificateCB(std::vector< std::pair<uint32_t, uint8_t*> > certList) = 0;
381  virtual void AgentDetachedCB();
382 #endif
383 
384  AgentIfc &getAgentIfc();
385 
386  ClientIfcBase();
387 
388 
389  public:
390 
391  virtual bool attach(ClientType clientType = ClientType_GUI,
392  bool requestFullCapabilities = true,
393  bool suppressAutoConnect = true);
394 
395  virtual void detach();
396 
397  virtual void ProcessEvents();
398 
399  virtual bool hasFullCapabilities();
400 
401  virtual bool isConnected();
402 
403  virtual bool isAvailable();
404 
405  virtual std::list<tstring> getHostNames();
406 
407  virtual std::list<HostEntry> getHostEntries();
408 
409  virtual tstring getDefaultHostName();
410 
411 #if defined(HOST_DATA_SUPPORTED)
412  virtual bool connect(const IHostData& hostData);
413 
414  bool connect(const IHostData& hostData,
415  unsigned int origin);
416 #else
417  virtual bool connect(tstring host);
418 
419  bool connect(tstring host,
420  unsigned int origin);
421 #endif
422 
423  virtual bool setNewTunnelGroup(const tstring & group);
424 
425  virtual void disconnect();
426 
427  virtual void cancel();
428 
429  virtual void resetStats();
430 
431  virtual void getState();
432 
433  VPNState getCurrentState();
434  VPNSubState getCurrentSubState();
435  VPNSubState getPreviousSubState();
436 
437  tstring getStateText();
438  static tstring getNoticeTypeText(MessageType msgType);
439 
440  static tstring getStateText(VPNState state,
441  VPNSubState subState = VPNSS_NORMAL,
442  NETENV_STATE netEnvState = NES_NETWORK_ACCESSIBLE,
443  const tstring& tstrConnectedHost = tstring());
444 
445  void setNetworkStates(NETENV_STATE netEnvState,
446  NETCTRL_STATE netCtrlState,
447  NETWORK_TYPE netType,
448  bool bACBrowserForCPRemediation,
449  bool bUpdateUI);
450  void refreshOperatingModeForCurrentNetStates();
451  NETENV_STATE getCurrentNetEnvState();
452  NETENV_STATE getPreviousNetEnvState();
453  NETCTRL_STATE getCurrentNetCtrlState();
454  NETWORK_TYPE getCurrentNetType();
455  bool isACBrowserForCPRemediation();
456 
457  static tstring getNetCtrlText(NETCTRL_STATE netCtrlState);
458  static tstring getNetEnvText(NETENV_STATE netEnvState,
459  bool bSimple = false);
460  static tstring getNetTypeText(NETWORK_TYPE netType);
461  static tstring getQuarantinedStatusText();
462  static tstring getNetworkStatusSimpleText(const NETENV_STATE netEnvState,
463  const NETCTRL_STATE netCtrlState);
464 
465  // can't be static due to requiring operating mode information
466  tstring getNetworkStatusText(const VPNState state,
467  const VPNSubState subState,
468  const NETENV_STATE netEnvState,
469  const NETCTRL_STATE netCtrlState);
470 
471  PreferenceInfo &getPreferences();
472 
473  bool savePreferences();
474 
475  virtual void startStats();
476 
477  virtual void stopStats();
478 
479  virtual void UserSubmit();
480 
481  void setBanner(const tstring &banner);
482  void setBannerResponse(bool bResponse);
483 
484  void setPreConnectReminder(const tstring &tstrPreConnectReminder);
485  void setPreConnectReminderResponse();
486 
487  bool getUserResponse();
488  bool isUserResponseSet();
489 
490  void setCertBlocked(const tstring &tstrUntrustedServer);
491  void setCertWarning(const tstring &rtstrUntrustedServer,
492  const std::list<tstring> &rltstrCertErrors,
493  bool bAllowImport);
494 #if defined(PLATFORM_WIN_APP)
495  void setCertWarning(const tstring &rtstrUntrustedServer,
496  const std::list<tstring> &rltstrCertErrors,
497  const std::vector<uint8_t>& rvServerCertDER,
498  bool bAllowImport);
499 #endif
500  bool getCertImportResponse();
501 
502 #if defined(PLATFORM_APPLE_SSLVPN) || defined(PLATFORM_ANDROID) || defined(PLATFORM_CHROMEBOOK)
503  void setCertBanner(tstring tstrCertBannerSummary,
504  uint32_t nCertBannerCertLen,
505  const uint8_t *pCertBannerCertDer,
506  const std::list<tstring> &confirmReasons,
507  const std::list<CertConfirmReason> &confirmReasonEnums,
508  bool bImportAllowed);
509 
510  void setCertBannerResponse(bool bResponse, bool bImportCert);
511  void importServerCert(std::vector<uint8_t> certData);
512  bool setFipsMode(bool bEnableFips);
513 #if defined(PLATFORM_ANDROID)
514  bool setStrictMode(bool bEnableStrictMode);
515  bool setRevocationEnabled(bool bRevocationEnabled);
516  bool IsRevocationEnabled();
517 #endif // currently supported only for android
518 #endif
519 
520  void setUserPrompt(ConnectPromptInfo &ConnectPrompt);
521 
522 #ifdef PLATFORM_ANDROID
523  void setClientCertResponse(std::vector< std::pair<uint32_t, uint8_t*> > &derList);
524  void setAgentDetached();
525  bool getClientCertificates();
526 #endif
527 
528 #if defined(PLATFORM_APPLE_SSLVPN) || defined(PLATFORM_ANDROID)
529  void setSCEPEnrollInProgress(bool bInProgress);
530  bool isSCEPEnrollInProgress();
531 #endif // PLATFORM_APPLE_SSLVPN || PLATFORM_ANDROID
532 
533 #ifdef MANUAL_PKCS12_IMPORT_SUPPORTED
534  void setImportPKCS12Result(const std::vector<uint8_t> &certHash, const tstring &tstrError);
535  bool requestImportPKCS12(const std::vector<uint8_t> &data);
536  std::vector<uint8_t> importPKCS12WithPassword(const std::vector<uint8_t> &data, const tstring &password);
537 #endif
538 
539  void setCertBlockedResponse(bool bUnlock);
540  void setCertWarningResponse(bool bConnect, bool bImportCert);
541 
542  void insertStateToConnectPrompt(ConnectPromptInfo &ConnectPrompt);
543 
544  void ExitNotice(const tstring &tstrNotice, const int code = 0);
545 
546  void notice(const tstring &tstrNotice,
547  const MessageType type = MsgType_Info,
548  bool bClearLastMsg = false,
549  bool bForce = false,
550  bool bStateMsg = false,
551  bool bSensitiveMsg = false);
552 
553  void notice(MsgWithArg &notice,
554  const MessageType type = MsgType_Info,
555  bool bClearLastMsg = false,
556  bool bForce = false,
557  bool bStateMsg = false,
558  bool bSensitiveMsg = false);
559 
560  void getStats(void);
561 
562  void setStats(VPNStats &stats);
563 
564  void exportStats(const tstring &tstrFilePath);
565 
566  void setState(VPNState state,
567  VPNState previousState,
568  VPNSubState subState = VPNSS_NORMAL,
569  bool bUpdateStateMsg = true,
570  bool bOnlyUpdateUI = false);
571 
572 #ifdef PROGRAM_DATA_IMPORT_SUPPORTED
573  IACImporterAsync *createACImporter(IACImporterAsyncCB *pCallback);
574 #endif
575 
576  void setWMHint(WMHint hint,
577  WMHintReason reason);
578 
579  bool isLastConnectType (const ConnectPromptType connPromptType);
580 
581  bool isOperatingMode(OperatingMode opMode);
582  void setOperatingMode(OperatingMode opMode);
583  void unsetOperatingMode(OperatingMode opMode);
584 
585  bool CanRemediateCaptivePortal();
586  bool policyAllowsCaptivePortalRemediation();
587 
588  bool isEventShutdown();
589 
590  bool isUsingEventModel();
591 
592  time_t getLastDisconnectTime();
593 
594  ConnectPromptInfo getConnectPromptInfo();
595  void resetConnectPromptPasswordData();
596 
597  void setStandaloneConnection(bool isStandalone);
598 
599  void deliverActiveHost(const tstring &activeHost,
600  ConnectProtocolType vpnProtocol = PROTOCOL_TYPE_UNKNOWN,
601  bool bActiveHostFriendlyName = false);
602 
603  bool isVPNServiceReady();
604 
605  // reset last disconnect time indicator.
606  //
607  void resetLastDisconnectTime(time_t time = 1);
608 
609  void processMinimize();
610 
611  // cert enrollment
612  void setEnrollClientCert(CertObj* pCert);
613 
614  // Show user banner for cert import warning on linux
615  // SCEPIfc to ConnectMgr
616  void linuxCertImportWarnUser();
617 
618  // Response to cert warning on linux
619  // ConnectMgr to SCEPIfc
620  void linuxCertImportWarnUserResponse(bool bAccept);
621 
622  void setDefaultHost(tstring &host);
623 
624 #if defined(HOST_DATA_SUPPORTED)
625  void setDefaultHostProfile(const IHostData &hostProfile);
626  IHostData* getDefaultHostData();
627 #endif // HOST_DATA_SUPPORTED
628 
629  void setLastVpnError(VPNError vpnError);
630  VPNError getLastVpnError();
631 
632 #ifdef PLATFORM_ANDROID
633  bool requestClientCertificates();
634 #endif
635 
636  bool requestImportLocalization(const tstring tstrLocale,
637  const std::vector<unsigned char> &MoFileData);
638 
639  // Start the Automatic Headend Selection operation
640  void startAHS(const unsigned int uiReason,
641  const ProxyIfc& proxy);
642  // statusReturnCode is a long to match the current type of STATUSCODE.
643  // It is not using a STATUSCODE directly so that we do not have to
644  // expose the header files for STATUSCODEs to ClientIfcBase.h
645  void AHSSelectedHost(const unsigned int uiReason,
646  const std::vector<tstring> &headendList,
647  const long statusReturnCode,
648  const tstring& extraInfo);
649  std::vector<tstring> getAHSHostList();
650  unsigned int getAHSState();
651  bool isAHSHasRun();
652 
653  bool suppressConnectionErrorPopups();
654 
655  tstring getCaptivePortalDetectedMsg();
656 
657  void setProxyAuthPrompts(ProxyIfc* pProxy,
658  const tstring& promptMsg);
659 
660 #if defined(INTERPROCESS_COMMUNICATION_SUPPORTED)
661  bool handleIpcMessage(CIpcMessage *pIpcMessage);
662 #endif
663  bool IsCsdTokenVerified() const;
664 
665 #if defined(PLATFORM_APPLE_SSLVPN) || defined(PLATFORM_ANDROID)
666  virtual void SCEPEnrollStartCB();
667  virtual void SCEPEnrollExitCB();
668 #endif // PLATFORM_APPLE_SSLVPN || PLATFORM_ANDROID
669 
670  void activateConnectMgrTunnelInitiationCompletionEvent();
671  bool isConnectRequestActive();
672 #if defined(PLATFORM_ANDROID) || defined(PLATFORM_CHROMEBOOK)
673  bool deleteProfileByName(const tstring &profileName);
674  tstring getProfileContents(const tstring &profileName);
675  bool importProfile(const tstring &profileName, const tstring &profileContents);
676 #endif // PLATFORM_ANDROID || PLATFORM_CHROMEBOOK
677 
678  bool syncProfileChange(const tstring &profileName);
679 
680 #if defined(CREDENTIAL_PREFILL_SUPPORTED)
681  bool hasPrefilledCredentials();
682  bool prefillCredentials(ConnectPromptInfo &connectPrompt);
683  void setPrefilledCredentials(CredentialPrefill *prefill);
684 #endif
685 
686 #if defined(PLATFORM_ANDROID) || defined(PLATFORM_APPLE_SSLVPN)
687  std::list<ManagedCertificate *> enumerateCertificates(CertificateType certType);
688  bool deleteCertificates(CertificateType certType, const std::list<std::string> &idList);
689  bool deleteServerCertificates(const std::list<std::string> &idList);
690 #endif // ANYCONNECT_USE_SNAK || PLATFORM_APPLE_SSLVPN
691 
692 #if defined(ANYCONNECT_USE_SNAK)
693  std::list<ManagedCertificate *> enumerateSNAKCertificates(SNAK_CertType certType);
694  SNAK_CertType getSNAKCertType(CertificateType certType);
695  bool deleteClientCertificates(const std::list<std::string> &idList);
696 #endif // ANYCONNECT_USE_SNAK
697 
698 #if defined(PLATFORM_APPLE_SSLVPN)
699  bool canUseBackupServers();
700 
701 #endif //PLATFORM_APPLE_SSLVPN
702 
703  virtual ~ClientIfcBase();
704 
705  tstring getConnectHost();
706 
707  tstring getMgmtTunnelHostname();
708 
709  VPN_TUNNEL_SCOPE getVpnTunnelScope();
710 
711  bool isStandaloneConnection();
712 
713  void sendSSoLogoutPrompt(ConnectPromptInfo &cpi);
714 
715  void setExternalSSOLogoutUrlFromAgent(const tstring& logoutUrl);
716 
717  private:
718 
719  //
720  // Private Member Data
721  //
722 
723  CExecutionContext* m_pExecutionContext;
724  CExecutionContext* m_pExecutionContextMgr;
725 
726  AgentIfc *mo_AgentIfc;
727 
728  ConnectMgr *mo_ConnectMgr;
729 
730  ApiThread *mo_ConnectThread;
731 
732  EventMgr *mo_EventMgr;
733 
734  PreferenceMgr *mo_PreferenceMgr;
735 
736  ConnectPromptInfo *mp_currentConnectPromptInfo;
737 
738  PreferenceInfo *mo_EditablePrefs;
739 
740 #if defined(SCRIPTING_SUPPORTED)
741  CScriptingMgr *mo_ScriptingMgr;
742 #endif // SCRIPTING_SUPPORTED
743 
744 #if defined(SCEP_CERTIFICATE_ENROLLMENT_SUPPORTED)
745  SCEPIfc* m_pSCEPIfc;
746  bool m_bInformedAgentOfSCEP;
747 #endif // SCEP_CERTIFICATE_ENROLLMENT_SUPPORTED
748 #ifndef PLATFORM_APPLE_SSLVPN
749  CStoragePath* m_pStoragePath;
750 #endif // !PLATFORM_APPLE_SSLVPN
751 
752 #ifdef ANYCONNECT_USE_SNAK
753  PluginLoader *m_pPluginLoader;
754  SNAK_CertPlugin *m_pSNAKCert;
755  SNAK_SocketPlugin *m_pSNAKSocket;
756  SNAK_StoragePlugin *m_pSNAKStorage;
757  SNAK_DeviceInfoPlugin *m_pSNAKDeviceInfo;
758  SNAKDeviceInfoPluginCBImpl *m_pSNAKDeviceInfoCB;
759 
760  bool mb_SNAKInitialized;
761 #endif
762 
763 #if defined(PLATFORM_ANDROID) || defined(PLATFORM_APPLE_SSLVPN)
764  bool mb_SCEPEnrollInProgress;
765 #endif // PLATFORM_ANDROID || PLATFORM_APPLE_SSLVPN
766 
767  bool mb_PreferenceMgrCreated;
768  bool mb_StandaloneConnection;
769  bool mb_UsingEventModel;
770  bool mb_UserResponse;
771  bool mb_IsUserResponseSet;
772  bool mb_PerformedAutoCertEnrollment;
773  tstring ms_PostEnrollmentConnectHost;
774  bool mb_CaptivePortalMsgDisplayed;
775  bool m_bSuppressMinimizeOnConnect;
776  bool m_bSuppressConnectionErrorPopups;
777  bool m_bLastConnectionAutomatic;
778  bool m_bImportCertResp;
779  bool m_bPrevMsgWasStateMsg;
780 
781  unsigned int mui_OperatingMode;
782  NETENV_STATE m_currentNetEnvState;
783  NETENV_STATE m_previousNetEnvState;
784  NETCTRL_STATE m_currentNetCtrlState;
785  NETWORK_TYPE m_currentNetType;
786  bool m_bACBrowserForCPRemediation;
787 
788  tstring ms_message;
789 
790  time_t m_disconnectTime;
791 
792  static std::string ms_ThreadName;
793 
794  CManualLock* m_pClientIfcStateLock;
795  CManualLock* m_pClientIfcLock;
796  CManualLock* m_pClientIfcPromptsLock;
797  CManualLock* m_pClientIfcOpModeLock;
798  CManualLock* m_pClientIfcAHSLock;
799  CManualLock* m_pClientIfcConnectModeLock;
800  CManualLock* m_pClientIfcInformAgentOfSCEPLock;
801 
802  std::vector<tstring> msl_AHSSelectedHosts;
803  ApiThread* m_pAHSThread;
804  unsigned int m_uiAHSState;
805 #if defined(CREDENTIAL_PREFILL_SUPPORTED)
806  CredentialPrefill* m_pCredentialPrefill;
807 #endif
808 
809  // m_AppLogStatus is a long to match the current type of STATUSCODE. It is not using the
810  // type of STATUSCODE directly to not expose the header files for STATUSCODE here.
811  long m_AppLogStatus;
812  std::unique_ptr<CAppLog> m_upAppLogger;
813 
814  VPNError m_lastVpnError;
815 
816  static volatile bool mb_deleteFirstPass;
817 
818  //
819  // Private Member Methods
820  //
821 
822  ConnectMgr &getConnectMgr();
823 
824  ProfileMgr &getProfileMgr();
825  UserPreferences &getUserPreferences();
826 
827  void displayAgentAttachMessage();
828 
829  void setLastDisconnectTime(time_t time);
830 
831  void setCurrentStatePrompts(const VPNState state,
832  const VPNState prevState,
833  const VPNSubState subState,
834  const bool bUpdateStateMsg);
835  void setCurrentStateErrorMessage(VPNState state, CONNECT_FAILURE_REASON cfr);
836  void getStateMessage(const VPNState state,
837  const VPNState prevState,
838  const VPNSubState subState,
839  const NETENV_STATE neState,
840  /*out*/ MsgWithArg& stateMessage);
841 
842  // IPreferenceUpdateCB methods
843  virtual void OnLoadPreferencesComplete();
844  virtual bool IsPreferenceOverridable(const PreferenceId ePreferenceId);
845  virtual void OverridePreferenceValue(const PreferenceId ePreferenceId,
846  tstring& rPrefenceValue,
847  bool& rbOverriden);
848 
849  void RefreshPreferences(void);
850 
851  void displayAHSPrompt(const bool isComplete);
852  void handleAHSPreferences(const unsigned int uiReason);
853  void setAHSState(const unsigned int ahsState);
854 
855  bool autoConnectIfEnabled(const bool suppressAutoConnect);
856 
857  void clearUserSetResponseFlag();
858 
859  bool decodeSSOToken();
860 
861 #if defined(SCEP_CERTIFICATE_ENROLLMENT_SUPPORTED)
862  bool processSCEPIpcMessage(CIpcMessage *pIpcMessage);
863  bool isSCEPRedirect();
864  void processSCEPRedirect();
865 #endif // SCEP_CERTIFICATE_ENROLLMENT_SUPPORTED
866 
867  bool hasConnectCapabilities();
868  bool hasMgmtCapabilities();
869 
870  ClientIfcBase(const ClientIfcBase& other);
871  ClientIfcBase& operator=(const ClientIfcBase& other);
872 
873 #ifdef ANYCONNECT_USE_SNAK
874  bool initializeSNAK(bool bUseExistingInstanceIfAvail);
875  void destroySNAK();
876  ManagedCertificate *convertSnakToManagedCertificate(const ManagedCertHandle &snakCert);
877 #endif
878 };
879 
880 
881 #endif // _CLIENTIFCBASE_
Definition: api.h:113
ConnectPromptType
Definition: api.h:228
Definition: PreferenceInfo.h:27
WMHintReason
Definition: api.h:204
VPNState
Definition: api.h:139
Definition: ClientIfcBase.h:164
#define tstring
Definition: api.h:35
WMHint
Definition: api.h:185
Definition: ConnectPromptInfo.h:37
MessageType
Definition: api.h:108
OperatingMode
Definition: api.h:523
VPNSubState
Definition: api.h:163
PreferenceId
Definition: api.h:278
VPNError
Definition: api.h:575
Definition: VPNStats.h:35
Definition: PreferenceUpdate.h:20