aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2018-02-23 01:28:10 +0100
committerMax <post@wickenrode.com>2018-02-23 01:28:10 +0100
commit770c18901f82696d1233e0139e9bb3c4fbbcb90b (patch)
tree29fd527b0c13a297fb522a0cf79ba7a89ed3ba93
parentfcb696ae383149f0abfb88a9d4b2ae21d91f3c3b (diff)
downloadsequelpro-770c18901f82696d1233e0139e9bb3c4fbbcb90b.tar.gz
sequelpro-770c18901f82696d1233e0139e9bb3c4fbbcb90b.tar.bz2
sequelpro-770c18901f82696d1233e0139e9bb3c4fbbcb90b.zip
Move method -keychainPassword from SPDatabaseDocument to SPConnectionController since all it did was request info from the connection controller
-rw-r--r--Source/SPConnectionController.h2
-rw-r--r--Source/SPConnectionController.m12
-rw-r--r--Source/SPDatabaseDocument.m23
3 files changed, 17 insertions, 20 deletions
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h
index 2da8f58a..03f8fc3b 100644
--- a/Source/SPConnectionController.h
+++ b/Source/SPConnectionController.h
@@ -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;
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 018ecf93..02f68b06 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -176,6 +176,18 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
@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
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index ccf1cb34..39687de1 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -119,7 +119,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
- (void) closeAndDisconnect;
-- (NSString *)keychainPassword;
- (NSString *)keychainPasswordForSSHConnection:(SPMySQLConnection *)connection;
@end
@@ -4672,7 +4671,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
[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 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
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 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
- (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];
}
/**