Initial implementation of using YubiKey for decryption (#533)
This commit is contained in:
parent
13804b79e6
commit
955e50c3d3
23 changed files with 606 additions and 118 deletions
|
|
@ -6,6 +6,8 @@
|
|||
// Copyright © 2017 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum AppError: Error, Equatable {
|
||||
case repositoryNotSet
|
||||
case repositoryRemoteBranchNotFound(branchName: String)
|
||||
|
|
@ -18,13 +20,31 @@ public enum AppError: Error, Equatable {
|
|||
case gitPushNotSuccessful
|
||||
case pgpPublicKeyNotFound(keyID: String)
|
||||
case pgpPrivateKeyNotFound(keyID: String)
|
||||
case yubiKey(YubiKeyError)
|
||||
case passwordFileNotFound(path: String)
|
||||
case keyExpiredOrIncompatible
|
||||
case wrongPassphrase
|
||||
case wrongPasswordFilename
|
||||
case decryption
|
||||
case encryption
|
||||
case encoding
|
||||
case unknown
|
||||
case other(message: String)
|
||||
}
|
||||
|
||||
public enum YubiKeyError: Error, Equatable {
|
||||
case connection(message: String)
|
||||
case selectApplication(message: String)
|
||||
case verify(message: String)
|
||||
case decipher(message: String)
|
||||
}
|
||||
|
||||
extension YubiKeyError: LocalizedError {
|
||||
public var errorDescription: String? {
|
||||
switch self {
|
||||
case let .connection(message), let .decipher(message), let .selectApplication(message), let .verify(message):
|
||||
return message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension AppError: LocalizedError {
|
||||
|
|
@ -36,6 +56,8 @@ extension AppError: LocalizedError {
|
|||
return localizationKey.localize(name)
|
||||
case let .pgpPrivateKeyNotFound(keyID), let .pgpPublicKeyNotFound(keyID):
|
||||
return localizationKey.localize(keyID)
|
||||
case let .other(message):
|
||||
return message.localize()
|
||||
default:
|
||||
return localizationKey.localize()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue