Skip To Content ArcGIS for Developers Sign In Dashboard

CredentialCache Class

(Esri::ArcGISRuntime::CredentialCache)

A cache containing credentials to reuse. More...

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

Public Functions

~CredentialCache()
Credential *credential(const QUrl &url) const
void removeAllCredentials()
void removeAndRevokeAllCredentials()
void removeAndRevokeCredential(Credential *credential)
bool removeCredential(const QUrl &url)
bool removeCredential(const Credential *credential)
bool setCredential(Credential *credential, const QUrl &url)
  • 31 public functions inherited from QObject

Signals

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

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

A cache containing credentials to reuse.

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

CredentialCache::~CredentialCache()

Destructor.

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's 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.

[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.

This function was introduced in Esri::ArcGISRuntime 100.8.

void CredentialCache::removeAndRevokeCredential(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.

[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.

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 Credential *credential)

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

bool CredentialCache::setCredential(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().


Feedback on this topic?