diff options
Diffstat (limited to 'Source/SPConnectionDelegate.m')
-rw-r--r-- | Source/SPConnectionDelegate.m | 24 |
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. */ |