Questions on when credentials are used in NSURLSessionDownloadTask
Questions on when credentials are used in NSURLSessionDownloadTask
- Subject: Questions on when credentials are used in NSURLSessionDownloadTask
- From: Daryle Walker <email@hidden>
- Date: Sat, 18 Apr 2015 22:36:14 -0400
I added command-line options to include a username and password. I use them via a newly-added callback method:
> - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
> didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
> completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler {
> completionHandler(challenge.previousFailureCount ? NSURLSessionAuthChallengeRejectProtectionSpace : NSURLSessionAuthChallengeUseCredential, self.usernameAndPassword);
> }
Where the “usernameAndPassword” was created with “[NSURLCredential credentialWithUser:cliUserName password:cliPassWord persistence:NSURLCredentialPersistenceForSession]”.
I was originally going to go with adding the username/password credential inside the session configuration’s credential store, but that store is sub-divided into protection spaces. I don’t really get what these protection spaces are, and my tool’s model should have the username & password be applicable to any URL submitted, and therefore any potential protection space. Will I get into problems if I keep the callback as above?
I’m thinking to adding an option of using the system credential store. Said option would set the default shared system store as the session configuration’s credential store. If I do so, where are they used in the download process? Are they tried before my callback would try my username/password?
Also, I don’t have a session-level challenge handler, so the task-level one above will be called then too. Will using my username/password credential cause any problems there?
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden