NSURLAuthenticationChallenge Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in iOS 2.0 and later.
Companion guide
Declared in
NSURLAuthenticationChallenge.h
Related sample code

Overview

NSURLAuthenticationChallenge encapsulates a challenge from a server requiring authentication from the client.

Tasks

Creating an Authentication Challenge Instance

Getting Authentication Challenge Properties

Instance Methods

error

Returns the NSError object representing the last authentication failure.

- (NSError *)error
Discussion

This method returns nil if the protocol doesn’t use errors to indicate an authentication failure.

Availability
  • Available in iOS 2.0 and later.
Declared In
NSURLAuthenticationChallenge.h

failureResponse

Returns the NSURLResponse object representing the last authentication failure.

- (NSURLResponse *)failureResponse
Discussion

This method will return nil if the protocol doesn’t use responses to indicate an authentication failure.

Availability
  • Available in iOS 2.0 and later.
See Also
Declared In
NSURLAuthenticationChallenge.h

initWithAuthenticationChallenge:sender:

Returns an initialized NSURLAuthenticationChallenge object copying the properties from challenge, and setting the authentication sender to sender.

- (id)initWithAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge sender:(id < NSURLAuthenticationChallengeSender >)sender
Availability
  • Available in iOS 2.0 and later.
Declared In
NSURLAuthenticationChallenge.h

initWithProtectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:

Returns an initialized NSURLAuthenticationChallenge object for the specified space using the credential, or nil if there is no proposed credential.

- (id)initWithProtectionSpace:(NSURLProtectionSpace *)space proposedCredential:(NSURLCredential *)credential previousFailureCount:(NSInteger)count failureResponse:(NSURLResponse *)response error:(NSError *)error sender:(id < NSURLAuthenticationChallengeSender >)sender
Discussion

The previous failure count is set to count. The response should contain the NSURLResponse for the authentication failure, or nil if it is not applicable to the challenge. The error should contain the NSError for the authentication failure, or nil if it is not applicable to the challenge. The object that initiated the authentication challenge is set to sender.

Availability
  • Available in iOS 2.0 and later.
Declared In
NSURLAuthenticationChallenge.h

previousFailureCount

Returns the receiver’s count of failed authentication attempts.

- (NSInteger)previousFailureCount
Availability
  • Available in iOS 2.0 and later.
Declared In
NSURLAuthenticationChallenge.h

proposedCredential

Returns the proposed credential for this challenge.

- (NSURLCredential *)proposedCredential
Discussion

This method will return nil if there is no default credential for this challenge.

If you have previously attempted to authenticate and failed, this method returns the most recent failed credential.

If the proposed credential is not nil and returns YES when sent the message hasPassword, then the credential is ready to use as-is. If the proposed credential returns NO for hasPassword, then the credential provides a default user name and the client must prompt the user for a corresponding password.

Availability
  • Available in iOS 2.0 and later.
Declared In
NSURLAuthenticationChallenge.h

protectionSpace

Returns the receiver’s protection space.

- (NSURLProtectionSpace *)protectionSpace
Availability
  • Available in iOS 2.0 and later.
Related Sample Code
Declared In
NSURLAuthenticationChallenge.h

sender

Returns the receiver’s sender.

Discussion

The sender should be sent a useCredential:forAuthenticationChallenge:, continueWithoutCredentialForAuthenticationChallenge: or cancelAuthenticationChallenge: when the client is finished processing the authentication challenge.

Availability
  • Available in iOS 2.0 and later.
Declared In
NSURLAuthenticationChallenge.h

Did this document help you? Yes It's good, but... Not helpful...