An object that manages the credential storage.


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 setDefaultCredential(URLCredential, for: URLProtectionSpace)

Sets the default credential for a specified protection space.

Adding and Removing Credentials

func remove(URLCredential, for: URLProtectionSpace)

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

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

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

func set(URLCredential, for: URLProtectionSpace)

Adds credential to the credential storage for the specified protectionSpace.

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.



static let NSURLCredentialStorageChanged: NSNotification.Name

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


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.