From 1e2d1c7724e7077053862048dac4830a95dd82cd Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Fri, 7 Aug 2009 22:27:09 +0000 Subject: Rename Keychain class. --- Source/KeyChain.h | 41 ------ Source/KeyChain.m | 261 -------------------------------------- Source/MainController.m | 2 +- Source/SPConnectionController.h | 4 +- Source/SPConnectionController.m | 2 +- Source/SPKeychain.h | 41 ++++++ Source/SPKeychain.m | 261 ++++++++++++++++++++++++++++++++++++++ Source/SPPreferenceController.h | 4 +- Source/SPPreferenceController.m | 6 +- Source/SPSSHTunnel.m | 6 +- Source/SequelProTunnelAssistant.m | 8 +- Source/TableDocument.m | 2 +- 12 files changed, 319 insertions(+), 319 deletions(-) delete mode 100644 Source/KeyChain.h delete mode 100644 Source/KeyChain.m create mode 100644 Source/SPKeychain.h create mode 100644 Source/SPKeychain.m diff --git a/Source/KeyChain.h b/Source/KeyChain.h deleted file mode 100644 index ca95d09f..00000000 --- a/Source/KeyChain.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// $Id$ -// -// KeyChain.h -// sequel-pro -// -// Created by lorenz textor (lorenz@textor.ch) on Wed Dec 25 2002. -// Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at - -#import -#import - -@interface KeyChain : NSObject - -- (void)addPassword:(NSString *)password forName:(NSString *)name account:(NSString *)account; -- (void)addPassword:(NSString *)password forName:(NSString *)name account:(NSString *)account withLabel:(NSString *)label; -- (NSString *)getPasswordForName:(NSString *)name account:(NSString *)account; -- (void)deletePasswordForName:(NSString *)name account:(NSString *)account; -- (BOOL)passwordExistsForName:(NSString *)name account:(NSString *)account; -- (NSString *)nameForFavoriteName:(NSString *)theName id:(NSString *)theID; -- (NSString *)accountForUser:(NSString *)theUser host:(NSString *)theHost database:(NSString *)theDatabase; -- (NSString *)nameForSSHForFavoriteName:(NSString *)theName id:(NSString *)theID; -- (NSString *)accountForSSHUser:(NSString *)theSSHUser sshHost:(NSString *)theSSHHost; - -@end diff --git a/Source/KeyChain.m b/Source/KeyChain.m deleted file mode 100644 index 483eeceb..00000000 --- a/Source/KeyChain.m +++ /dev/null @@ -1,261 +0,0 @@ -// -// $Id$ -// -// KeyChain.m -// sequel-pro -// -// Created by lorenz textor (lorenz@textor.ch) on Wed Dec 25 2002. -// Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at - -#import "KeyChain.h" - -#import -#import - -@implementation KeyChain - -/** - * Add the supplied password to the user's Keychain using the supplied name and account. - */ -- (void)addPassword:(NSString *)password forName:(NSString *)name account:(NSString *)account -{ - [self addPassword:password forName:name account:account withLabel:name]; -} - -/** - * Add the supplied password to the user's Keychain using the supplied name, account, and label. - */ -- (void)addPassword:(NSString *)password forName:(NSString *)name account:(NSString *)account withLabel:(NSString *)label; -{ - OSStatus status; - SecTrustedApplicationRef sequelProRef, sequelProHelperRef; - SecAccessRef passwordAccessRef; - SecKeychainAttribute attributes[4]; - SecKeychainAttributeList attList; - - // Check if password already exists before adding - if (![self passwordExistsForName:name account:account]) { - - // Create a trusted access list with two items - ourselves and the SSH pass app. - NSString *helperPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"SequelProTunnelAssistant"]; - if ((SecTrustedApplicationCreateFromPath(NULL, &sequelProRef) == noErr) && - (SecTrustedApplicationCreateFromPath([helperPath UTF8String], &sequelProHelperRef) == noErr)) { - - NSArray *trustedApps = [NSArray arrayWithObjects:(id)sequelProRef, (id)sequelProHelperRef, nil]; - status = SecAccessCreate((CFStringRef)name, (CFArrayRef)trustedApps, &passwordAccessRef); - if (status != noErr) { - NSLog(@"Error (%i) while trying to create access list for name: %@ account: %@", status, name, account); - passwordAccessRef = NULL; - } - } - - // Set up the item attributes - attributes[0].tag = kSecGenericItemAttr; - attributes[0].data = "application password"; - attributes[0].length = 20; - attributes[1].tag = kSecLabelItemAttr; - attributes[1].data = (unichar *)[label UTF8String]; - attributes[1].length = strlen([label UTF8String]); - attributes[2].tag = kSecAccountItemAttr; - attributes[2].data = (unichar *)[account UTF8String]; - attributes[2].length = strlen([account UTF8String]); - attributes[3].tag = kSecServiceItemAttr; - attributes[3].data = (unichar *)[name UTF8String]; - attributes[3].length = strlen([name UTF8String]); - attList.count = 4; - attList.attr = attributes; - - // Create the keychain item - status = SecKeychainItemCreateFromContent( - kSecGenericPasswordItemClass, // Generic password type - &attList, // The attribute list created for the keychain item - strlen([password UTF8String]), // Length of password - [password UTF8String], // Password data - NULL, // Default keychain - passwordAccessRef, // Access list for this keychain - NULL); // The item reference - - if (passwordAccessRef) CFRelease(passwordAccessRef); - if (status != noErr) { - NSLog(@"Error (%i) while trying to add password for name: %@ account: %@", status, name, account); - } - } -} - -/** - * Get a password from the user's Keychain for the supplied name and account. - */ -- (NSString *)getPasswordForName:(NSString *)name account:(NSString *)account -{ - OSStatus status; - - void *passwordData; - UInt32 passwordLength; - SecKeychainItemRef itemRef; - NSString *password = @""; - - status = SecKeychainFindGenericPassword( - NULL, // default keychain - strlen([name UTF8String]), // length of service name (bytes) - [name UTF8String], // service name - strlen([account UTF8String]), // length of account name (bytes) - [account UTF8String], // account name - &passwordLength, // length of password - &passwordData, // pointer to password data - &itemRef // the item reference - ); - - if (status == noErr) { - password = [NSString stringWithCString:passwordData length:passwordLength]; - - // Free the data allocated by SecKeychainFindGenericPassword: - SecKeychainItemFreeContent( - NULL, // No attribute data to release - passwordData // Release data - ); - } - - return password; -} - -/** - * Delete a password from the user's Keychain for the supplied name and account. - */ -- (void)deletePasswordForName:(NSString *)name account:(NSString *)account -{ - OSStatus status; - SecKeychainItemRef itemRef = nil; - - // Check if password already exists before deleting - if ([self passwordExistsForName:name account:account]) { - status = SecKeychainFindGenericPassword( - NULL, // default keychain - strlen([name UTF8String]), // length of service name - [name UTF8String], // service name - strlen([account UTF8String]), // length of account name - [account UTF8String], // account name - nil, // length of password - nil, // pointer to password data - &itemRef // the item reference - ); - - if (status == noErr) { - status = SecKeychainItemDelete(itemRef); - - if (status != noErr) { - NSLog(@"Error (%i) while trying to delete password for name: %@ account: %@", status, name, account); - } - } - - if (itemRef) CFRelease(itemRef); - } -} - -/** - * Checks the user's Keychain to see if a password for the supplied name and account exists. - */ -- (BOOL)passwordExistsForName:(NSString *)name account:(NSString *)account -{ - SecKeychainItemRef item; - SecKeychainSearchRef search = NULL; - int numberOfItemsFound = 0; - SecKeychainAttributeList list; - SecKeychainAttribute attributes[2]; - - attributes[0].tag = kSecAccountItemAttr; - attributes[0].data = (void *)[account UTF8String]; // Account name - attributes[0].length = strlen([account UTF8String]); // Length of account name (bytes) - - attributes[1].tag = kSecServiceItemAttr; - attributes[1].data = (void *)[name UTF8String]; // Service name - attributes[1].length = strlen([name UTF8String]); // Length of service name (bytes) - - list.count = 2; - list.attr = attributes; - - if (SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, &list, &search) == noErr) { - while (SecKeychainSearchCopyNext(search, &item) == noErr) { - CFRelease(item); - numberOfItemsFound++; - } - } - - if (search) CFRelease(search); - - return (numberOfItemsFound > 0); -} - -/** - * Retrieve the keychain item name for a supplied name and id. - */ -- (NSString *)nameForFavoriteName:(NSString *)theName id:(NSString *)theID -{ - NSString *keychainItemName; - - keychainItemName = [NSString stringWithFormat:@"Sequel Pro : %@ (%i)", - theName, - [theID intValue]]; - - return keychainItemName; -} - -/** - * Retrieve the keychain item account for a supplied user, host, and database - which can be nil. - */ -- (NSString *)accountForUser:(NSString *)theUser host:(NSString *)theHost database:(NSString *)theDatabase -{ - NSString *keychainItemAccount; - - keychainItemAccount = [NSString stringWithFormat:@"%@@%@/%@", - theUser?theUser:@"", - theHost?theHost:@"", - theDatabase?theDatabase:@""]; - - return keychainItemAccount; -} - -/** - * Retrieve the keychain SSH item name for a supplied name and id. - */ -- (NSString *)nameForSSHForFavoriteName:(NSString *)theName id:(NSString *)theID -{ - NSString *sshKeychainItemName; - - sshKeychainItemName = [NSString stringWithFormat:@"Sequel Pro SSHTunnel : %@ (%i)", - theName, - [theID intValue]]; - - return sshKeychainItemName; -} - -/** - * Retrieve the keychain SSH item account for a supplied SSH user and host - which can be nil. - */ -- (NSString *)accountForSSHUser:(NSString *)theSSHUser sshHost:(NSString *)theSSHHost -{ - NSString *sshKeychainItemAccount; - - sshKeychainItemAccount = [NSString stringWithFormat:@"%@@%@", - theSSHUser?theSSHUser:@"", - theSSHHost?theSSHHost:@""]; - - return sshKeychainItemAccount; -} - -@end diff --git a/Source/MainController.m b/Source/MainController.m index 3f297574..a712e481 100644 --- a/Source/MainController.m +++ b/Source/MainController.m @@ -23,7 +23,7 @@ // // More info at -#import "KeyChain.h" +#import "SPKeychain.h" #import "MainController.h" #import "TableDocument.h" #import "SPPreferenceController.h" diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index f9af5894..d9e83410 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -27,7 +27,7 @@ #import #import "TableDocument.h" -#import "KeyChain.h" +#import "SPKeychain.h" #import "SPSSHTunnel.h" enum spconnection_types @@ -48,7 +48,7 @@ enum spconnection_types TableDocument *tableDocument; NSWindow *documentWindow; NSSplitView *contentView; - KeyChain *keychain; + SPKeychain *keychain; NSUserDefaults *prefs; NSMutableArray *favorites; SPSSHTunnel *sshTunnel; diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index e5a0a473..baef9691 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -80,7 +80,7 @@ for (int i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:NO]; // Set up a keychain instance and preferences reference, and create the initial favorites list - keychain = [[KeyChain alloc] init]; + keychain = [[SPKeychain alloc] init]; prefs = [[NSUserDefaults standardUserDefaults] retain]; favorites = nil; [self updateFavorites]; diff --git a/Source/SPKeychain.h b/Source/SPKeychain.h new file mode 100644 index 00000000..21e6c405 --- /dev/null +++ b/Source/SPKeychain.h @@ -0,0 +1,41 @@ +// +// $Id$ +// +// SPKeychain.h +// sequel-pro +// +// Created by lorenz textor (lorenz@textor.ch) on Wed Dec 25 2002. +// Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import +#import + +@interface SPKeychain : NSObject + +- (void)addPassword:(NSString *)password forName:(NSString *)name account:(NSString *)account; +- (void)addPassword:(NSString *)password forName:(NSString *)name account:(NSString *)account withLabel:(NSString *)label; +- (NSString *)getPasswordForName:(NSString *)name account:(NSString *)account; +- (void)deletePasswordForName:(NSString *)name account:(NSString *)account; +- (BOOL)passwordExistsForName:(NSString *)name account:(NSString *)account; +- (NSString *)nameForFavoriteName:(NSString *)theName id:(NSString *)theID; +- (NSString *)accountForUser:(NSString *)theUser host:(NSString *)theHost database:(NSString *)theDatabase; +- (NSString *)nameForSSHForFavoriteName:(NSString *)theName id:(NSString *)theID; +- (NSString *)accountForSSHUser:(NSString *)theSSHUser sshHost:(NSString *)theSSHHost; + +@end diff --git a/Source/SPKeychain.m b/Source/SPKeychain.m new file mode 100644 index 00000000..9aea5248 --- /dev/null +++ b/Source/SPKeychain.m @@ -0,0 +1,261 @@ +// +// $Id$ +// +// SPKeychain.m +// sequel-pro +// +// Created by lorenz textor (lorenz@textor.ch) on Wed Dec 25 2002. +// Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import "SPKeychain.h" + +#import +#import + +@implementation SPKeychain + +/** + * Add the supplied password to the user's Keychain using the supplied name and account. + */ +- (void)addPassword:(NSString *)password forName:(NSString *)name account:(NSString *)account +{ + [self addPassword:password forName:name account:account withLabel:name]; +} + +/** + * Add the supplied password to the user's Keychain using the supplied name, account, and label. + */ +- (void)addPassword:(NSString *)password forName:(NSString *)name account:(NSString *)account withLabel:(NSString *)label; +{ + OSStatus status; + SecTrustedApplicationRef sequelProRef, sequelProHelperRef; + SecAccessRef passwordAccessRef; + SecKeychainAttribute attributes[4]; + SecKeychainAttributeList attList; + + // Check if password already exists before adding + if (![self passwordExistsForName:name account:account]) { + + // Create a trusted access list with two items - ourselves and the SSH pass app. + NSString *helperPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"SequelProTunnelAssistant"]; + if ((SecTrustedApplicationCreateFromPath(NULL, &sequelProRef) == noErr) && + (SecTrustedApplicationCreateFromPath([helperPath UTF8String], &sequelProHelperRef) == noErr)) { + + NSArray *trustedApps = [NSArray arrayWithObjects:(id)sequelProRef, (id)sequelProHelperRef, nil]; + status = SecAccessCreate((CFStringRef)name, (CFArrayRef)trustedApps, &passwordAccessRef); + if (status != noErr) { + NSLog(@"Error (%i) while trying to create access list for name: %@ account: %@", status, name, account); + passwordAccessRef = NULL; + } + } + + // Set up the item attributes + attributes[0].tag = kSecGenericItemAttr; + attributes[0].data = "application password"; + attributes[0].length = 20; + attributes[1].tag = kSecLabelItemAttr; + attributes[1].data = (unichar *)[label UTF8String]; + attributes[1].length = strlen([label UTF8String]); + attributes[2].tag = kSecAccountItemAttr; + attributes[2].data = (unichar *)[account UTF8String]; + attributes[2].length = strlen([account UTF8String]); + attributes[3].tag = kSecServiceItemAttr; + attributes[3].data = (unichar *)[name UTF8String]; + attributes[3].length = strlen([name UTF8String]); + attList.count = 4; + attList.attr = attributes; + + // Create the keychain item + status = SecKeychainItemCreateFromContent( + kSecGenericPasswordItemClass, // Generic password type + &attList, // The attribute list created for the keychain item + strlen([password UTF8String]), // Length of password + [password UTF8String], // Password data + NULL, // Default keychain + passwordAccessRef, // Access list for this keychain + NULL); // The item reference + + if (passwordAccessRef) CFRelease(passwordAccessRef); + if (status != noErr) { + NSLog(@"Error (%i) while trying to add password for name: %@ account: %@", status, name, account); + } + } +} + +/** + * Get a password from the user's Keychain for the supplied name and account. + */ +- (NSString *)getPasswordForName:(NSString *)name account:(NSString *)account +{ + OSStatus status; + + void *passwordData; + UInt32 passwordLength; + SecKeychainItemRef itemRef; + NSString *password = @""; + + status = SecKeychainFindGenericPassword( + NULL, // default keychain + strlen([name UTF8String]), // length of service name (bytes) + [name UTF8String], // service name + strlen([account UTF8String]), // length of account name (bytes) + [account UTF8String], // account name + &passwordLength, // length of password + &passwordData, // pointer to password data + &itemRef // the item reference + ); + + if (status == noErr) { + password = [NSString stringWithCString:passwordData length:passwordLength]; + + // Free the data allocated by SecKeychainFindGenericPassword: + SecKeychainItemFreeContent( + NULL, // No attribute data to release + passwordData // Release data + ); + } + + return password; +} + +/** + * Delete a password from the user's Keychain for the supplied name and account. + */ +- (void)deletePasswordForName:(NSString *)name account:(NSString *)account +{ + OSStatus status; + SecKeychainItemRef itemRef = nil; + + // Check if password already exists before deleting + if ([self passwordExistsForName:name account:account]) { + status = SecKeychainFindGenericPassword( + NULL, // default keychain + strlen([name UTF8String]), // length of service name + [name UTF8String], // service name + strlen([account UTF8String]), // length of account name + [account UTF8String], // account name + nil, // length of password + nil, // pointer to password data + &itemRef // the item reference + ); + + if (status == noErr) { + status = SecKeychainItemDelete(itemRef); + + if (status != noErr) { + NSLog(@"Error (%i) while trying to delete password for name: %@ account: %@", status, name, account); + } + } + + if (itemRef) CFRelease(itemRef); + } +} + +/** + * Checks the user's Keychain to see if a password for the supplied name and account exists. + */ +- (BOOL)passwordExistsForName:(NSString *)name account:(NSString *)account +{ + SecKeychainItemRef item; + SecKeychainSearchRef search = NULL; + int numberOfItemsFound = 0; + SecKeychainAttributeList list; + SecKeychainAttribute attributes[2]; + + attributes[0].tag = kSecAccountItemAttr; + attributes[0].data = (void *)[account UTF8String]; // Account name + attributes[0].length = strlen([account UTF8String]); // Length of account name (bytes) + + attributes[1].tag = kSecServiceItemAttr; + attributes[1].data = (void *)[name UTF8String]; // Service name + attributes[1].length = strlen([name UTF8String]); // Length of service name (bytes) + + list.count = 2; + list.attr = attributes; + + if (SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, &list, &search) == noErr) { + while (SecKeychainSearchCopyNext(search, &item) == noErr) { + CFRelease(item); + numberOfItemsFound++; + } + } + + if (search) CFRelease(search); + + return (numberOfItemsFound > 0); +} + +/** + * Retrieve the keychain item name for a supplied name and id. + */ +- (NSString *)nameForFavoriteName:(NSString *)theName id:(NSString *)theID +{ + NSString *keychainItemName; + + keychainItemName = [NSString stringWithFormat:@"Sequel Pro : %@ (%i)", + theName, + [theID intValue]]; + + return keychainItemName; +} + +/** + * Retrieve the keychain item account for a supplied user, host, and database - which can be nil. + */ +- (NSString *)accountForUser:(NSString *)theUser host:(NSString *)theHost database:(NSString *)theDatabase +{ + NSString *keychainItemAccount; + + keychainItemAccount = [NSString stringWithFormat:@"%@@%@/%@", + theUser?theUser:@"", + theHost?theHost:@"", + theDatabase?theDatabase:@""]; + + return keychainItemAccount; +} + +/** + * Retrieve the keychain SSH item name for a supplied name and id. + */ +- (NSString *)nameForSSHForFavoriteName:(NSString *)theName id:(NSString *)theID +{ + NSString *sshKeychainItemName; + + sshKeychainItemName = [NSString stringWithFormat:@"Sequel Pro SSHTunnel : %@ (%i)", + theName, + [theID intValue]]; + + return sshKeychainItemName; +} + +/** + * Retrieve the keychain SSH item account for a supplied SSH user and host - which can be nil. + */ +- (NSString *)accountForSSHUser:(NSString *)theSSHUser sshHost:(NSString *)theSSHHost +{ + NSString *sshKeychainItemAccount; + + sshKeychainItemAccount = [NSString stringWithFormat:@"%@@%@", + theSSHUser?theSSHUser:@"", + theSSHHost?theSSHHost:@""]; + + return sshKeychainItemAccount; +} + +@end diff --git a/Source/SPPreferenceController.h b/Source/SPPreferenceController.h index 515221e9..4e4eed5a 100644 --- a/Source/SPPreferenceController.h +++ b/Source/SPPreferenceController.h @@ -25,7 +25,7 @@ #import -@class KeyChain; +@class SPKeychain; @interface SPPreferenceController : NSWindowController { @@ -56,7 +56,7 @@ IBOutlet NSTextField *favoriteUserTextFieldSSH; IBOutlet NSTextField *favoriteHostTextFieldSSH; - KeyChain *keychain; + SPKeychain *keychain; NSDictionary *currentFavorite; IBOutlet NSTextField *editorFontName; diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index ca7c6562..f9618249 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -26,7 +26,7 @@ #import "SPPreferenceController.h" #import "SPWindowAdditions.h" #import "SPFavoriteTextFieldCell.h" -#import "KeyChain.h" +#import "SPKeychain.h" #import "TableDocument.h" #define FAVORITES_PB_DRAG_TYPE @"SequelProPreferencesPasteboard" @@ -78,7 +78,7 @@ { [self _setupToolbar]; - keychain = [[KeyChain alloc] init]; + keychain = [[SPKeychain alloc] init]; SPFavoriteTextFieldCell *tableCell = [[[SPFavoriteTextFieldCell alloc] init] autorelease]; @@ -206,7 +206,7 @@ NSMutableArray *favoritesArray = [NSMutableArray arrayWithArray:[prefs objectForKey:@"favorites"]]; NSMutableDictionary *favorite; NSString *password, *keychainName, *keychainAccount; - KeyChain *upgradeKeychain = [[KeyChain alloc] init]; + SPKeychain *upgradeKeychain = [[SPKeychain alloc] init]; // Cycle through the favorites, generating a timestamp-derived ID for each and renaming associated keychain items. for (i = 0; i < [favoritesArray count]; i++) { diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index d086c8ce..01ab721d 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -25,7 +25,7 @@ #import "SPSSHTunnel.h" #import "RegexKitLite.h" -#import "KeyChain.h" +#import "SPKeychain.h" #import @implementation SPSSHTunnel @@ -510,7 +510,7 @@ NSSize queryTextSize; NSRect windowFrameRect; NSString *thePassword; - KeyChain *keychain; + SPKeychain *keychain; // Work out whether a passphrase is being requested, extracting the key name NSString *keyName = [theQuery stringByMatching:@"^\\s*Enter passphrase for key \\'(.*)\\':\\s*$" capture:1L]; @@ -543,7 +543,7 @@ // Add to keychain if appropriate if (keyName && [sshPasswordKeychainCheckbox state] == NSOnState) { - keychain = [[KeyChain alloc] init]; + keychain = [[SPKeychain alloc] init]; [keychain addPassword:thePassword forName:@"SSH" account:keyName withLabel:[NSString stringWithFormat:@"SSH: %@", keyName]]; [keychain release]; } diff --git a/Source/SequelProTunnelAssistant.m b/Source/SequelProTunnelAssistant.m index 462d9a6d..0d9138a1 100644 --- a/Source/SequelProTunnelAssistant.m +++ b/Source/SequelProTunnelAssistant.m @@ -23,7 +23,7 @@ // More info at #import -#import "KeyChain.h" +#import "SPKeychain.h" #import "SPSSHTunnel.h" #import "RegexKitLite.h" @@ -69,7 +69,7 @@ int main(int argc, const char *argv[]) // If the password method is set to use the keychain, use the supplied keychain name to // request the password if ([[environment objectForKey:@"SP_PASSWORD_METHOD"] intValue] == SPSSH_PASSWORD_USES_KEYCHAIN) { - KeyChain *keychain; + SPKeychain *keychain; NSString *keychainName = [environment objectForKey:@"SP_KEYCHAIN_ITEM_NAME"]; NSString *keychainAccount = [environment objectForKey:@"SP_KEYCHAIN_ITEM_ACCOUNT"]; @@ -79,7 +79,7 @@ int main(int argc, const char *argv[]) return 1; } - keychain = [[KeyChain alloc] init]; + keychain = [[SPKeychain alloc] init]; if (![keychain passwordExistsForName:keychainName account:keychainAccount]) { NSLog(@"SSH Tunnel: specified keychain password not found"); [keychain release]; @@ -131,7 +131,7 @@ int main(int argc, const char *argv[]) if (keyName) { // Check whether the passphrase is in the keychain, using standard OS X sshagent name and account - KeyChain *keychain = [[KeyChain alloc] init]; + SPKeychain *keychain = [[SPKeychain alloc] init]; if ([keychain passwordExistsForName:@"SSH" account:keyName]) { printf("%s\n", [[keychain getPasswordForName:@"SSH" account:keyName] UTF8String]); [keychain release]; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 4670740c..1063070b 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -2401,7 +2401,7 @@ */ - (NSString *)keychainPasswordForConnection:(MCPConnection *)connection { - KeyChain *keychain = [[KeyChain alloc] init]; + SPKeychain *keychain = [[SPKeychain alloc] init]; NSString *password = [keychain getPasswordForName:[connectionController connectionKeychainItemName] account:[connectionController connectionKeychainItemAccount]]; -- cgit v1.2.3