Revision: 21840
http://sourceforge.net/p/bibdesk/svn/21840
Author: hofman
Date: 2018-02-07 20:09:24 +0000 (Wed, 07 Feb 2018)
Log Message:
-----------
remove old password methods
Modified Paths:
--------------
trunk/bibdesk/BDSKPasswordController.h
trunk/bibdesk/BDSKPasswordController.m
Modified: trunk/bibdesk/BDSKPasswordController.h
===================================================================
--- trunk/bibdesk/BDSKPasswordController.h 2018-02-07 19:48:45 UTC (rev
21839)
+++ trunk/bibdesk/BDSKPasswordController.h 2018-02-07 20:09:24 UTC (rev
21840)
@@ -52,12 +52,6 @@
+ (NSData *)runModalPanelForKeychainService:(NSString *)service
account:(NSString *)account name:(NSString *)aName message:(NSString *)status;
-+ (NSData *)passwordForKeychainServiceName:(NSString *)name;
-
-+ (BOOL)addOrModifyPassword:(NSString *)password
forKeychainServiceName:(NSString *)name;
-
-+ (NSData *)runModalPanelForKeychainServiceName:(NSString *)name
message:(NSString *)status;
-
- (IBAction)buttonAction:(id)sender;
@end
Modified: trunk/bibdesk/BDSKPasswordController.m
===================================================================
--- trunk/bibdesk/BDSKPasswordController.m 2018-02-07 19:48:45 UTC (rev
21839)
+++ trunk/bibdesk/BDSKPasswordController.m 2018-02-07 20:09:24 UTC (rev
21840)
@@ -172,86 +172,6 @@
return [pwc runModalForKeychainService:service account:account name:name
message:status];
}
-+ (NSData *)passwordForKeychainServiceName:(NSString *)name {
- // use the service name to get password from keychain and hash it with
sha1 for comparison purposes
- OSStatus err;
-
- const char *nameCString = [name UTF8String];
- void *password = NULL;
- UInt32 passwordLength = 0;
- NSData *pwData = nil;
-
- err = SecKeychainFindGenericPassword(NULL, strlen(nameCString),
nameCString, 0, NULL, &passwordLength, &password, NULL);
- if(err == noErr){
- pwData = [NSData dataWithBytes:password length:passwordLength];
- SecKeychainItemFreeContent(NULL, password);
- } else if (err != errSecItemNotFound && err != errSecUserCanceled){
- NSLog(@"Error %d occurred getting password: %@", (int)err,
[(id)SecCopyErrorMessageString(err, NULL) autorelease]);
- }
- return pwData;
-}
-
-+ (BOOL)addOrModifyPassword:(NSString *)password
forKeychainServiceName:(NSString *)name {
- // default is to use current user's username
- const char *userNameCString = [NSUserName() UTF8String];
-
- NSParameterAssert(name != nil);
- const char *nameCString = [name UTF8String];
-
- OSStatus err;
- SecKeychainItemRef itemRef = NULL;
- const void *passwordData = [password UTF8String];
- const void *oldPasswordData = NULL;
- UInt32 passwordLength = 0;
- BOOL result = NO;
-
- // first see if the password exists in the keychain
- err = SecKeychainFindGenericPassword(NULL, strlen(nameCString),
nameCString, 0, NULL, &passwordLength, (void **)&oldPasswordData, &itemRef);
-
- if (err == noErr) {
- // password was on keychain, so flush the buffer and then modify the
keychain if necessary
- if (passwordLength != strlen(passwordData) || strncmp(passwordData,
oldPasswordData, passwordLength) != 0) {
- err = SecKeychainItemModifyAttributesAndData(itemRef, NULL,
strlen(passwordData), passwordData);
- if (err != noErr && err != errSecUserCanceled)
- NSLog(@"Error %d occurred modifying password: %@", (int)err,
[(id)SecCopyErrorMessageString(err, NULL) autorelease]);
- result = (err == noErr);
- }
- SecKeychainItemFreeContent(NULL, (void *)oldPasswordData);
- CFRelease(itemRef);
- } else if (err == errSecItemNotFound) {
- // password not on keychain, so add it
- err = SecKeychainAddGenericPassword(NULL, strlen(nameCString),
nameCString, strlen(userNameCString), userNameCString, strlen(passwordData),
passwordData, NULL);
- if (err != noErr && err != errSecUserCanceled)
- NSLog(@"Error %d occurred adding password: %@", (int)err,
[(id)SecCopyErrorMessageString(err, NULL) autorelease]);
- result = (err == noErr);
- } else if (err != errSecUserCanceled) {
- NSLog(@"Error %d occurred getting password: %@", (int)err,
[(id)SecCopyErrorMessageString(err, NULL) autorelease]);
- }
- return result;
-}
-
-- (NSData *)runModalForKeychainServiceName:(NSString *)name message:(NSString
*)status {
- NSString *password = nil;
- [self window]; // load window before seting the status
- [statusField setStringValue:status];
- if (NSOKButton == [NSApp runModalForWindow:[self window]]) {
- NSAssert(name != nil, @"name is nil");
- password = [[[passwordField stringValue] retain] autorelease];
- NSParameterAssert(password != nil);
- [[self class] addOrModifyPassword:password
forKeychainServiceName:name];
- }
- [[self window] orderOut:self];
-
- if (password == nil)
- return nil;
- return [password dataUsingEncoding:NSUTF8StringEncoding];
-}
-
-+ (NSData *)runModalPanelForKeychainServiceName:(NSString *)name
message:(NSString *)status {
- BDSKPasswordController *pwc = [[[self alloc]
initWithWindowNibName:@"BDSKPasswordController"] autorelease];
- return [pwc runModalForKeychainServiceName:name message:status];
-}
-
- (IBAction)buttonAction:(id)sender {
[NSApp stopModalWithCode:[sender tag]];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit