aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-12-05 15:57:15 +0000
committerstuconnolly <stuart02@gmail.com>2010-12-05 15:57:15 +0000
commitc91dd638605c4e4cee9343dce11abdf498e20532 (patch)
tree9230820828d0230dd4edf37e675ff602221effce /Source/SPConnectionController.m
parente945be72f8e476d84c19f712dd79e51a4a3f1e80 (diff)
downloadsequelpro-c91dd638605c4e4cee9343dce11abdf498e20532.tar.gz
sequelpro-c91dd638605c4e4cee9343dce11abdf498e20532.tar.bz2
sequelpro-c91dd638605c4e4cee9343dce11abdf498e20532.zip
Only access Keychain items when necessary.
Diffstat (limited to 'Source/SPConnectionController.m')
-rw-r--r--Source/SPConnectionController.m24
1 files changed, 14 insertions, 10 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 8c5c4896..4938c09a 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -892,14 +892,6 @@ static const NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist";
NSInteger duplicatedFavoriteType = [[favorite objectForKey:SPFavoriteTypeKey] integerValue];
- // Select the keychain passwords for duplication
- NSString *keychainName = [keychain nameForFavoriteName:[favorite objectForKey:SPFavoriteNameKey] id:[favorite objectForKey:SPFavoriteIDKey]];
- NSString *keychainAccount = [keychain accountForUser:[favorite objectForKey:SPFavoriteUserKey] host:((duplicatedFavoriteType == SPSocketConnection) ? @"localhost" : [favorite objectForKey:SPFavoriteHostKey]) database:[favorite objectForKey:SPFavoriteDatabaseKey]];
- NSString *favoritePassword = [keychain getPasswordForName:keychainName account:keychainAccount];
- NSString *keychainSSHName = [keychain nameForSSHForFavoriteName:[favorite objectForKey:SPFavoriteNameKey] id:[favorite objectForKey:SPFavoriteIDKey]];
- NSString *keychainSSHAccount = [keychain accountForSSHUser:[favorite objectForKey:SPFavoriteSSHUserKey] sshHost:[favorite objectForKey:SPFavoriteSSHHostKey]];
- NSString *favoriteSSHPassword = [keychain getPasswordForName:keychainSSHName account:keychainSSHAccount];
-
// Update the unique ID
[favorite setObject:favoriteID forKey:SPFavoriteIDKey];
@@ -908,16 +900,28 @@ static const NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist";
// Create new keychain items if appropriate
if (password && [password length]) {
+ NSString *keychainName = [keychain nameForFavoriteName:[favorite objectForKey:SPFavoriteNameKey] id:[favorite objectForKey:SPFavoriteIDKey]];
+ NSString *keychainAccount = [keychain accountForUser:[favorite objectForKey:SPFavoriteUserKey] host:((duplicatedFavoriteType == SPSocketConnection) ? @"localhost" : [favorite objectForKey:SPFavoriteHostKey]) database:[favorite objectForKey:SPFavoriteDatabaseKey]];
+ NSString *favoritePassword = [keychain getPasswordForName:keychainName account:keychainAccount];
+
keychainName = [keychain nameForFavoriteName:[favorite objectForKey:SPFavoriteNameKey] id:[favorite objectForKey:SPFavoriteIDKey]];
+
[keychain addPassword:favoritePassword forName:keychainName account:keychainAccount];
+
+ favoritePassword = nil;
}
if (sshPassword && [sshPassword length]) {
+ NSString *keychainSSHName = [keychain nameForSSHForFavoriteName:[favorite objectForKey:SPFavoriteNameKey] id:[favorite objectForKey:SPFavoriteIDKey]];
+ NSString *keychainSSHAccount = [keychain accountForSSHUser:[favorite objectForKey:SPFavoriteSSHUserKey] sshHost:[favorite objectForKey:SPFavoriteSSHHostKey]];
+ NSString *favoriteSSHPassword = [keychain getPasswordForName:keychainSSHName account:keychainSSHAccount];
+
keychainSSHName = [keychain nameForSSHForFavoriteName:[favorite objectForKey:SPFavoriteNameKey] id:[favorite objectForKey:SPFavoriteIDKey]];
+
[keychain addPassword:favoriteSSHPassword forName:keychainSSHName account:keychainSSHAccount];
- }
- favoritePassword = nil, favoriteSSHPassword = nil;
+ favoriteSSHPassword = nil;
+ }
SPTreeNode *selectedNode = [self selectedFavoriteNode];