Permalink
Browse files

Move method -keychainPassword from SPDatabaseDocument to SPConnection…

…Controller since all it did was request info from the connection controller
  • Loading branch information...
dmoagx committed Feb 23, 2018
1 parent fcb696a commit 770c18901f82696d1233e0139e9bb3c4fbbcb90b
Showing with 17 additions and 20 deletions.
  1. +2 −0 Source/SPConnectionController.h
  2. +12 −0 Source/SPConnectionController.m
  3. +3 −20 Source/SPDatabaseDocument.m
@@ -221,6 +221,8 @@
@property (readonly, assign) BOOL isConnecting;
@property (readonly, assign) BOOL isEditingConnection;
- (NSString *)keychainPassword;
// Connection processes
- (IBAction)initiateConnection:(id)sender;
- (IBAction)cancelConnection:(id)sender;
@@ -176,6 +176,18 @@ @implementation SPConnectionController
@synthesize isConnecting;
@synthesize isEditingConnection;
- (NSString *)keychainPassword
{
NSString *kcItemName = [self connectionKeychainItemName];
// If no keychain item is available, return an empty password
if (!kcItemName) return nil;
// Otherwise, pull the password from the keychain using the details from this connection
NSString *kcPassword = [keychain getPasswordForName:kcItemName account:[self connectionKeychainItemAccount]];
return kcPassword;
}
#pragma mark -
#pragma mark Connection processes
@@ -119,7 +119,6 @@ - (void)_loadTableTask;
- (void) closeAndDisconnect;
- (NSString *)keychainPassword;
- (NSString *)keychainPasswordForSSHConnection:(SPMySQLConnection *)connection;
@end
@@ -4672,7 +4671,7 @@ - (NSDictionary *) stateIncludingDetails:(NSDictionary *)detailsToReturn
[connection setObject:[self database] forKey:@"database"];
if (includePasswords) {
NSString *pw = [self keychainPassword];
NSString *pw = [connectionController keychainPassword];
if (!pw) pw = [connectionController password];
if (pw) [connection setObject:pw forKey:@"password"];
@@ -4871,7 +4870,7 @@ - (BOOL)setState:(NSDictionary *)stateDetails fromFile:(BOOL)spfBased
if ([connection objectForKey:@"password"])
[connectionController setPassword:[connection objectForKey:@"password"]];
else {
NSString *pw = [self keychainPassword];
NSString *pw = [connectionController keychainPassword];
if (pw) [connectionController setPassword:pw];
}
@@ -7138,23 +7137,7 @@ - (void)queryGaveError:(NSString *)error connection:(id)connection
- (NSString *)keychainPasswordForConnection:(SPMySQLConnection *)connection authPlugin:(NSString *)pluginName
{
//TODO check plugin name to see whether we want to fetch it from keychain
return [self keychainPassword];
}
- (NSString *)keychainPassword
{
NSString *kcItemName = [connectionController connectionKeychainItemName];
// If no keychain item is available, return an empty password
if (!kcItemName) return nil;
// Otherwise, pull the password from the keychain using the details from this connection
SPKeychain *keychain = [[SPKeychain alloc] init];
NSString *password = [keychain getPasswordForName:kcItemName account:[connectionController connectionKeychainItemAccount]];
[keychain release];
return password;
return [connectionController keychainPassword];
}
/**

0 comments on commit 770c189

Please sign in to comment.