AnyConnect Secure Mobility Client  5.1.2.42
ClientIfc Class Reference

Public Member Functions

bool attach (ClientType clientType=ClientType_GUI, bool requestFullCapabilities=true, bool suppressAutoConnect=true)
 
void detach ()
 
void ProcessEvents ()
 
bool hasFullCapabilities ()
 
bool isConnected (bool bSilent=false)
 
bool isAvailable ()
 
bool isVPNServiceAvailable ()
 
bool isOperatingMode (OperatingMode opMode)
 
std::list< tstringgetHostNames ()
 
tstring getDefaultHostName ()
 
bool connect (tstring host)
 
bool connect (tstring host, unsigned int origin)
 
bool setNewTunnelGroup (const tstring &group)
 
void disconnect ()
 
void cancel ()
 
void getState ()
 
void getStats ()
 
void resetStats ()
 
void startStats ()
 
void stopStats ()
 
void exportStats (const tstring &tstrFilePath)
 
void setBannerResponse (bool bAccepted)
 
void setPreConnectReminderResponse ()
 
void setCertBlockedResponse (bool bUnblock)
 
void setCertWarningResponse (bool bConnect, bool bImportCert)
 
void UserSubmit ()
 
std::shared_ptr< PreferenceInfogetPreferences ()
 
unsigned int getPreferencesCount ()
 
bool savePreferences (const std::shared_ptr< PreferenceInfo > &spPreferenceInfo)
 
tstring getConnectHost ()
 
void setLastVpnError (VPNError vpnError)
 
VPNError getLastVpnError ()
 
bool isConnectRequestActive ()
 

Friends

class ClientIfcData
 

Additional Inherited Members

- Protected Member Functions inherited from ClientIfcBase
virtual void StatsCB (VPNStats &stats)=0
 
virtual void StateCB (const VPNState state, const VPNSubState subState, const tstring stateString)=0
 
virtual void BannerCB (const tstring &banner)=0
 
virtual void PreConnectReminderCB (const tstring &rtstrPreConnectReminder)
 
virtual void NoticeCB (const tstring &notice, const MessageType type, const bool bSensitive=false)=0
 
virtual void ExitNoticeCB (const tstring &tstrNotice, const int returnCode)
 
virtual void ServiceReadyCB ()=0
 
virtual void UserPromptCB (ConnectPromptInfo &ConnectPrompt)=0
 
virtual void WMHintCB (const WMHint hint, const WMHintReason reason)
 
virtual void deliverWebLaunchHostCB (const tstring &activeHost)
 
virtual void CertBlockedCB (const tstring &rtstrUntrustedServer)=0
 
virtual void CertWarningCB (const tstring &rtstrUntrustedServer, const std::list< tstring > &rltstrCertErrors, bool bAllowImport)=0
 
virtual void EventAvailable ()
 
void ClientIfcTransmigration ()
 
bool attach (const ClientType clientType=ClientType_GUI, const bool requestFullCapabilities=true, const bool suppressAutoConnect=true, const bool bSuppressEventAvailableCB=false)
 
void detach ()
 
void ProcessEvents ()
 
bool hasFullCapabilities ()
 
bool isConnected (bool bSilent=false)
 
bool isAvailable ()
 
std::list< tstringgetHostNames ()
 
std::list< HostEntry > getHostEntries ()
 
tstring getDefaultHostName ()
 
bool connect (tstring host)
 
bool connect (tstring host, unsigned int origin)
 
bool setNewTunnelGroup (const tstring &group)
 
void disconnect ()
 
void cancel ()
 
void resetStats ()
 
void getState ()
 
VPNState getCurrentState ()
 
VPNSubState getCurrentSubState ()
 
VPNSubState getPreviousSubState ()
 
tstring getStateText ()
 
void setNetworkStates (NETENV_STATE netEnvState, NETCTRL_STATE netCtrlState, NETWORK_TYPE netType, bool bACBrowserForCPRemediation, bool bUpdateUI)
 
