Class

URLCredentialStorage

An object that manages the credential storage.

Topics

Getting the Credential Storage

class var shared: URLCredentialStorage

Returns the shared URL credential storage object.

Getting and Setting Default Credentials

func defaultCredential(for: URLProtectionSpace)

Returns the default credential for the specified protectionSpace.

func getDefaultCredential(for: URLProtectionSpace, task: URLSessionTask, completionHandler: (URLCredential?) -> Void)

Gets the default credential for the specified protection space and passes it to the provided completion handler.

func setDefaultCredential(URLCredential, for: URLProtectionSpace)

Sets the default credential for a specified protection space.

func setDefaultCredential(URLCredential, for: URLProtectionSpace, task: URLSessionTask)

Sets the default credential for a specified protection space and task.

Adding and Removing Credentials

func remove(URLCredential, for: URLProtectionSpace)

Removes the specified credential from the credential storage for the specified protection space.

func remove(URLCredential, for: URLProtectionSpace, options: [String : Any]? = nil)

Removes the specified credential from the credential storage for the specified protection space using the given options.

func remove(URLCredential, for: URLProtectionSpace, options: [String : Any]? = nil, task: URLSessionTask)

Removes the specified credential from the credential storage for the specified protection space and task, using the given options.

func set(URLCredential, for: URLProtectionSpace)

Adds a credential to the credential storage for the specified protection space.

func set(URLCredential, for: URLProtectionSpace, task: URLSessionTask)

Adds a credential to the credential storage for the specified protection space and task.

Retrieving Credentials

var allCredentials: [URLProtectionSpace : [String : URLCredential]]

The credentials for all available protection spaces.

func credentials(for: URLProtectionSpace)

Returns a dictionary containing the credentials for the specified protection space.

func getCredentials(for: URLProtectionSpace, task: URLSessionTask, completionHandler: ([String : URLCredential]?) -> Void)

Gets a dictionary containing the credentials for the specified protection space and task, and passes the dictionary to the provided completion handler.

Constants

Notifications

static let NSURLCredentialStorageChanged: NSNotification.Name

This notification is posted when the set of stored credentials changes.

Relationships

Inherits From

Conforms To

See Also

Authentication and Credentials

class URLAuthenticationChallenge

A challenge from a server requiring authentication from the client.

class URLCredential

An authentication credential consisting of authentication information specific to the type of credential and the type of persistent storage to use, if any.

class URLProtectionSpace

A server or an area on a server, commonly referred to as a realm, that requires authentication.