aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionDelegate.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-06-28 10:54:17 +0000
committerBibiko <bibiko@eva.mpg.de>2010-06-28 10:54:17 +0000
commit1490d184c4c3ef4bf76396203d58feece4e4a25d (patch)
tree68d49a0526d9eebe59a14ed7030e90075eb33955 /Source/SPConnectionDelegate.m
parentc92a1ef7ad770374b2c3912fd591ee39d3ef130e (diff)
downloadsequelpro-1490d184c4c3ef4bf76396203d58feece4e4a25d.tar.gz
sequelpro-1490d184c4c3ef4bf76396203d58feece4e4a25d.tar.bz2
sequelpro-1490d184c4c3ef4bf76396203d58feece4e4a25d.zip
• added to SPconnectionDelegate method "keychainPasswordForSSHConnection"
Diffstat (limited to 'Source/SPConnectionDelegate.m')
-rw-r--r--Source/SPConnectionDelegate.m24
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m
index 9d49d298..5231c996 100644
--- a/Source/SPConnectionDelegate.m
+++ b/Source/SPConnectionDelegate.m
@@ -98,6 +98,30 @@
}
/**
+ * Invoked when the current connection needs a ssh password from the Keychain.
+ */
+- (NSString *)keychainPasswordForSSHConnection:(MCPConnection *)connection
+{
+
+ // If no keychain item is available, return an empty password
+ if (![connectionController connectionKeychainItemName]) return @"";
+
+ // Otherwise, pull the password from the keychain using the details from this connection
+ SPKeychain *keychain = [[SPKeychain alloc] init];
+ NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]] retain];
+ NSString *connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]] retain];
+ NSString *sshpw = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
+ if (!sshpw || ![sshpw length])
+ sshpw = @"";
+
+ if(connectionSSHKeychainItemName) [connectionSSHKeychainItemName release];
+ if(connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release];
+ [keychain release];
+
+ return sshpw;
+}
+
+/**
* Invoked when an attempt was made to execute a query on the current connection, but the connection is not
* actually active.
*/