void refreshOperatingModeForCurrentNetStates ()
 
NETENV_STATE getCurrentNetEnvState ()
 
NETENV_STATE getPreviousNetEnvState ()
 
NETCTRL_STATE getCurrentNetCtrlState ()
 
NETWORK_TYPE getCurrentNetType ()
 
bool isACBrowserForCPRemediation ()
 
tstring getNetworkStatusText (const VPNState state, const VPNSubState subState, const NETENV_STATE netEnvState, const NETCTRL_STATE netCtrlState)
 
PreferenceInfogetPreferences ()
 
bool savePreferences ()
 
void startStats ()
 
void stopStats ()
 
void UserSubmit ()
 
void setBanner (const tstring &banner)
 
void setBannerResponse (bool bResponse)
 
void setPreConnectReminder (const tstring &tstrPreConnectReminder)
 
void setPreConnectReminderResponse ()
 
bool getUserResponse ()
 
bool isUserResponseSet ()
 
void setCertBlocked (const tstring &tstrUntrustedServer)
 
void setCertWarning (const tstring &rtstrUntrustedServer, const std::list< tstring > &rltstrCertErrors, bool bAllowImport)
 
bool getCertImportResponse ()
 
void setUserPrompt (ConnectPromptInfo &ConnectPrompt)
 
void setCertBlockedResponse (bool bUnlock)
 
void setCertWarningResponse (bool bConnect, bool bImportCert)
 
void insertStateToConnectPrompt (ConnectPromptInfo &ConnectPrompt)
 
void ExitNotice (const tstring &tstrNotice, const int code=0)
 
void notice (const tstring &tstrNotice, const MessageType type=MsgType_Info, bool bClearLastMsg=false, bool bForce=false, bool bStateMsg=false, bool bSensitiveMsg=false)
 
void notice (MsgWithArg &notice, const MessageType type=MsgType_Info, bool bClearLastMsg=false, bool bForce=false, bool bStateMsg=false, bool bSensitiveMsg=false)
 
void getStats (void)
 
void setStats (VPNStats &stats)
 
void exportStats (const tstring &tstrFilePath)
 
void initState (VPNState state, VPNState previousState, VPNSubState subState)
 
void setState (VPNState state, VPNState previousState, VPNSubState subState=VPNSS_NORMAL, bool bUpdateStateMsg=true, bool bOnlyUpdateUI=false)
 
void setWMHint (WMHint hint, WMHintReason reason)
 
bool isLastConnectType (const ConnectPromptType connPromptType)
 
bool isOperatingMode (OperatingMode opMode)
 
void setOperatingMode (OperatingMode opMode)
 
void unsetOperatingMode (OperatingMode opMode)
 
bool CanRemediateCaptivePortal ()
 
bool policyAllowsCaptivePortalRemediation ()
 
bool isEventShutdown ()
 
bool isUsingEventModel ()
 
time_t getLastDisconnectTime ()
 
ConnectPromptInfo getConnectPromptInfo ()
 
void resetConnectPromptPasswordData ()
 
void setStandaloneConnection (bool isStandalone)
 
void deliverActiveHost (const tstring &activeHost, ConnectProtocolType vpnProtocol=PROTOCOL_TYPE_UNKNOWN, bool bActiveHostFriendlyName=false)
 
bool isVPNServiceReady ()
 
void resetLastDisconnectTime (time_t time=1)
 
void processMinimize ()
 
void setEnrollClientCert (CertObj *pCert)
 
void linuxCertImportWarnUser ()
 
void linuxCertImportWarnUserResponse (bool bAccept)
 
void setDefaultHost (tstring &host)
 
void setLastVpnError (VPNError vpnError)
 
VPNError getLastVpnError ()
 
bool requestImportLocalization (const tstring tstrLocale, const std::vector< unsigned char > &MoFileData)
 
void startAHS (const unsigned int uiReason, const ProxyIfc &proxy)
 
