aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionController.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2018-02-23 20:56:44 +0100
committerMax <post@wickenrode.com>2018-02-23 20:56:44 +0100
commitca864a1f887feaf7ac6d35eeb55b265f3e630a09 (patch)
tree8746370d8785d9030a52383c5dfbef48bfc05d2c /Source/SPConnectionController.m
parent770c18901f82696d1233e0139e9bb3c4fbbcb90b (diff)
downloadsequelpro-ca864a1f887feaf7ac6d35eeb55b265f3e630a09.tar.gz
sequelpro-ca864a1f887feaf7ac6d35eeb55b265f3e630a09.tar.bz2
sequelpro-ca864a1f887feaf7ac6d35eeb55b265f3e630a09.zip
Remove the keychain id stuff from SPDatabaseDocument. It was only proxying SPConnectionController anyway
Diffstat (limited to 'Source/SPConnectionController.m')
-rw-r--r--Source/SPConnectionController.m20
1 files changed, 14 insertions, 6 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 02f68b06..467aa303 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -168,6 +168,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
@synthesize dbDocument;
#endif
+@synthesize connectionKeychainID = connectionKeychainID;
@synthesize connectionKeychainItemName;
@synthesize connectionKeychainItemAccount;
@synthesize connectionSSHKeychainItemName;
@@ -188,6 +189,16 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
return kcPassword;
}
+- (NSString *)keychainPasswordForSSH
+{
+ if (![self connectionKeychainItemName]) return nil;
+
+ // Otherwise, pull the password from the keychain using the details from this connection
+ NSString *kcSSHPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
+
+ return kcSSHPassword;
+}
+
#pragma mark -
#pragma mark Connection processes
@@ -749,7 +760,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
#ifndef SP_CODA
// Clear the keychain referral items as appropriate
- if (connectionKeychainID) SPClear(connectionKeychainID);
+ [self setConnectionKeychainID:nil];
if (connectionKeychainItemName) SPClear(connectionKeychainItemName);
if (connectionKeychainItemAccount) SPClear(connectionKeychainItemAccount);
if (connectionSSHKeychainItemName) SPClear(connectionSSHKeychainItemName);
@@ -816,7 +827,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
}
// Store the selected favorite ID for use with the document on connection
- if ([fav objectForKey:SPFavoriteIDKey]) connectionKeychainID = [[[fav objectForKey:SPFavoriteIDKey] stringValue] retain];
+ if ([fav objectForKey:SPFavoriteIDKey]) [self setConnectionKeychainID:[[fav objectForKey:SPFavoriteIDKey] stringValue]];
// And the same for the SSH password
connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[fav objectForKey:SPFavoriteNameKey] id:[fav objectForKey:SPFavoriteIDKey]] retain];
@@ -2384,8 +2395,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
for (NSUInteger i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:YES];
#endif
- if (connectionKeychainID) [dbDocument setKeychainID:connectionKeychainID];
-
// Pass the connection to the table document, allowing it to set
// up the other classes and the rest of the interface.
[dbDocument setConnection:mySQLConnection];
@@ -3179,7 +3188,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
#endif
// Keychain references
- connectionKeychainID = nil;
connectionKeychainItemName = nil;
connectionKeychainItemAccount = nil;
connectionSSHKeychainItemName = nil;
@@ -3633,7 +3641,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
SPClear(nibObjectsToRelease);
- if (connectionKeychainID) SPClear(connectionKeychainID);
+ [self setConnectionKeychainID:nil];
if (connectionKeychainItemName) SPClear(connectionKeychainItemName);
if (connectionKeychainItemAccount) SPClear(connectionKeychainItemAccount);
if (connectionSSHKeychainItemName) SPClear(connectionSSHKeychainItemName);