![]() |
AnyConnect Secure Mobility Client 4.4.00243
|
00001 /************************************************************************** 00002 * Copyright (c) 2006, Cisco Systems, All Rights Reserved 00003 *************************************************************************** 00004 * 00005 * File: ClientIfcBase.h 00006 * Author: Chris Fitzgerald 00007 * Date: 08/2007 00008 * 00009 *************************************************************************** 00010 * 00011 * Client Interface Base class implementation for the Client API. 00012 * 00013 ***************************************************************************/ 00014 00015 // The ClientIfcBase class contains the majority of private methods and members. 00016 // The purpose of this class is to hide all but the necessary methods from 00017 // being exposed. 00018 // 00019 00020 #ifndef _CLIENTIFCBASE_ 00021 #define _CLIENTIFCBASE_ 00022 00023 #include <list> 00024 #include <vector> 00025 00026 /* 00027 * When changing the SCRIPTING_SUPPORTED definition, you MUST also update GenDefs.h! 00028 * We duplicate this definition here due to the manner in which we distribute our 00029 * code to partners; we cannot include GenDefs.h from here. 00030 */ 00031 #if !defined(PLATFORM_APPLE_SSLVPN) && !defined(PLATFORM_ANDROID) 00032 #define SCRIPTING_SUPPORTED 00033 #endif 00034 00035 #include "api.h" 00036 #include "PreferenceUpdate.h" 00037 00038 class ConnectPromptInfo; 00039 class ConnectMgr; 00040 class MsgWithArg; 00041 class VPNStats; 00042 class AgentIfc; 00043 class ProfileMgr; 00044 class ApiThread; 00045 class EventMgr; 00046 class PreferenceMgr; 00047 class PreferenceInfo; 00048 class UserPreferences; 00049 class CScriptingMgr; 00050 class CManualLock; 00051 class ApiThread; 00052 class ProxyIfc; 00053 class CIpcMessage; 00054 class SCEPIfc; 00055 class CertObj; 00056 class CExecutionContext; 00057 class HostEntry; 00058 00059 #if !defined(PLATFORM_APPLE_SSLVPN) 00060 class CStoragePath; 00061 #endif 00062 00063 #ifdef ANYCONNECT_USE_SNAK 00064 class PluginLoader; 00065 class SNAK_StoragePlugin; 00066 class SNAK_CertPlugin; 00067 class SNAK_SocketPlugin; 00068 #endif 00069 00070 class VPN_VPNAPI ClientIfcBase : private IPreferenceUpdateCB 00071 { 00072 friend class EventMgr; 00073 00074 protected: 00075 00076 virtual void StatsCB(VPNStats &stats) = 0; 00077 00078 virtual void StateCB(const VPNState state, 00079 const VPNSubState subState, 00080 const tstring stateString) = 0; 00081 00082 virtual void BannerCB(const tstring &banner) = 0; 00083 00084 virtual void NoticeCB(const tstring notice, 00085 const MessageType type) = 0; 00086 00087 virtual void ExitNoticeCB(const tstring &tstrNotice, 00088 const int returnCode); 00089 00090 virtual void ServiceReadyCB() = 0; 00091 00092 virtual void UserPromptCB(ConnectPromptInfo &ConnectPrompt) = 0; 00093 00094 virtual void WMHintCB(const WMHint hint, 00095 const WMHintReason reason); 00096 00097 virtual void deliverWebLaunchHostCB(const tstring &activeHost); 00098 00099 virtual void EventAvailable(); 00100 00101 #ifdef PLATFORM_ANDROID 00102 virtual void ClientCertificateCB(std::vector< std::pair<uint32_t, uint8_t*> > certList) = 0; 00103 virtual void AgentDetachedCB(); 00104 #endif 00105 00106 virtual void ImportPKCS12ResultCB(bool bResult, const tstring &strError); 00107 00108 virtual void CertBlockedCB(const tstring &rtstrUntrustedServer) = 0; 00109 virtual void CertWarningCB(const tstring &rtstrUntrustedServer, 00110 const std::list<tstring> &rltstrCertErrors, 00111 bool bAllowImport) = 0; 00112 00113 AgentIfc &getAgentIfc(); 00114 00115 ClientIfcBase(); 00116 00117 00118 public: 00119 00120 virtual bool attach(bool SBL = false, 00121 bool isGUI = true, 00122 bool requestFullCapabilities = true, 00123 bool suppressAutoConnect = true); 00124 00125 virtual void detach(); 00126 00127 virtual void ProcessEvents(); 00128 00129 virtual bool hasFullCapabilities(); 00130 00131 virtual bool isConnected(); 00132 00133 virtual bool isAvailable(); 00134 00135 virtual std::list<tstring> getHostNames(); 00136 00137 virtual tstring getDefaultHostName(); 00138 00139 #if defined (PLATFORM_ANDROID) 00140 virtual bool connect(tstring host, const CertAuthMode mode=CertAuth_Automatic, const tstring &hash=""); 00141 00142 bool connect(tstring host, unsigned int origin, const CertAuthMode mode=CertAuth_Automatic, const tstring &hash=""); 00143 #else 00144 virtual bool connect(tstring host); 00145 00146 bool connect(tstring host, unsigned int origin); 00147 #endif 00148 00149 virtual bool setNewTunnelGroup(const tstring & group); 00150 00151 virtual void disconnect(); 00152 00153 virtual void cancel(); 00154 00155 virtual void resetStats(); 00156 00157 virtual void getState(); 00158 00159 VPNState getCurrentState(); 00160 VPNSubState getCurrentSubState(); 00161 VPNSubState getPreviousSubState(); 00162 00163 tstring getStateText(); 00164 static tstring getNoticeTypeText(MessageType msgType); 00165 00166 static tstring getStateText(VPNState state, 00167 VPNSubState subState = VPNSS_NORMAL, 00168 NETENV_STATE netEnvState = NES_NETWORK_ACCESSIBLE); 00169 00170 void setNetworkStates(NETENV_STATE netEnvState, 00171 NETCTRL_STATE netCtrlState, 00172 NETWORK_TYPE netType, 00173 bool bUpdateUI); 00174 void refreshOperatingModeForCurrentNetStates(); 00175 NETENV_STATE getCurrentNetEnvState(); 00176 NETENV_STATE getPreviousNetEnvState(); 00177 NETCTRL_STATE getCurrentNetCtrlState(); 00178 NETWORK_TYPE getCurrentNetType(); 00179 00180 static tstring getNetCtrlText(NETCTRL_STATE netCtrlState); 00181 static tstring getNetEnvText(NETENV_STATE netEnvState, 00182 bool bSimple = false); 00183 static tstring getNetTypeText(NETWORK_TYPE netType); 00184 static tstring getQuarantinedStatusText(); 00185 static tstring getNetworkStatusSimpleText(const NETENV_STATE netEnvState, 00186 const NETCTRL_STATE netCtrlState); 00187 00188 // can't be static due to requiring operating mode information 00189 tstring getNetworkStatusText(const VPNState state, 00190 const VPNSubState subState, 00191 const NETENV_STATE netEnvState, 00192 const NETCTRL_STATE netCtrlState); 00193 00194 PreferenceInfo &getPreferences(); 00195 00196 bool savePreferences(); 00197 00198 virtual void startStats(); 00199 00200 virtual void stopStats(); 00201 00202 virtual void UserSubmit(); 00203 00204 void setBanner(const tstring &banner); 00205 void setBannerResponse(bool bResponse); 00206 bool getUserResponse(); 00207 bool isUserResponseSet(); 00208 00209 void setCertBlocked(const tstring &tstrUntrustedServer); 00210 void setCertWarning(const tstring &tstrUntrustedServer, 00211 const std::list<tstring> <strCertErrors, 00212 bool bAllowImport); 00213 bool getCertImportResponse(); 00214 00215 void setUserPrompt(ConnectPromptInfo &ConnectPrompt); 00216 00217 #ifdef PLATFORM_ANDROID 00218 void setClientCertResponse(std::vector< std::pair<uint32_t, uint8_t*> > &derList); 00219 #endif 00220 00221 void setImportPKCS12Result(bool bResult, const tstring &strError); 00222 00223 void setCertBlockedResponse(bool bUnlock); 00224 void setCertWarningResponse(bool bConnect, bool bImportCert); 00225 00226 void insertStateToConnectPrompt(ConnectPromptInfo &ConnectPrompt); 00227 00228 void ExitNotice(const tstring &tstrNotice, const int code = 0); 00229 00230 void notice(const tstring tstrNotice, 00231 const MessageType type = MsgType_Info, 00232 bool bClearLastMsg = false); 00233 00234 void notice(MsgWithArg ¬ice, 00235 const MessageType type = MsgType_Info, 00236 bool bClearLastMsg = false); 00237 00238 void getStats(void); 00239 00240 void setStats(VPNStats &stats); 00241 00242 void exportStats(const tstring &tstrFilePath); 00243 00244 void setState(VPNState state, 00245 VPNState previousState, 00246 VPNSubState subState = VPNSS_NORMAL, 00247 bool bUpdateStateMsg = true, 00248 bool bOnlyUpdateUI = false); 00249 00250 void setWMHint(WMHint hint, 00251 WMHintReason reason); 00252 00253 bool isLastConnectType (const ConnectPromptType connPromptType); 00254 00255 bool isOperatingMode(OperatingMode opMode); 00256 void setOperatingMode(OperatingMode opMode); 00257 void unsetOperatingMode(OperatingMode opMode); 00258 00259 bool CanRemediateCaptivePortal(); 00260 00261 bool isUsingEventModel(); 00262 00263 time_t getLastDisconnectTime(); 00264 00265 ConnectPromptInfo getConnectPromptInfo(); 00266 00267 void setStandaloneConnection(bool isStandalone); 00268 00269 void deliverActiveHost(const tstring &activeHost, 00270 ConnectProtocolType vpnProtocol = PROTOCOL_TYPE_UNKNOWN); 00271 00272 bool isVPNServiceReady(); 00273 00274 // reset last disconnect time indicator. 00275 // 00276 void resetLastDisconnectTime(time_t time = 1); 00277 00278 void processMinimize(); 00279 00280 // cert enrollment 00281 void setEnrollClientCert(CertObj* pCert); 00282 00283 // Show user banner for cert import warning on linux 00284 // SCEPIfc to ConnectMgr 00285 void linuxCertImportWarnUser(); 00286 00287 // Response to cert warning on linux 00288 // ConnectMgr to SCEPIfc 00289 void linuxCertImportWarnUserResponse(bool bAccept); 00290 00291 void setDefaultHost(tstring &host); 00292 00293 #ifdef PLATFORM_ANDROID 00294 bool requestClientCertificates(); 00295 #endif 00296 00297 bool requestImportPKCS12(const std::vector<unsigned char> &der); 00298 00299 bool requestImportLocalization(const tstring tstrLocale, 00300 const std::vector<unsigned char> &MoFileData); 00301 00302 // Start the Automatic Headend Selection operation 00303 void startAHS(const unsigned int uiReason, 00304 const ProxyIfc& proxy); 00305 // statusReturnCode is a long to match the current type of STATUSCODE. 00306 // It is not using a STATUSCODE directly so that we do not have to 00307 // expose the header files for STATUSCODEs to ClientIfcBase.h 00308 void AHSSelectedHost(const unsigned int uiReason, 00309 const std::vector<tstring> &headendList, 00310 const long statusReturnCode, 00311 const tstring& extraInfo); 00312 std::vector<tstring> getAHSHostList(); 00313 unsigned int getAHSState(); 00314 bool isAHSHasRun(); 00315 00316 bool suppressConnectionErrorPopups(); 00317 00318 tstring getCaptivePortalDetectedMsg(); 00319 00320 void setProxyAuthPrompts(ProxyIfc* pProxy, 00321 const tstring& promptMsg); 00322 00323 00324 bool handleIpcMessage(CIpcMessage *pIpcMessage); 00325 00326 bool IsCsdTokenVerified() const; 00327 00328 bool isConnectRequestActive(); 00329 00330 virtual ~ClientIfcBase(); 00331 00332 tstring getConnectHost(); 00333 00334 private: 00335 CExecutionContext* m_pExecutionContext; 00336 CExecutionContext* m_pExecutionContextMgr; 00337 00338 AgentIfc *mo_AgentIfc; 00339 00340 ConnectMgr *mo_ConnectMgr; 00341 00342 ApiThread *mo_ConnectThread; 00343 00344 EventMgr *mo_EventMgr; 00345 00346 PreferenceMgr *mo_PreferenceMgr; 00347 00348 ConnectPromptInfo *mp_currentConnectPromptInfo; 00349 00350 PreferenceInfo *mo_EditablePrefs; 00351 00352 #if defined(SCRIPTING_SUPPORTED) 00353 CScriptingMgr *mo_ScriptingMgr; 00354 #endif // SCRIPTING_SUPPORTED 00355 #ifndef PLATFORM_APPLE_SSLVPN 00356 SCEPIfc* m_pSCEPIfc; 00357 bool m_bInformedAgentOfSCEP; 00358 CStoragePath* m_pStoragePath; 00359 #endif // !PLATFORM_APPLE_SSLVPN 00360 00361 #ifdef ANYCONNECT_USE_SNAK 00362 PluginLoader *m_pPluginLoader; 00363 SNAK_CertPlugin *m_pSNAKCert; 00364 SNAK_SocketPlugin *m_pSNAKSocket; 00365 SNAK_StoragePlugin *m_pSNAKStorage; 00366 00367 bool mb_SNAKInitialized; 00368 #endif 00369 00370 bool mb_PreferenceMgrCreated; 00371 bool mb_StandaloneConnection; 00372 bool mb_UsingEventModel; 00373 bool mb_UserResponse; 00374 bool mb_IsUserResponseSet; 00375 bool mb_PerformedAutoCertEnrollment; 00376 tstring ms_PostEnrollmentConnectHost; 00377 bool mb_CaptivePortalMsgDisplayed; 00378 bool m_bSuppressMinimizeOnConnect; 00379 bool m_bSuppressConnectionErrorPopups; 00380 bool m_bLastConnectionAutomatic; 00381 bool m_bImportCertResp; 00382 00383 unsigned int mui_OperatingMode; 00384 NETENV_STATE m_currentNetEnvState; 00385 NETENV_STATE m_previousNetEnvState; 00386 NETCTRL_STATE m_currentNetCtrlState; 00387 NETWORK_TYPE m_currentNetType; 00388 00389 tstring ms_message; 00390 00391 time_t m_disconnectTime; 00392 00393 static std::string ms_ThreadName; 00394 00395 CManualLock* m_pClientIfcStateLock; 00396 CManualLock* m_pClientIfcLock; 00397 CManualLock* m_pClientIfcPromptsLock; 00398 CManualLock* m_pClientIfcOpModeLock; 00399 CManualLock* m_pClientIfcAHSLock; 00400 CManualLock* m_pClientIfcConnectModeLock; 00401 CManualLock* m_pClientIfcInformAgentOfSCEPLock; 00402 00403 std::vector<tstring> msl_AHSSelectedHosts; 00404 ApiThread* m_pAHSThread; 00405 unsigned int m_uiAHSState; 00406 00407 static volatile bool mb_deleteFirstPass; 00408 00409 ConnectMgr &getConnectMgr(); 00410 00411 ProfileMgr &getProfileMgr(); 00412 UserPreferences &getUserPreferences(); 00413 00414 void displayAgentAttachMessage(); 00415 00416 void setLastDisconnectTime(time_t time); 00417 00418 void setCurrentStatePrompts(const VPNState state, 00419 const VPNState prevState, 00420 const VPNSubState subState, 00421 const bool bUpdateStateMsg); 00422 void setCurrentStateErrorMessage(VPNState state, CONNECT_FAILURE_REASON cfr); 00423 void getStateMessage(const VPNState state, 00424 const VPNState prevState, 00425 const VPNSubState subState, 00426 const NETENV_STATE neState, 00427 /*out*/ MsgWithArg& stateMessage); 00428 00429 bool isStandaloneConnection(); 00430 00431 virtual void OnLoadPreferencesComplete(); 00432 void RefreshPreferences(void); 00433 00434 void displayAHSPrompt(const bool isComplete); 00435 void handleAHSPreferences(const unsigned int uiReason); 00436 void setAHSState(const unsigned int ahsState); 00437 00438 bool autoConnectIfEnabled(const bool suppressAutoConnect); 00439 00440 void clearUserSetResponseFlag(); 00441 00442 #ifndef PLATFORM_APPLE_SSLVPN 00443 bool processSCEPIpcMessage(CIpcMessage *pIpcMessage); 00444 bool isSCEPRedirect(); 00445 void processSCEPRedirect(); 00446 #endif // PLATFORM_APPLE_SSLVPN 00447 00448 ClientIfcBase(const ClientIfcBase& other); 00449 ClientIfcBase& operator=(const ClientIfcBase& other); 00450 00451 #ifdef ANYCONNECT_USE_SNAK 00452 bool initializeSNAK(); 00453 #endif 00454 00455 }; 00456 00457 00458 #endif // _CLIENTIFCBASE_