void AHSSelectedHost (const unsigned int uiReason, const std::vector< tstring > &headendList, const long statusReturnCode, const tstring &extraInfo)
 
std::vector< tstringgetAHSHostList ()
 
unsigned int getAHSState ()
 
bool isAHSHasRun ()
 
bool IsAHSCachingRestricted ()
 
bool suppressConnectionErrorPopups ()
 
tstring getCaptivePortalDetectedMsg ()
 
void setProxyAuthPrompts (ProxyIfc *pProxy, const tstring &promptMsg)
 
bool handleIpcMessage (CIpcMessage *pIpcMessage)
 
bool IsCsdTokenVerified () const
 
void activateConnectMgrTunnelInitiationCompletionEvent ()
 
bool isConnectRequestActive ()
 
bool syncProfileChange (const tstring &profileName)
 
tstring getConnectHost ()
 
tstring getMgmtTunnelHostname ()
 
VPN_TUNNEL_SCOPE getVpnTunnelScope ()
 
bool isStandaloneConnection ()
 
void sendSSoLogoutPrompt (ConnectPromptInfo &cpi)
 
void setExternalSSOLogoutUrlFromAgent (const tstring &logoutUrl)
 
- Static Protected Member Functions inherited from ClientIfcBase
static tstring getNoticeTypeText (MessageType msgType)
 
static tstring getStateText (VPNState state, VPNSubState subState=VPNSS_NORMAL, NETENV_STATE netEnvState=NES_NETWORK_ACCESSIBLE, const tstring &tstrConnectedHost=tstring())
 
static tstring getNetCtrlText (NETCTRL_STATE netCtrlState)
 
static tstring getNetEnvText (NETENV_STATE netEnvState, bool bSimple=false)
 
static tstring getNetTypeText (NETWORK_TYPE netType)
 
static tstring getQuarantinedStatusText ()
 
static tstring getNetworkStatusSimpleText (const NETENV_STATE netEnvState, const NETCTRL_STATE netCtrlState)
 

Member Function Documentation

◆ attach()

bool ClientIfc::attach ( ClientType  clientType = ClientType_GUI,
bool  requestFullCapabilities = true,
bool  suppressAutoConnect = true 
)

Callback Declarations inherited from ClientIfcBase.

Virtual Abstract Callback Method Declarations: StatsCB StateCB BannerCB NoticeCB CertBannerCB ServiceReadyCB UserPromptCB CertBlockedCB CertWarningCB (2 signatures) ClientCertificateCB

Virtual Callback Method Declarations: PreConnectReminderCB ExitNoticeCB WMHintCB deliverWebLaunchHostCB EventAvailable ImportPKCS12ResultCB AgentDetachedCB After the ClientIfc class has been created, the client implementation must invoke this method prior to attempting connections, retrieving statistics, etc. If successful, this method returns true. If not successful, it returns false and returns a notice error message to the user.

A single call to this method is all that is necessary. If the attach fails, a message indicating the VPN service is not available is returned. If the call succeeds, the ServiceReadyCB is called and true is returned.

Parameters
ClientTypeclientType (default ClientType_GUI) Other options: ClientType_GUI_SBL, ClientType_CLI, ClientType_MGMT. ClientType_GUI: indicates that the started program is a GUI application. With this attribute set to true, the application will now receive WMHints. ClientType_GUI_SBL: SBL (Start Before Logon) is a mode of operation where a GUI can be launched prior to the normal windows logon sequence.
This allows a VPN tunnel to be activated and used as part of the windows logon sequence. This value is applicable only when a corresponding argument has been passed to the program by the VPN agent. ClientType_CLI: indicates that the started program is a CLI application. ClientType_MGMT: indicates that the started program is used to initiate an AnyConnect management VPN tunnel. This value is applicable only to a client launched by AnyConnect VPN agent.
requestFullCapabilitiesindicates that the client program is requesting full API capabilities. Full capabilities allows the client program to connect, disconnect, receive statistics, etc. When full capabilities are not requested or not available, the client program will not be able to establish new VPN connections. Only a client program with full capabilites can do this. In addition, only the first program requesting full capabilities will be granted this level of access. The attach method can succeed even if full capabilities is requested but not granted. To test for this state, use the method ::hasFullCapabilities.
suppressAutoConnectindicates that the client wishes to override automatically initiating a connection to the last connected secure gateway at startup. Normally, this is determined by the value of the AutoConnectOnStart preference. If this flag is true then an automatic connection will never be initiated, even if AutoConnectOnStart is enabled.

◆ cancel()

void ClientIfc::cancel ( )

Use this method to cancel the user authentication. VPN tunnel is not connected at the moment. This function is used to cancel SSO authentication.

An indication of VPN disconnect is received via the StateCB method.

◆ connect()

bool ClientIfc::connect ( tstring  host)

This method initiates a connection to the specified host. The connection results in the presentation of authentication credentials, as appropriate. Any credentials returned by the secure gateway are delivered via the UserPromptCB method.

See ConnectPromptInfo for more details on possible authentication credentials.

If the connection request is accepted, true is returned. This does not mean the connection succeeded. If the connection succeeds, a state of connect will be received via the StateCB method.

◆ detach()

void ClientIfc::detach ( )

After the client program is done, call the detach method to do a graceful cleanup. This method stops the flow of events and does general cleanup.

◆ disconnect()

void ClientIfc::disconnect ( )

Use this method to initiate a disconnect of the active VPN connection.

An indication of VPN disconnect is received via the StateCB method.

◆ exportStats()

void ClientIfc::exportStats ( const tstring tstrFilePath)

This method directs where and how to export the statistics

◆ getConnectHost()

tstring ClientIfc::getConnectHost ( )

This is called from the credential dialog in the GUI to get the correct friendly name for the dialog title.

◆ getDefaultHostName()

tstring ClientIfc::getDefaultHostName ( )

This method returns any default Host name from User Preferences.

A host can be returned here even if there are no profiles on the system. The host last connected to (via the connect method) is returned by this method.

If there is no previously connected-to host, the first host found in an AnyConnect profile (if any) is returned.

◆ getHostNames()

std::list<tstring> ClientIfc::getHostNames ( )

This method returns a list of secure gateway host names found in an AnyConnect profile. If no profile is available, an empty list is returned.

◆ getLastVpnError()

VPNError ClientIfc::getLastVpnError ( )

This method gets the last VPN error seen during this connection attempt for reporting purposes. This VPN error should be cleared for each connection attempt.

◆ getPreferences()

std::shared_ptr<PreferenceInfo> ClientIfc::getPreferences ( )

Method for retrieving the currently available user preferences. This method returns a instance of the class PreferenceInfo. The class instance is a deep copy and therefore independent of any VPN API object instances. It contains a variable number of Preference class instance pointers. Each preference contains data identifying the specific preference, its current value, etc. For a list of all possible preferences see the PreferenceId enum in api.h. Note that some of these preferences are not available to the user.

See also
PreferenceInfo

◆ getPreferencesCount()

unsigned int ClientIfc::getPreferencesCount ( )

Method for retrieving the current number of available user preferences. This method provides an optimized means of determining if there are any available user preferences. An application may have no need to retrieve the user preferences if there are no user preferences available, and invoking getPreferences() incurs the cost of a deep copy of the internal PreferenceInfo class instance, possibly causing many memory allocations, even when there are no avaiable user preferences, which could result in poor user interface responsiveness.

See also
PreferenceInfo

◆ getState()

void ClientIfc::getState ( )

This method triggers the retrieval of the current VPN state. After the client is conected to the VPN service via the attach method, both the current state and any changes in state are automatically delivered to the client. In general, this method should not be needed.

VPNState is delivered via StateCB method.

◆ getStats()

void ClientIfc::getStats ( )

This method triggers the retrieval of the current VPN statistics. This allows an UI to notify the API that it is ready to receive statistics.

