• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Ignoring credentials in shared NSURLCredentialStorage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ignoring credentials in shared NSURLCredentialStorage


  • Subject: Re: Ignoring credentials in shared NSURLCredentialStorage
  • From: Dave Dribin <email@hidden>
  • Date: Mon, 14 May 2007 09:54:37 -0500

On May 11, 2007, at 11:36 AM, Becky Willrich wrote:
- You can try using poseAs: to insert your own NSURLCredentialStorage class in place of the default one; it could always fail to find credentials, or maybe call through to the real NSURLCredentialStorage in all cases except the ones you want to intercept. If you do this, you are tinkering with the runtime, so be careful - you'll want to make sure and implement forward:: to send any unrecognized messages through to a "real" NSURLCredentialStorage. I'm not a runtime expert, so I don't know what all the gotchas are, just that there are more than a few.

I figured out how to do it with a category (see below). You just need to call initializeDefaultCredentials() early on, in main() or an +initialize method. The only downside is a category can only override a method and cannot call the original NSURLCredentialStorage methods. You'd have to do class posing or method swizzling to do that. Also, I didn't have to override credentialsForProtectionSpace: and setCredential:forProtectionSpace:, as I didn't see them being called in my app.


-Dave

-----
static NSMutableDictionary * sDefaultCredentials;

void initializeDefaultCredentials()
{
    sDefaultCredentials = [[NSMutableDictionary alloc] init];;
}

@implementation NSURLCredentialStorage  (SharedOverride)

- (NSURLCredential *) defaultCredentialForProtectionSpace: (NSURLProtectionSpace *) protectionSpace;
{
return [sDefaultCredentials objectForKey: protectionSpace];
}


- (void) setDefaultCredential: (NSURLCredential *) credential
forProtectionSpace: (NSURLProtectionSpace *) protectionSpace;
{
[sDefaultCredentials setObject: credential forKey: protectionSpace];
}


@end
-----
_______________________________________________
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


References: 
 >Ignoring credentials in shared NSURLCredentialStorage (From: Dave Dribin <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Jerry Krinock <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Dave Dribin <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Jerry Krinock <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Dave Dribin <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Jerry Krinock <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Dave Dribin <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Jerry Krinock <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Dave Dribin <email@hidden>)
 >Re: Ignoring credentials in shared NSURLCredentialStorage (From: Becky Willrich <email@hidden>)

  • Prev by Date: Re: CFReadStreamRead doesn't read data over SSL (HTTPS) server
  • Next by Date: Cable disconnected event
  • Previous by thread: Re: Ignoring credentials in shared NSURLCredentialStorage
  • Next by thread: CFReadStreamRead doesn't read data over SSL (HTTPS) server
  • Index(es):
    • Date
    • Thread