ArcGIS Runtime SDK for iOS: AGSCredential Class Reference
ArcGIS Runtime SDK for iOS  100.15
AGSCredential Class Reference

Description

Represents an credential to access a secured resource.

Instances of this class represent a credential object to access a secured ArcGIS resource. The resource could be secured using ArcGIS tokens or HTTP (basic or digest) authentication.

@define{AGSCredential.h, ArcGIS}

Since
100
Inheritance diagram for AGSCredential:

Instance Methods

(nullable NSString *) - authenticatingHost
 
(nullable instancetype) - initWithIdentityCertificateData:password:
 
(instancetype) - initWithIdentityRef:
 
(instancetype) - initWithToken:referer:
 
(instancetype) - initWithUser:password:
 

Class Methods

(instancetype) + credentialWithUser:password:
 
(nullable NSArray< id > *) + identitiesForProtectionSpace:
 
(nullable SecIdentityRef) + importCertificateData:password:overwrite:error:
 
(OSStatus) + removeIdentityFromKeychain:
 

Properties

BOOL cachingEnabled
 
SecIdentityRef identity
 
NSData * identityCertificateData
 
NSString * identityCertificatePassword
 
NSString * password
 
NSString * referer
 
NSString * token
 
NSURL * tokenUrl
 
NSString * username
 

Method Documentation

◆ authenticatingHost

- (nullable NSString*) authenticatingHost

Returns the host (including port number) that a username/password will be sent to for authentication. This is useful to display to a user when prompting them for credentials when a resource fails to load.

Since
100

◆ credentialWithUser:password:

+ (instancetype) credentialWithUser: (NSString *)  username
password: (NSString *)  password 

Initialize an AGSCredential object.

Parameters
usernameThe username of user attempting to access secured resource.
passwordThe password of user attempting to access secured resource.
Returns
A new, initialized AGSCredential.
Since
100

◆ identitiesForProtectionSpace:

+ (nullable NSArray<id>*) identitiesForProtectionSpace: (nullable NSURLProtectionSpace *)  protectionSpace

Returns an array of SecIdentityRef objects that can be used to authenticate against the specified NSURLProtectionSpace. Pass nil for the protectionSpace to return all identities available to the application.

Parameters
protectionSpaceThe protection space in which to retrieve identities for.
Returns
An array of SecIdentityRef objects that can be used for client certificate authentication.
Since
100
Deprecated:
100.8. No direct replacement. Instead of importing your certificate into the keychain, you can use continueWithDefaultHandling (AGSAuthenticationChallenge) to respond to the authentication challenge which allows the user to browse for the certificate on the device. Alternatively, you can choose to handle the challenge yourself and display custom UI for picking a certificate, in which case use the new init method initWithIdentityCertificateData:password: to create the credential and respond to the challenge.

◆ importCertificateData:password:overwrite:error:

+ (nullable SecIdentityRef) importCertificateData: (NSData *)  data
password: (NSString *)  password
overwrite: (BOOL)  overwrite
error: (NSError **)  error 

Imports the certificate data into the keychain for the running application. This certificate can be retrieved from any application that shares the same keychain access group.

Parameters
dataThe data representing the client certificate.
passwordThe password to be used to access the certificate.
overwriteIf YES, this method will delete an existing certificate that matches and then re-add the certificate represented by data.
errorReturned if an error is encountered while importing the data.
Returns
An SecIdentityRef object representing the imported data.
Since
100
Deprecated:
100.8. No direct replacement. Instead of importing your certificate into the keychain, you can use continueWithDefaultHandling (AGSAuthenticationChallenge) to respond to the authentication challenge which allows the user to browse for the certificate on the device. Alternatively, you can choose to handle the challenge yourself and display custom UI for picking a certificate, in which case use the new init method initWithIdentityCertificateData:password: to create the credential and respond to the challenge.

◆ initWithIdentityCertificateData:password:

- (nullable instancetype) initWithIdentityCertificateData: (NSData *)  data
password: (NSString *)  password 

Initialize an AGSCredential object with the certificate data and password.

Parameters
dataThe data representing the client certificate.
passwordThe password to be used to access the certificate data.
Returns
A new, initialized AGSCredential or nil if unable to create SecIdentityRef from provided data and password.
Since
100.8

◆ initWithIdentityRef:

- (instancetype) initWithIdentityRef: (SecIdentityRef)  identityRef

Initialize an AGSCredential object with an SecIdentityRef.

Parameters
identityRefThe identity in which to initialize the credential object.
Returns
A new, initialized AGSCredential.
Since
100

◆ initWithToken:referer:

- (instancetype) initWithToken: (NSString *)  token
referer: (nullable NSString *)  referer 

Initialize an AGSCredential object with a long-lived token and referer. This token will be used to access the secured resource.

Parameters
tokenThe long-lived token to initialize the credential object.
refererThe referer to be sent along with token in the request.
Returns
A new, initialized AGSCredential.
Since
100

◆ initWithUser:password:

- (instancetype) initWithUser: (NSString *)  username
password: (NSString *)  password 

Initialize an AGSCredential object.

Parameters
usernameThe username of user attempting to access secured resource.
passwordThe password of user attempting to access secured resource.
Returns
A new, initialized AGSCredential.
Since
100

◆ removeIdentityFromKeychain:

+ (OSStatus) removeIdentityFromKeychain: (SecIdentityRef)  identityRef

Removes an identity and its certificates from the keychain.

Parameters
identityRefThe identity to remove from the keychain.
Returns
An OSStatus result code indicating success or failure. See SecBase.h for for possible values.
Since
100
Deprecated:
100.8. No direct replacement. Instead of importing your certificate into the keychain, you can use continueWithDefaultHandling (AGSAuthenticationChallenge) to respond to the authentication challenge which allows the user to browse for the certificate on the device. Alternatively, you can choose to handle the challenge yourself and display custom UI for picking a certificate, in which case use the new init method initWithIdentityCertificateData:password: to create the credential and respond to the challenge.

Property Documentation

◆ cachingEnabled

- (BOOL) cachingEnabled
readwritenonatomicassign

Specifies whehter credential can be added to the credential cache. Default is YES.

Since
100

◆ identity

- (SecIdentityRef) identity
readwritenonatomicassign

The identity associated with this credential.

Since
100

◆ identityCertificateData

- (NSData*) identityCertificateData
readwritenonatomiccopy

The data representing the client certificate.

Since
100.8

◆ identityCertificatePassword

- (NSString*) identityCertificatePassword
readwritenonatomiccopy

The password to be used to access the identityCertificateData.

Since
100.8

◆ password

- (NSString*) password
readwritenonatomiccopy

Password used to access secured resource or retrieve a token.

Since
100

◆ referer

- (NSString*) referer
readnonatomiccopy

A string representing the referer for which the long-lived token was generated.

Since
100

◆ token

- (NSString*) token
readwritenonatomiccopy

Generated by the server from a username/password combination.

Since
100

◆ tokenUrl

- (NSURL*) tokenUrl
readwritenonatomicstrong

Url to the token service.

Since
100

◆ username

- (NSString*) username
readwritenonatomiccopy

Username used to access secured resource or retrieve a token.

Since
100