public void ApplyCredentialDictionary(CFHTTPAuthentication auth, NetworkCredential credential) { var keys = new NSString [3]; var values = new CFString [3]; keys [0] = _AuthenticationUsername; keys [1] = _AuthenticationPassword; keys [2] = _AuthenticationAccountDomain; values [0] = (CFString)credential.UserName; values [1] = (CFString)credential.Password; values [2] = credential.Domain != null ? (CFString)credential.Domain : null; var dict = CFDictionary.FromObjectsAndKeys(values, keys); try { CFStreamError error; var ok = CFHTTPMessageApplyCredentialDictionary( Handle, auth.Handle, dict.Handle, out error); if (ok) { return; } throw GetException((ErrorHTTPAuthentication)error.code); } finally { dict.Dispose(); values [0].Dispose(); values [1].Dispose(); if (values [2] != null) { values [2].Dispose(); } } }
public void ApplyCredentials(CFHTTPAuthentication auth, NetworkCredential credential) { if (auth.RequiresAccountDomain) { ApplyCredentialDictionary(auth, credential); return; } var username = new CFString(credential.UserName); var password = new CFString(credential.Password); try { CFStreamError error; var ok = CFHTTPMessageApplyCredentials( Handle, auth.Handle, username.Handle, password.Handle, out error); if (!ok) { throw GetException((ErrorHTTPAuthentication)error.code); } } finally { username.Dispose(); password.Dispose(); } }
protected override void Dispose (bool disposing) { if (disposing) { if (auth != null) { auth.Dispose (); auth = null; } } base.Dispose (disposing); }
void FindAuthenticationObject (CFHTTPMessage response) { if (auth != null) { if (auth.IsValid) return; auth.Dispose (); auth = null; } if (auth == null) { auth = CFHTTPAuthentication.CreateFromResponse (response); if (auth == null) throw new HttpRequestException ("Failed to create CFHTTPAuthentication"); } if (!auth.IsValid) throw new HttpRequestException ("Failed to validate CFHTTPAuthentication"); }
public void ApplyCredentialDictionary (CFHTTPAuthentication auth, NetworkCredential credential) { var keys = new NSString [3]; var values = new CFString [3]; keys [0] = _AuthenticationUsername; keys [1] = _AuthenticationPassword; keys [2] = _AuthenticationAccountDomain; values [0] = (CFString)credential.UserName; values [1] = (CFString)credential.Password; values [2] = credential.Domain != null ? (CFString)credential.Domain : null; var dict = CFDictionary.FromObjectsAndKeys (values, keys); try { CFStreamError error; var ok = CFHTTPMessageApplyCredentialDictionary ( Handle, auth.Handle, dict.Handle, out error); if (ok) return; throw GetException ((ErrorHTTPAuthentication)error.code); } finally { dict.Dispose (); values [0].Dispose (); values [1].Dispose (); if (values [2] != null) values [2].Dispose (); } }
public void ApplyCredentials (CFHTTPAuthentication auth, NetworkCredential credential) { if (auth.RequiresAccountDomain) { ApplyCredentialDictionary (auth, credential); return; } var username = new CFString (credential.UserName); var password = new CFString (credential.Password); try { CFStreamError error; var ok = CFHTTPMessageApplyCredentials ( Handle, auth.Handle, username.Handle, password.Handle, out error); if (!ok) throw GetException ((ErrorHTTPAuthentication)error.code); } finally { username.Dispose (); password.Dispose (); } }