VPNState is delivered via StatsCB method.

◆ hasFullCapabilities()

bool ClientIfc::hasFullCapabilities ( )

Use this method to determine whether this application has full capabilities. Only one application (the first one started) can have full capabilities. If this is the first application started, this method returns true. When an application has full capabilities, it can initiate connections, as well as offer UI capabilities.

◆ isAvailable()

bool ClientIfc::isAvailable ( )

This method returns true if the client VPN is available for use. If false is returned this means that VPN has been intentionally disabled. This would indicate a situation where other AnyConnect services were in use but not VPN.

◆ isConnected()

bool ClientIfc::isConnected ( bool  bSilent = false)

This method returns true if the client has an active VPN connection with a secure gateway.

◆ isConnectRequestActive()

bool ClientIfc::isConnectRequestActive ( )

This method indicates if a request to connect has been initiated and the SG is being contacted. Note: the connect request is not active while waiting for the user to enter credentials.

◆ isOperatingMode()

bool ClientIfc::isOperatingMode ( OperatingMode  opMode)

This method returns true if the mode in which the client is currently operating is enabled. For a list of all possible modes of operation see the OperatingMode enum in api.h.

◆ isVPNServiceAvailable()

bool ClientIfc::isVPNServiceAvailable ( )

This method returns true if the VPN service is available for establishing VPN connections.

◆ ProcessEvents()

void ClientIfc::ProcessEvents ( )

When the method ClientIfc::EventAvailable has been overridden in the client application, this method must be called to receive events.

It is expected that GUI programs will use EventAvailable as a signal, allowing them to set an event using their native event handler. When that event fires, the application can call ProcessEvents, which causes the API to deliver events in the client's main thread.

◆ resetStats()

void ClientIfc::resetStats ( )

This method resets current VPN statistics counters.

◆ savePreferences()

bool ClientIfc::savePreferences ( const std::shared_ptr< PreferenceInfo > &  spPreferenceInfo)

This method stores the current set values of the preferences to the preferences file(s). This method is a counterpart to the getPreferences() method.

◆ setBannerResponse()

void ClientIfc::setBannerResponse ( bool  bAccepted)

Call this method after a BannerCB has been received to indicate that the user response to the banner can now be read.

Parameters
bAcceptedindicates if the user accepted or declined the banner.

◆ setLastVpnError()

void ClientIfc::setLastVpnError ( VPNError  vpnError)

This method sets the last VPN error seen during this connection attempt for reporting purposes. This VPN error should be cleared for each connection attempt.

◆ setNewTunnelGroup()

bool ClientIfc::setNewTunnelGroup ( const tstring group)

Use this method to change selected group after initial connection request has been made and credentials were delivered.

Depending on secure gateway configuratiion, call to this method may result in a new connection request and will update credentials required for the selected group. New credentials returned by the secure gateway are delivered via the UserPromptCB method.

◆ setPreConnectReminderResponse()

void ClientIfc::setPreConnectReminderResponse ( )

Call this method after a PreConnectReminderCB has been received to indicate that user has acknowledged pre-connect reminder message.

NOTE : Ignoring the response from user (for example, closing the modal dialog instead of clicking OK button). Old AnyConnect client (v3.1) ignored the response too.

◆ startStats()

void ClientIfc::startStats ( )

This method activates the retrieval of VPN statistics and other related data. By default, VPNStats are automatically delivered via the method StatsCB.

If the stopStats method is called to stop the delivery of statistics, this method can be called to resume delivery.

◆ stopStats()

void ClientIfc::stopStats ( )

This method stops the delivery of VPN statistics and other related data. By default, VPNStats are automatically delivered. This method disables delivery.

The method startStats can be called to resume the delivery of statistics.

◆ UserSubmit()

void ClientIfc::UserSubmit ( )

Call this method to indicate that authentication credential requests values solicited by the UserPromptCB method can now be read from the ConnectPromptInfo instance.