Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- + (NSString*)passwordForProxy:(NSString*)proxy port:(int)port user:(NSString*)user protocol:(SecProtocolType)protocol {
- void *password;
- UInt32 passwordLength = 0;
- NSString *passwordStr = nil;
- OSStatus status = SecKeychainFindInternetPassword(NULL,
- (int)[proxy length], [proxy UTF8String], 0, NULL,
- (int)[user length], [user UTF8String], 0, NULL,
- port, protocol,
- kSecAuthenticationTypeAny,
- &passwordLength, &password, NULL);
- if (status == noErr) {
- if (password) {
- passwordStr = [[[NSString alloc] initWithBytes:password length:passwordLength encoding:NSUTF8StringEncoding] autorelease];
- SecKeychainItemFreeContent(NULL, password);
- }
- }
- return passwordStr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement