CredentialCache Class

  • CredentialCache
  • class Esri::ArcGISRuntime::CredentialCache

    A cache containing credentials to reuse. More...

    Header: #include <CredentialCache.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::Object

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Functions

    virtual ~CredentialCache() override
    Esri::ArcGISRuntime::Credential *credential(const QUrl &url) const
    void removeAllCredentials()
    void removeAndRevokeAllCredentials()
    void removeAndRevokeCredential(Esri::ArcGISRuntime::Credential *credential)
    bool removeCredential(const QUrl &url)
    bool removeCredential(const Esri::ArcGISRuntime::Credential *credential)
    bool setCredential(Esri::ArcGISRuntime::Credential *credential, const QUrl &url)

    Signals

    void removeAndRevokeAllCredentialsCompleted(const QMap<Esri::ArcGISRuntime::Credential *, Esri::ArcGISRuntime::Error> &errors)
    void removeAndRevokeCredentialCompleted(Esri::ArcGISRuntime::Error error)

    Detailed Description

    An instance of this class is available through the AuthenticationManager. It represents a cache containing credentials. All objects and tasks share this instance and could potentially reuse a credential if they need to access the same security realm.

    The URL acts as the lookup key into the cache and represents one of the following:

    • The full path to a server from an ArcGIS Server.
    • The full path to a portal, portal item, or hosted item.
    • The URL to a portal, such as https://www.arcgis.com.
    • The URL to an ArcGIS Server instance, such as https://host(:port)/instance.

    Automatic caching happens when credentials (that is, username, password, token, or OAuth client information) are required when connecting to a secure service hosted by ArcGIS Server, ArcGIS Online, or Federated by Portal. Upon successful connection to one of these secure services, the credential is cached in the CredentialCache and reused again whenever subsequent connections are made to the secure service.

    Caching happens automatically if AuthenticationManager::isCredentialCacheEnabled is enabled. In addition, the CredentialCache class contains public methods to manipulate the cache contents.

    Member Function Documentation

    [signal] void CredentialCache::removeAndRevokeAllCredentialsCompleted(const QMap<Esri::ArcGISRuntime::Credential *, Esri::ArcGISRuntime::Error> &errors)

    Signal emitted when removeAndRevokeAllCredentials completes.

    • errors - A map in which the keys are pointers to Credential objects and the values are Error objects indicating why revocation of the associated Credentials failed.

    The returned Credential objects have the CredentialCache as its parent.

    This function was introduced in Esri::ArcGISRuntime 100.8.

    See also Returned QObjects Parenting.

    [signal] void CredentialCache::removeAndRevokeCredentialCompleted(Esri::ArcGISRuntime::Error error)

    Signal emitted when removeAndRevokeCredential completes.

    • error - The optional error related to the request to revoke the credential's OAuth token.

    This function was introduced in Esri::ArcGISRuntime 100.8.

    [override virtual] CredentialCache::~CredentialCache()

    Destructor.

    Esri::ArcGISRuntime::Credential *CredentialCache::credential(const QUrl &url) const

    Returns the credential for a given url.

    See also setCredential().

    void CredentialCache::removeAllCredentials()

    Removes all credentials from the cache.

    void CredentialCache::removeAndRevokeAllCredentials()

    Removes all credentials from the cache and revokes tokens if appropriate.

    If any credential is used for OAuth authentication, a request is sent to revoke its OAuth token. The resultant removeAndRevokeAllCredentialsCompleted signal contains a map that will be empty if no errors occurred. If it is not empty, each entry contains a Credential for which OAuth token revocation failed and an Error indicating why it failed. All credentials are removed from the cache even if OAuth token revocation fails.

    This function was introduced in Esri::ArcGISRuntime 100.8.

    void CredentialCache::removeAndRevokeCredential(Esri::ArcGISRuntime::Credential *credential)

    Removes the given credential from the cache and revokes its token if appropriate.

    If the credential is used for OAuth authentication, a request is sent to revoke its OAuth token. If the resultant removeAndRevokeCredentialCompleted signal indicates an error occurred, the error relates to the request to revoke the OAuth token. The credential is removed from the cache even if OAuth token revocation fails.

    This function was introduced in Esri::ArcGISRuntime 100.8.

    bool CredentialCache::removeCredential(const QUrl &url)

    Removes from the cache the credential for a given url and returns true if successful.

    bool CredentialCache::removeCredential(const Esri::ArcGISRuntime::Credential *credential)

    Removes from the cache the credential and returns true if successful.

    bool CredentialCache::setCredential(Esri::ArcGISRuntime::Credential *credential, const QUrl &url)

    Sets the credential for a given url and returns true if successful.

    This method will append a credential to the cache if the key for the URL does not already exist. The credential is replaced for the URL if the URL is already in the cache.

    See also credential().

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.