Inherits from NSObject
Declared in KGChallengeHandler.h

Overview

A ChallengeHandler is responsible for producing responses to authentication challenges.

When an attempt to access a protected URI is made, the server responsible for serving the resource may respond with authentication challenge, indicating that credentials need be provided before access to the resource is granted. The specific type of challenge is indicated in a HTTP header called “WWW-Authenticate”. This response and that header are converted into a KGChallengeRequest and sent to a registered ChallengeHandler for authentication challenge responses. The KGChallengeResponse credentials generated by a registered challenge handler are included in a replay of the original request to the server, which (assuming the credentials are sufficient) allows access to the resource.

Public subclasses of ChallengeHandler can be loaded and instantiated using KGChallengeHandlers, and registered to handle server challenges for specific URI locations using KGDispatchChallengeHandler register method.

Any challenge responses to requests matching the registered location may be handled by the registered KGChallengeHandler as long as canHandle returns true. In the case where multiple registered challenge handlers could respond to a challenge request, the earliest challenge handler registered at the most specific location matching the protected URI is selected.

Tasks

  • – canHandle:

    Can the presented challenge be potentially handled by this challenge handler?

  • – handle:

    Handle the presented challenge by creating a challenge response or returning nil. This responsibility is usually achieved by using the associated KGLoginHandler to obtain user credentials, and transforming those credentials into a KGChallengeResponse.

    When it is not possible to create a KGChallengeResponse, this method MUST return nil.

Instance Methods

canHandle:

Can the presented challenge be potentially handled by this challenge handler?

- (BOOL)canHandle:(KGChallengeRequest *)challengeRequest

Parameters

challengeRequest

a challenge request object containing a challenge

Return Value

true if this challenge handler could potentially respond meaningfully to the challenge.

Declared In

KGChallengeHandler.h

handle:

Handle the presented challenge by creating a challenge response or returning nil. This responsibility is usually achieved by using the associated KGLoginHandler to obtain user credentials, and transforming those credentials into a KGChallengeResponse.

When it is not possible to create a KGChallengeResponse, this method MUST return nil.

- (KGChallengeResponse *)handle:(KGChallengeRequest *)challengeRequest

Parameters

challengeRequest

a challenge object

Return Value

a challenge response object or nil if no response is possible.

Declared In

KGChallengeHandler.h