Revision: 18359
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18359&view=rev
Author:   hofman
Date:     2012-01-03 13:39:15 +0000 (Tue, 03 Jan 2012)
Log Message:
-----------
do not hash password in password controller, do hashing in place

Modified Paths:
--------------
    trunk/bibdesk/BDSKPasswordController.m
    trunk/bibdesk/BDSKSharingClient.m

Modified: trunk/bibdesk/BDSKPasswordController.m
===================================================================
--- trunk/bibdesk/BDSKPasswordController.m      2012-01-03 13:18:25 UTC (rev 
18358)
+++ trunk/bibdesk/BDSKPasswordController.m      2012-01-03 13:39:15 UTC (rev 
18359)
@@ -40,7 +40,6 @@
 
 #import "BDSKPasswordController.h"
 #import <Security/Security.h>
-#import "NSData_BDSKExtensions.h"
 
 
 @implementation BDSKPasswordController
@@ -110,7 +109,7 @@
     
     if (password == nil)
         return nil;
-    return [[password dataUsingEncoding:NSUTF8StringEncoding] sha1Signature];
+    return [password dataUsingEncoding:NSUTF8StringEncoding];
 }
 
 + (NSData *)runModalPanelForKeychainServiceName:(NSString *)name 
message:(NSString *)status {

Modified: trunk/bibdesk/BDSKSharingClient.m
===================================================================
--- trunk/bibdesk/BDSKSharingClient.m   2012-01-03 13:18:25 UTC (rev 18358)
+++ trunk/bibdesk/BDSKSharingClient.m   2012-01-03 13:39:15 UTC (rev 18359)
@@ -385,33 +385,34 @@
 // this can be called from any thread
 - (NSData *)authenticationDataForComponents:(NSArray *)components;
 {
-    OSMemoryBarrier();
-    if(flags.needsAuthentication == 0)
-        return [[NSData data] sha1Signature];
-    
     NSData *password = nil;
-    OSAtomicCompareAndSwap32Barrier(1, 0, &flags.canceledAuthentication);
     
     OSMemoryBarrier();
-    if(flags.authenticationFailed == 0)
-        password = [[BDSKPasswordController 
passwordForKeychainServiceName:[[self class] 
keychainServiceNameWithComputerName:[service name]]] sha1Signature];
-    
-    if(password == nil && [self shouldKeepRunning]){   
+    if(flags.needsAuthentication == 0) {
+        password = [NSData data];
+    } else {
+        OSAtomicCompareAndSwap32Barrier(1, 0, &flags.canceledAuthentication);
         
-        // run the prompt on the main thread
-        password = [([NSThread isMainThread] ? self : [self 
serverOnMainThread]) runPasswordPrompt];
+        OSMemoryBarrier();
+        if(flags.authenticationFailed == 0)
+            password = [BDSKPasswordController 
passwordForKeychainServiceName:[[self class] 
keychainServiceNameWithComputerName:[service name]]];
         
-        // retry from the keychain
-        if (password){
-            // assume we succeeded; the exception handler for the connection 
will change it back if we fail again
-            OSAtomicCompareAndSwap32Barrier(1, 0, &flags.authenticationFailed);
-        }else{
-            OSAtomicCompareAndSwap32Barrier(0, 1, 
&flags.canceledAuthentication);
+        if(password == nil && [self shouldKeepRunning]){   
+            
+            // run the prompt on the main thread
+            password = [([NSThread isMainThread] ? self : [self 
serverOnMainThread]) runPasswordPrompt];
+            
+            // retry from the keychain
+            if (password){
+                // assume we succeeded; the exception handler for the 
connection will change it back if we fail again
+                OSAtomicCompareAndSwap32Barrier(1, 0, 
&flags.authenticationFailed);
+            }else{
+                OSAtomicCompareAndSwap32Barrier(0, 1, 
&flags.canceledAuthentication);
+            }
         }
     }
-    
     // doc says we're required to return empty NSData instead of nil
-    return password ?: [NSData data];
+    return [password sha1Signature] ?: [NSData data];
 }
 
 // monitor the TXT record in case the server changes password requirements

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to