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 protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to