Up

# NSURLAuthenticationChallenge class documentation

### Authors

Richard Frith-Macdonald (`frm@gnu.org`)

Date: Generated at 2025-02-13 06:02:40 +0000

Copyright: (C) 2006 Software Foundation, Inc.

### Contents -

1. Software documentation for the NSURLAuthenticationChallenge class
2. Software documentation for the NSURLAuthenticationChallengeSender protocol

# Software documentation for the NSURLAuthenticationChallenge class

## NSURLAuthenticationChallenge : NSObject

> Declared in:
>   Foundation/NSURLAuthenticationChallenge.h

Availability: MacOS-X 10.2.0, Base 1.13.0
Class to represent an authentication challenge and indicate when the challenge is complete.

Instance Variables
Method summary

- -error
- -failureResponse
- -initWithAuthenticationChallenge:sender:
- -initWithProtectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:
- -previousFailureCount
- -proposedCredential
- -protectionSpace
- -sender

### error

- (NSError*) error;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the error with which the reciver was initialised or `nil` if it was not initialised with an error.
The error may indicate the nature of the authentication failure.

### failureResponse

- (NSURLResponse*) failureResponse;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the response with which the receiver was initialised.
This response contains the authentication failure corresponding to this challenge object.
If there was no failure or response, returns `nil`.

### initWithAuthenticationChallenge: sender:

- (id) initWithAuthenticationChallenge: (NSURLAuthenticationChallenge*)challenge sender: (id<NSURLAuthenticationChallengeSender>)sender;
Availability: MacOS-X 10.2.0, Base 1.13.0
Initialises a new challenge by copying information from an old one.

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

- (id) initWithProtectionSpace: (NSURLProtectionSpace*)space proposedCredential: (NSURLCredential*)credential previousFailureCount: (NSInteger)previousFailureCount failureResponse: (NSURLResponse*)response error: (NSError*)error sender: (id<NSURLAuthenticationChallengeSender>)sender;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the receiver initialised in the specified protection space and with the specified credential. The previousFailureCount says how many requests have failed the challenge and response provide information about the last failure (which caused this challenge to be created).
The error provides information about the authentication failure and the sender is the object to receive callbacks.

### previousFailureCount

- (NSInteger) previousFailureCount;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the count of failed authentication attempts.

### proposedCredential

- (NSURLCredential*) proposedCredential;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns a proposed credential to answer the challenge.
If there is no credential available, this returns `nil`.
The credential may come from storage or from the URL itsself.

### protectionSpace

- (NSURLProtectionSpace*) protectionSpace;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the protection space needing authentication.

### sender

- (id<NSURLAuthenticationChallengeSender>) sender;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the sender of the challenge... the object to which callbacks should be made while processing the challenge.

## Instance Variables for NSURLAuthenticationChallenge Class

### _NSURLAuthenticationChallengeInternal

@protected void* _NSURLAuthenticationChallengeInternal;
Availability: MacOS-X 10.2.0, Base 1.13.0
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

# Software documentation for the NSURLAuthenticationChallengeSender protocol

## NSURLAuthenticationChallengeSender

> Declared in:
>   Foundation/NSURLAuthenticationChallenge.h

> Conforms to:
>   NSObject

Availability: MacOS-X 10.2.0, Base 1.13.0
A challenge sender (usually an NSURLProtocol subclass handling a connection/download) provides these methods to permit a client to control authentication.
Method summary

- -cancelAuthenticationChallenge:
- -continueWithoutCredentialForAuthenticationChallenge:
- -useCredential:forAuthenticationChallenge:

### cancelAuthenticationChallenge:

- (void) cancelAuthenticationChallenge: (NSURLAuthenticationChallenge*)challenge;
Availability: MacOS-X 10.2.0, Base 1.13.0
Cancels the authenticatiopn challenge, ensuring that the load operation will fail to retrieve data, completing with only the response headers containing the challenge having been read from the server.

### continueWithoutCredentialForAuthenticationChallenge:

- (void) continueWithoutCredentialForAuthenticationChallenge: (NSURLAuthenticationChallenge*)challenge;
Availability: MacOS-X 10.2.0, Base 1.13.0
Tells the sender to continue the load without providing a new credential for it to use... if the challenge already had a proposed credential, the sender may elect to use it.

### useCredential: forAuthenticationChallenge:

- (void) useCredential: (NSURLCredential*)credential forAuthenticationChallenge: (NSURLAuthenticationChallenge*)challenge;
Availability: MacOS-X 10.2.0, Base 1.13.0
Tells the sender to continue the load using the new credential provided by this method.

Up