From 1490d184c4c3ef4bf76396203d58feece4e4a25d Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 28 Jun 2010 10:54:17 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20to=20SPconnectionDelegate=20method?= =?UTF-8?q?=20"keychainPasswordForSSHConnection"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPConnectionDelegate.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Source/SPConnectionDelegate.m') diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m index 9d49d298..5231c996 100644 --- a/Source/SPConnectionDelegate.m +++ b/Source/SPConnectionDelegate.m @@ -97,6 +97,30 @@ return password; } +/** + * 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. -- cgit v1.2.3