Ticket #635: httpauth.patch

File httpauth.patch, 3.7 KB (added by technimad, 2 years ago)
  • Classes/BlogDataManager.m

     
    51375137        //call the keychain util's getPassword function, passing in the userName and blogURL we got from the method that called this one 
    51385138        // and set our blank string equal to the result of this call 
    51395139        NSError *anError = nil; 
     5140        blogURL = [blogURL stringByReplacingOccurrencesOfString:@"https://" withString:@""]; 
    51405141        keychainPWD = [SFHFKeychainUtils getPasswordForUsername : userName andServiceName : blogURL error:&anError]; 
    51415142        //return the resulting string to the calling function as a string 
    51425143        //NSLog(@"Inside getBlogPasswordFromKeychainWithUsername... keychainPWD is %@", keychainPWD); 
  • Classes/AddSiteViewController.m

     
    522522                        // Grab our XML-RPC url 
    523523                        ASIHTTPRequest *htmlRequest = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:url]]; 
    524524                        [htmlRequest setShouldPresentCredentialsBeforeChallenge:NO]; 
     525                        [htmlRequest setValidatesSecureCertificate:NO]; 
    525526                        [htmlRequest setShouldPresentAuthenticationDialog:YES]; 
    526527                        [htmlRequest setUseKeychainPersistence:YES]; 
    527528                        [htmlRequest setDelegate:self]; 
     
    742743                                                                                                                 andBlogURL:[self.url stringByReplacingOccurrencesOfRegex:@"http(s?)://" withString:@""]]; 
    743744         
    744745        if([authEnabled isEqualToNumber:[NSNumber numberWithInt:1]]) { 
    745                 [[BlogDataManager sharedDataManager] updatePasswordInKeychain:authPassword 
     746                [[BlogDataManager sharedDataManager] saveBlogPasswordToKeychain:authPassword 
    746747                                                                                                                  andUserName:authUsername 
    747748                                                                                                                   andBlogURL:authBlogURL]; 
    748749        } 
  • Classes/WPMediaUploader.h

     
    2020        UILabel *messageLabel; 
    2121        UIProgressView *progressView; 
    2222    UIButton *stopButton; 
     23        BlogDataManager *dm; 
    2324         
    2425        MediaType mediaType; 
    2526        MediaOrientation orientation; 
  • Classes/WPMediaUploader.m

     
    148148        else if(self.mediaType == kVideo) 
    149149                [self updateStatus:@"Uploading video..."]; 
    150150         
     151         
     152        dm = [BlogDataManager sharedDataManager]; 
     153        BOOL httpAuthEnabled = [[dm.currentBlog objectForKey:@"authEnabled"] boolValue]; 
     154        NSString *httpAuthUsername = [dm.currentBlog valueForKey:@"authUsername"]; 
     155        NSString *httpAuthPassword = [dm getHTTPPasswordFromKeychainInContextOfCurrentBlog:dm.currentBlog]; 
     156         
    151157        ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:self.xmlrpcURL]]; 
    152158        [request setDelegate:self]; 
    153159        [request setShouldStreamPostDataFromDisk:YES]; 
    154160        [request appendPostDataFromFile:self.localEncodedURL]; 
    155161        [request setUploadProgressDelegate:self.progressView]; 
    156162        [request setTimeOutSeconds:600]; 
     163        [request setValidatesSecureCertificate:NO]; 
     164        if (httpAuthEnabled) { 
     165                [request setUsername:httpAuthUsername]; 
     166                [request setPassword:httpAuthPassword]; 
     167        } 
    157168        [request startAsynchronous]; 
    158169} 
    159170 
     
    473484 
    474485- (void)connection:(NSURLConnection *)conn didFailWithError:(NSError *)error { 
    475486        [self updateStatus:@"Upload failed. Please try again."]; 
    476         NSLog(@"connection failed: %@", [error localizedDescription]); 
     487        NSLog(@"connection failed: %@", [error localizedDescription]);   
    477488         
    478489        if(self.mediaType == kImage) 
    479490                [self stopWithNotificationName:@"ImageUploadFailed"];