Remove imported keys from iTunes Documents (fix #97)
This commit is contained in:
parent
fb5f689540
commit
3b562da607
4 changed files with 53 additions and 17 deletions
|
|
@ -33,6 +33,11 @@ public class Globals {
|
|||
public static let gitSSHPrivateKeyURL = URL(fileURLWithPath: gitSSHPrivateKeyPath)
|
||||
public static let repositoryPath = libraryPath + "/password-store"
|
||||
|
||||
public static let iTunesFileSharingPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
|
||||
public static let iTunesFileSharingPGPPublic = iTunesFileSharingPath + "/gpg_key.pub"
|
||||
public static let iTunesFileSharingPGPPrivate = iTunesFileSharingPath + "/gpg_key"
|
||||
public static let iTunesFileSharingSSHPrivate = iTunesFileSharingPath + "/ssh_key"
|
||||
|
||||
public static let passwordDefaultLength = ["Random": (min: 4, max: 64, def: 16),
|
||||
"Apple": (min: 15, max: 15, def: 15)]
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ public class PasswordStore {
|
|||
}
|
||||
return size
|
||||
}
|
||||
|
||||
|
||||
private init() {
|
||||
// File migration to group
|
||||
|
|
@ -852,11 +851,36 @@ public class PasswordStore {
|
|||
Utils.removeKeychain(name: ".gitSSHPrivateKeyPassphrase")
|
||||
}
|
||||
|
||||
public func gitSSHKeyExists() -> Bool {
|
||||
return fm.fileExists(atPath: Globals.gitSSHPrivateKeyPath)
|
||||
public func gitSSHKeyExists(inFileSharing: Bool = false) -> Bool {
|
||||
if inFileSharing == false {
|
||||
return fm.fileExists(atPath: Globals.gitSSHPrivateKeyPath)
|
||||
} else {
|
||||
return fm.fileExists(atPath: Globals.iTunesFileSharingSSHPrivate)
|
||||
}
|
||||
}
|
||||
|
||||
public func pgpKeyExists() -> Bool {
|
||||
return fm.fileExists(atPath: Globals.pgpPublicKeyPath) && fm.fileExists(atPath: Globals.pgpPrivateKeyPath)
|
||||
public func pgpKeyExists(inFileSharing: Bool = false) -> Bool {
|
||||
if inFileSharing == false {
|
||||
return fm.fileExists(atPath: Globals.pgpPublicKeyPath) && fm.fileExists(atPath: Globals.pgpPrivateKeyPath)
|
||||
} else {
|
||||
return fm.fileExists(atPath: Globals.iTunesFileSharingPGPPublic) && fm.fileExists(atPath: Globals.iTunesFileSharingPGPPrivate)
|
||||
}
|
||||
}
|
||||
|
||||
public func gitSSHKeyImportFromFileSharing() {
|
||||
do {
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingSSHPrivate, toPath: Globals.gitSSHPrivateKeyPath)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
public func pgpKeyImportFromFileSharing() {
|
||||
do {
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPublic, toPath: Globals.pgpPublicKeyPath)
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPrivate, toPath: Globals.pgpPrivateKeyPath)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue