change sshPublicKeyPath to sshPublicKeyURL

This commit is contained in:
Bob Sun 2017-02-08 19:31:42 +08:00
parent b73605ee9e
commit 7effaa841a
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
4 changed files with 8 additions and 8 deletions

View file

@ -11,8 +11,8 @@ import Foundation
class Globals {
static let documentPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0];
static let secringPath = "\(documentPath)/secring.gpg"
static let sshPublicKeyPath = URL(fileURLWithPath: "\(documentPath)/ssh_key.pub")
static let sshPrivateKeyPath = URL(fileURLWithPath: "\(documentPath)/ssh_key")
static let sshPublicKeyURL = URL(fileURLWithPath: "\(documentPath)/ssh_key.pub")
static let sshPrivateKeyURL = URL(fileURLWithPath: "\(documentPath)/ssh_key")
static var passcodeConfiguration = PasscodeLockConfiguration()
private init() { }
}

View file

@ -63,7 +63,7 @@ class PasswordStore {
if Defaults[.gitRepositoryAuthenticationMethod] == "Password" {
gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: Defaults[.gitRepositoryUsername], password: Defaults[.gitRepositoryPassword]))
} else if Defaults[.gitRepositoryAuthenticationMethod] == "SSH Key"{
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: Defaults[.gitRepositoryUsername], password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Globals.sshPublicKeyPath, privateKeyFile: Globals.sshPrivateKeyPath))
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: Defaults[.gitRepositoryUsername], password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Globals.sshPublicKeyURL, privateKeyFile: Globals.sshPrivateKeyURL))
} else {
gitCredential = nil
}
@ -186,8 +186,8 @@ class PasswordStore {
func erase() {
Utils.removeFileIfExists(at: storeURL)
Utils.removeFileIfExists(atPath: Globals.secringPath)
Utils.removeFileIfExists(at: Globals.sshPrivateKeyPath)
Utils.removeFileIfExists(at: Globals.sshPublicKeyPath)
Utils.removeFileIfExists(at: Globals.sshPrivateKeyURL)
Utils.removeFileIfExists(at: Globals.sshPublicKeyURL)
deleteCoreData(entityName: "PasswordEntity")
deleteCoreData(entityName: "PasswordCategoryEntity")

View file

@ -36,8 +36,8 @@ class SSHKeySettingTableViewController: UITableViewController {
Defaults[.gitRepositorySSHPrivateKeyPassphrase] = passphraseTextField.text!
do {
try Data(contentsOf: Defaults[.gitRepositorySSHPublicKeyURL]!).write(to: Globals.sshPublicKeyPath, options: .atomic)
try Data(contentsOf: Defaults[.gitRepositorySSHPrivateKeyURL]!).write(to: Globals.sshPrivateKeyPath, options: .atomic)
try Data(contentsOf: Defaults[.gitRepositorySSHPublicKeyURL]!).write(to: Globals.sshPublicKeyURL, options: .atomic)
try Data(contentsOf: Defaults[.gitRepositorySSHPrivateKeyURL]!).write(to: Globals.sshPrivateKeyURL, options: .atomic)
} catch {
print(error)
}

View file

@ -37,7 +37,7 @@ class SettingsTableViewController: UITableViewController {
if auth == "Password" {
gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password))
} else {
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: username, password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Globals.sshPublicKeyPath, privateKeyFile: Globals.sshPrivateKeyPath))
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: username, password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Globals.sshPublicKeyURL, privateKeyFile: Globals.sshPrivateKeyURL))
}
DispatchQueue.global(qos: .userInitiated).async {