KGDispatchChallengeHandler Class Reference
| Inherits from | KGChallengeHandler : NSObject |
| Declared in | KGDispatchChallengeHandler.h |
Overview
A DispatchChallengeHandler is responsible for dispatching challenge requests to appropriate challenge handlers when challenges arrive from specific URI locations in challenge responses.
This allows clients to use specific challenge handlers to handle specific types of challenges at different URI locations.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. -
– registerChallengeHandler:challengeHandler:Register a challenge handler to respond to challenges at one or more locations.
When a challenge response is received for a protected URI, thelocationDescriptionmatches against elements of the protected URI; if a match is found, one consults the challenge handler(s) registered at thatlocationDescriptionto find a challenge handler suitable to respond to the challenge. AlocationDescriptioncomprises a username, password, host, port and paths, any of which can be wild-carded with the “*” character to match any number of request URIs. If no port is explicitly mentioned in alocationDescription, a default port will be inferred based on the scheme mentioned in the location description, according to the following table:
The protocol scheme (e.g. http or ws) if present inscheme default port Sample locationDescription http 80 foo.example.com or http://foo.example.comws 80 foo.example.com or ws://foo.example.com https 443 https://foo.example.comwss 443 wss://foo.example.com locationDescriptionwill not be used to matchlocationDescriptionwith the protected URI, because authentication challenges are implemented on top of one of the HTTP/s protocols always, whether one is initiating web socket connections or regular HTTP connections. That is to say for example, the locationDescription"foo.example.com"matches both URIshttp://foo.example.comandws://foo.example.com. Some examples oflocationDescriptionvalues with wildcards are:*/ — matches all requests to any host on port 80 (default port), with no user info or path specified.*.hostname.com:8000— matches all requests to port 8000 on any sub-domain ofhostname.com, but nothostname.comitself.server.hostname.com:*/*— matches all requests to a particular server on any port on any path but not the empty path.
-
– unregisterChallengeHandler:challengeHandler:If the provided challengeHandler is registered at the provided location, clear that association such that any future challenge requests matching the location will never be handled by the provided challenge handler.
If no such location or challengeHandler registration exists, this method silently succeeds.
Instance Methods
canHandle:
Can the presented challenge be potentially handled by this challenge handler?
- (BOOL)canHandle:(KGChallengeRequest *)challengeRequestParameters
- 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.hhandle:
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 *)challengeRequestParameters
- challengeRequest
a challenge object
Return Value
a challenge response object or nil if no response is possible.
Declared In
KGChallengeHandler.hregisterChallengeHandler:challengeHandler:
Register a challenge handler to respond to challenges at one or more locations.
When a challenge response is received for a protected URI, thelocationDescription
matches against elements of the protected URI; if a match is found, one
consults the challenge handler(s) registered at that locationDescription to find
a challenge handler suitable to respond to the challenge.
A locationDescription comprises a username, password, host, port and paths,
any of which can be wild-carded with the “*” character to match any number of request URIs.
If no port is explicitly mentioned in a locationDescription, a default port will be inferred
based on the scheme mentioned in the location description, according to the following table:
| scheme | default port | Sample locationDescription |
|---|---|---|
| http | 80 | foo.example.com or http://foo.example.com |
| ws | 80 | foo.example.com or ws://foo.example.com |
| https | 443 | https://foo.example.com |
| wss | 443 | wss://foo.example.com |
locationDescription will not be used to
match locationDescription with the protected URI, because authentication challenges are
implemented on top of one of the HTTP/s protocols always, whether one is initiating web socket
connections or regular HTTP connections. That is to say for example, the locationDescription "foo.example.com"
matches both URIs http://foo.example.com and ws://foo.example.com.
Some examples of locationDescription values with wildcards are:
*/ — matches all requests to any host on port 80 (default port), with no user info or path specified.*.hostname.com:8000— matches all requests to port 8000 on any sub-domain ofhostname.com, but nothostname.comitself.server.hostname.com:*/*— matches all requests to a particular server on any port on any path but not the empty path.
- (KGDispatchChallengeHandler *)registerChallengeHandler:(NSString *)locationDescription challengeHandler:(KGChallengeHandler *)challengeHandlerParameters
- locationDescription
the (possibly wild-carded) location(s) at which to register a handler.
- challengeHandler
the challenge handler to register at the location(s).
Return Value
a reference to this challenge handler for chained calls
Declared In
KGDispatchChallengeHandler.hunregisterChallengeHandler:challengeHandler:
If the provided challengeHandler is registered at the provided location, clear that association such that any future challenge requests matching the location will never be handled by the provided challenge handler.
If no such location or challengeHandler registration exists, this method silently succeeds.- (KGChallengeHandler *)unregisterChallengeHandler:(NSString *)locationDescription challengeHandler:(KGChallengeHandler *)challengeHandlerParameters
- locationDescription
the exact location description at which the challenge handler was originally registered
- challengeHandler
the challenge handler to de-register.
Return Value
a reference to this object for chained call support
Declared In
KGDispatchChallengeHandler.h