Advertisement
Guest User

Untitled

a guest
May 26th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. + (NSString*)passwordForProxy:(NSString*)proxy port:(int)port user:(NSString*)user protocol:(SecProtocolType)protocol {
  2. void *password;
  3. UInt32 passwordLength = 0;
  4. NSString *passwordStr = nil;
  5.  
  6. OSStatus status = SecKeychainFindInternetPassword(NULL,
  7. (int)[proxy length], [proxy UTF8String], 0, NULL,
  8. (int)[user length], [user UTF8String], 0, NULL,
  9. port, protocol,
  10. kSecAuthenticationTypeAny,
  11. &passwordLength, &password, NULL);
  12.  
  13. if (status == noErr) {
  14. if (password) {
  15. passwordStr = [[[NSString alloc] initWithBytes:password length:passwordLength encoding:NSUTF8StringEncoding] autorelease];
  16. SecKeychainItemFreeContent(NULL, password);
  17. }
  18. }
  19.  
  20. return passwordStr;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement