|
@@ -158,8 +158,8 @@ public class Keychain {
|
|
return options.accessibility
|
|
return options.accessibility
|
|
}
|
|
}
|
|
|
|
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
- @availability(OSX, introduced=10.10)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
|
|
+ @available(OSX, introduced=10.10)
|
|
public var authenticationPolicy: AuthenticationPolicy? {
|
|
public var authenticationPolicy: AuthenticationPolicy? {
|
|
return options.authenticationPolicy
|
|
return options.authenticationPolicy
|
|
}
|
|
}
|
|
@@ -176,8 +176,8 @@ public class Keychain {
|
|
return options.comment
|
|
return options.comment
|
|
}
|
|
}
|
|
|
|
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
- @availability(OSX, unavailable)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
|
|
+ @available(OSX, unavailable)
|
|
public var authenticationPrompt: String? {
|
|
public var authenticationPrompt: String? {
|
|
return options.authenticationPrompt
|
|
return options.authenticationPrompt
|
|
}
|
|
}
|
|
@@ -254,8 +254,8 @@ public class Keychain {
|
|
return Keychain(options)
|
|
return Keychain(options)
|
|
}
|
|
}
|
|
|
|
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
- @availability(OSX, introduced=10.10)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
|
|
+ @available(OSX, introduced=10.10)
|
|
public func accessibility(accessibility: Accessibility, authenticationPolicy: AuthenticationPolicy) -> Keychain {
|
|
public func accessibility(accessibility: Accessibility, authenticationPolicy: AuthenticationPolicy) -> Keychain {
|
|
var options = self.options
|
|
var options = self.options
|
|
options.accessibility = accessibility
|
|
options.accessibility = accessibility
|
|
@@ -281,8 +281,8 @@ public class Keychain {
|
|
return Keychain(options)
|
|
return Keychain(options)
|
|
}
|
|
}
|
|
|
|
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
- @availability(OSX, unavailable)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
|
|
+ @available(OSX, unavailable)
|
|
public func authenticationPrompt(authenticationPrompt: String) -> Keychain {
|
|
public func authenticationPrompt(authenticationPrompt: String) -> Keychain {
|
|
var options = self.options
|
|
var options = self.options
|
|
options.authenticationPrompt = authenticationPrompt
|
|
options.authenticationPrompt = authenticationPrompt
|
|
@@ -325,13 +325,13 @@ public class Keychain {
|
|
public func getDataOrError(key: String) -> FailableOf<NSData> {
|
|
public func getDataOrError(key: String) -> FailableOf<NSData> {
|
|
var query = options.query()
|
|
var query = options.query()
|
|
|
|
|
|
- query[kSecMatchLimit as! String] = kSecMatchLimitOne
|
|
|
|
- query[kSecReturnData as! String] = kCFBooleanTrue
|
|
|
|
|
|
+ query[kSecMatchLimit as String] = kSecMatchLimitOne
|
|
|
|
+ query[kSecReturnData as String] = kCFBooleanTrue
|
|
|
|
|
|
- query[kSecAttrAccount as! String] = key
|
|
|
|
|
|
+ query[kSecAttrAccount as String] = key
|
|
|
|
|
|
var result: AnyObject?
|
|
var result: AnyObject?
|
|
- var status = withUnsafeMutablePointer(&result) { SecItemCopyMatching(query, UnsafeMutablePointer($0)) }
|
|
|
|
|
|
+ let status = withUnsafeMutablePointer(&result) { SecItemCopyMatching(query, UnsafeMutablePointer($0)) }
|
|
|
|
|
|
switch status {
|
|
switch status {
|
|
case errSecSuccess:
|
|
case errSecSuccess:
|
|
@@ -359,10 +359,10 @@ public class Keychain {
|
|
public func set(value: NSData, key: String) -> NSError? {
|
|
public func set(value: NSData, key: String) -> NSError? {
|
|
var query = options.query()
|
|
var query = options.query()
|
|
|
|
|
|
- query[kSecAttrAccount as! String] = key
|
|
|
|
|
|
+ query[kSecAttrAccount as String] = key
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
if floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_7_1) {
|
|
if floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_7_1) {
|
|
- query[kSecUseNoAuthenticationUI as! String] = kCFBooleanTrue
|
|
|
|
|
|
+ query[kSecUseNoAuthenticationUI as String] = kCFBooleanTrue
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -370,15 +370,15 @@ public class Keychain {
|
|
switch status {
|
|
switch status {
|
|
case errSecSuccess, errSecInteractionNotAllowed:
|
|
case errSecSuccess, errSecInteractionNotAllowed:
|
|
var query = options.query()
|
|
var query = options.query()
|
|
- query[kSecAttrAccount as! String] = key
|
|
|
|
|
|
+ query[kSecAttrAccount as String] = key
|
|
|
|
|
|
- var (attributes, error) = options.attributes(key: nil, value: value)
|
|
|
|
- if var error = error {
|
|
|
|
- println("error:[\(error.code)] \(error.localizedDescription)")
|
|
|
|
|
|
+ let (attributes, error) = options.attributes(key: nil, value: value)
|
|
|
|
+ if let error = error {
|
|
|
|
+ print("error:[\(error.code)] \(error.localizedDescription)")
|
|
return error
|
|
return error
|
|
} else {
|
|
} else {
|
|
if status == errSecInteractionNotAllowed && floor(NSFoundationVersionNumber) <= floor(NSFoundationVersionNumber_iOS_8_0) {
|
|
if status == errSecInteractionNotAllowed && floor(NSFoundationVersionNumber) <= floor(NSFoundationVersionNumber_iOS_8_0) {
|
|
- var error = remove(key)
|
|
|
|
|
|
+ let error = remove(key)
|
|
if error != nil {
|
|
if error != nil {
|
|
return error
|
|
return error
|
|
} else {
|
|
} else {
|
|
@@ -392,9 +392,9 @@ public class Keychain {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
case errSecItemNotFound:
|
|
case errSecItemNotFound:
|
|
- var (attributes, error) = options.attributes(key: key, value: value)
|
|
|
|
- if var error = error {
|
|
|
|
- println("error:[\(error.code)] \(error.localizedDescription)")
|
|
|
|
|
|
+ let (attributes, error) = options.attributes(key: key, value: value)
|
|
|
|
+ if let error = error {
|
|
|
|
+ print("error:[\(error.code)] \(error.localizedDescription)")
|
|
return error
|
|
return error
|
|
} else {
|
|
} else {
|
|
status = SecItemAdd(attributes, nil)
|
|
status = SecItemAdd(attributes, nil)
|
|
@@ -412,7 +412,7 @@ public class Keychain {
|
|
|
|
|
|
public func remove(key: String) -> NSError? {
|
|
public func remove(key: String) -> NSError? {
|
|
var query = options.query()
|
|
var query = options.query()
|
|
- query[kSecAttrAccount as! String] = key
|
|
|
|
|
|
+ query[kSecAttrAccount as String] = key
|
|
|
|
|
|
let status = SecItemDelete(query)
|
|
let status = SecItemDelete(query)
|
|
if status != errSecSuccess && status != errSecItemNotFound {
|
|
if status != errSecSuccess && status != errSecItemNotFound {
|
|
@@ -438,9 +438,9 @@ public class Keychain {
|
|
|
|
|
|
public func contains(key: String) -> Bool {
|
|
public func contains(key: String) -> Bool {
|
|
var query = options.query()
|
|
var query = options.query()
|
|
- query[kSecAttrAccount as! String] = key
|
|
|
|
|
|
+ query[kSecAttrAccount as String] = key
|
|
|
|
|
|
- var status = SecItemCopyMatching(query, nil)
|
|
|
|
|
|
+ let status = SecItemCopyMatching(query, nil)
|
|
|
|
|
|
switch status {
|
|
switch status {
|
|
case errSecSuccess:
|
|
case errSecSuccess:
|
|
@@ -501,12 +501,12 @@ public class Keychain {
|
|
|
|
|
|
public class func allKeys(itemClass: ItemClass) -> [(String, String)] {
|
|
public class func allKeys(itemClass: ItemClass) -> [(String, String)] {
|
|
var query = [String: AnyObject]()
|
|
var query = [String: AnyObject]()
|
|
- query[kSecClass as! String] = itemClass.rawValue
|
|
|
|
- query[kSecMatchLimit as! String] = kSecMatchLimitAll
|
|
|
|
- query[kSecReturnAttributes as! String] = kCFBooleanTrue
|
|
|
|
|
|
+ query[kSecClass as String] = itemClass.rawValue
|
|
|
|
+ query[kSecMatchLimit as String] = kSecMatchLimitAll
|
|
|
|
+ query[kSecReturnAttributes as String] = kCFBooleanTrue
|
|
|
|
|
|
var result: AnyObject?
|
|
var result: AnyObject?
|
|
- var status = withUnsafeMutablePointer(&result) { SecItemCopyMatching(query, UnsafeMutablePointer($0)) }
|
|
|
|
|
|
+ let status = withUnsafeMutablePointer(&result) { SecItemCopyMatching(query, UnsafeMutablePointer($0)) }
|
|
|
|
|
|
switch status {
|
|
switch status {
|
|
case errSecSuccess:
|
|
case errSecSuccess:
|
|
@@ -535,15 +535,15 @@ public class Keychain {
|
|
|
|
|
|
public class func allItems(itemClass: ItemClass) -> [[String: AnyObject]] {
|
|
public class func allItems(itemClass: ItemClass) -> [[String: AnyObject]] {
|
|
var query = [String: AnyObject]()
|
|
var query = [String: AnyObject]()
|
|
- query[kSecClass as! String] = itemClass.rawValue
|
|
|
|
- query[kSecMatchLimit as! String] = kSecMatchLimitAll
|
|
|
|
- query[kSecReturnAttributes as! String] = kCFBooleanTrue
|
|
|
|
|
|
+ query[kSecClass as String] = itemClass.rawValue
|
|
|
|
+ query[kSecMatchLimit as String] = kSecMatchLimitAll
|
|
|
|
+ query[kSecReturnAttributes as String] = kCFBooleanTrue
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- query[kSecReturnData as! String] = kCFBooleanTrue
|
|
|
|
|
|
+ query[kSecReturnData as String] = kCFBooleanTrue
|
|
#endif
|
|
#endif
|
|
|
|
|
|
var result: AnyObject?
|
|
var result: AnyObject?
|
|
- var status = withUnsafeMutablePointer(&result) { SecItemCopyMatching(query, UnsafeMutablePointer($0)) }
|
|
|
|
|
|
+ let status = withUnsafeMutablePointer(&result) { SecItemCopyMatching(query, UnsafeMutablePointer($0)) }
|
|
|
|
|
|
switch status {
|
|
switch status {
|
|
case errSecSuccess:
|
|
case errSecSuccess:
|
|
@@ -564,7 +564,7 @@ public class Keychain {
|
|
}
|
|
}
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
public func getSharedPassword(completion: (account: String?, password: String?, error: NSError?) -> () = { account, password, error -> () in }) {
|
|
public func getSharedPassword(completion: (account: String?, password: String?, error: NSError?) -> () = { account, password, error -> () in }) {
|
|
if let domain = server.host {
|
|
if let domain = server.host {
|
|
self.dynamicType.requestSharedWebCredential(domain: domain, account: nil) { (credentials, error) -> () in
|
|
self.dynamicType.requestSharedWebCredential(domain: domain, account: nil) { (credentials, error) -> () in
|
|
@@ -584,7 +584,7 @@ public class Keychain {
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
public func getSharedPassword(account: String, completion: (password: String?, error: NSError?) -> () = { password, error -> () in }) {
|
|
public func getSharedPassword(account: String, completion: (password: String?, error: NSError?) -> () = { password, error -> () in }) {
|
|
if let domain = server.host {
|
|
if let domain = server.host {
|
|
self.dynamicType.requestSharedWebCredential(domain: domain, account: account) { (credentials, error) -> () in
|
|
self.dynamicType.requestSharedWebCredential(domain: domain, account: account) { (credentials, error) -> () in
|
|
@@ -606,7 +606,7 @@ public class Keychain {
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
public func setSharedPassword(password: String, account: String, completion: (error: NSError?) -> () = { e -> () in }) {
|
|
public func setSharedPassword(password: String, account: String, completion: (error: NSError?) -> () = { e -> () in }) {
|
|
setSharedPassword(password as String?, account: account, completion: completion)
|
|
setSharedPassword(password as String?, account: account, completion: completion)
|
|
}
|
|
}
|
|
@@ -630,53 +630,53 @@ public class Keychain {
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
public func removeSharedPassword(account: String, completion: (error: NSError?) -> () = { e -> () in }) {
|
|
public func removeSharedPassword(account: String, completion: (error: NSError?) -> () = { e -> () in }) {
|
|
setSharedPassword(nil, account: account, completion: completion)
|
|
setSharedPassword(nil, account: account, completion: completion)
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
public class func requestSharedWebCredential(completion: (credentials: [[String: String]], error: NSError?) -> () = { credentials, error -> () in }) {
|
|
public class func requestSharedWebCredential(completion: (credentials: [[String: String]], error: NSError?) -> () = { credentials, error -> () in }) {
|
|
requestSharedWebCredential(domain: nil, account: nil, completion: completion)
|
|
requestSharedWebCredential(domain: nil, account: nil, completion: completion)
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
- public class func requestSharedWebCredential(#domain: String, completion: (credentials: [[String: String]], error: NSError?) -> () = { credentials, error -> () in }) {
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
|
|
+ public class func requestSharedWebCredential(domain domain: String, completion: (credentials: [[String: String]], error: NSError?) -> () = { credentials, error -> () in }) {
|
|
requestSharedWebCredential(domain: domain, account: nil, completion: completion)
|
|
requestSharedWebCredential(domain: domain, account: nil, completion: completion)
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
- public class func requestSharedWebCredential(#domain: String, account: String, completion: (credentials: [[String: String]], error: NSError?) -> () = { credentials, error -> () in }) {
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
|
|
+ public class func requestSharedWebCredential(domain domain: String, account: String, completion: (credentials: [[String: String]], error: NSError?) -> () = { credentials, error -> () in }) {
|
|
requestSharedWebCredential(domain: domain as String?, account: account as String?, completion: completion)
|
|
requestSharedWebCredential(domain: domain as String?, account: account as String?, completion: completion)
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- private class func requestSharedWebCredential(#domain: String?, account: String?, completion: (credentials: [[String: String]], error: NSError?) -> ()) {
|
|
|
|
|
|
+ private class func requestSharedWebCredential(domain domain: String?, account: String?, completion: (credentials: [[String: String]], error: NSError?) -> ()) {
|
|
SecRequestSharedWebCredential(domain, account) { (credentials, error) -> () in
|
|
SecRequestSharedWebCredential(domain, account) { (credentials, error) -> () in
|
|
var remoteError: NSError?
|
|
var remoteError: NSError?
|
|
if let error = error {
|
|
if let error = error {
|
|
remoteError = error.error
|
|
remoteError = error.error
|
|
if remoteError?.code != Int(errSecItemNotFound) {
|
|
if remoteError?.code != Int(errSecItemNotFound) {
|
|
- println("error:[\(remoteError!.code)] \(remoteError!.localizedDescription)")
|
|
|
|
|
|
+ print("error:[\(remoteError!.code)] \(remoteError!.localizedDescription)")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if let credentials = credentials as? [[String: AnyObject]] {
|
|
if let credentials = credentials as? [[String: AnyObject]] {
|
|
let credentials = credentials.map { credentials -> [String: String] in
|
|
let credentials = credentials.map { credentials -> [String: String] in
|
|
var credential = [String: String]()
|
|
var credential = [String: String]()
|
|
- if let server = credentials[kSecAttrServer as! String] as? String {
|
|
|
|
|
|
+ if let server = credentials[kSecAttrServer as String] as? String {
|
|
credential["server"] = server
|
|
credential["server"] = server
|
|
}
|
|
}
|
|
- if let account = credentials[kSecAttrAccount as! String] as? String {
|
|
|
|
|
|
+ if let account = credentials[kSecAttrAccount as String] as? String {
|
|
credential["account"] = account
|
|
credential["account"] = account
|
|
}
|
|
}
|
|
- if let password = credentials[kSecSharedPassword.takeUnretainedValue() as! String] as? String {
|
|
|
|
|
|
+ if let password = credentials[kSecSharedPassword as String] as? String {
|
|
credential["password"] = password
|
|
credential["password"] = password
|
|
}
|
|
}
|
|
return credential
|
|
return credential
|
|
@@ -690,9 +690,9 @@ public class Keychain {
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- @availability(iOS, introduced=8.0)
|
|
|
|
|
|
+ @available(iOS, introduced=8.0)
|
|
public class func generatePassword() -> String {
|
|
public class func generatePassword() -> String {
|
|
- return SecCreateSharedWebCredentialPassword().takeUnretainedValue() as! String
|
|
|
|
|
|
+ return SecCreateSharedWebCredentialPassword().takeUnretainedValue() as String
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -700,14 +700,14 @@ public class Keychain {
|
|
|
|
|
|
private func items() -> [[String: AnyObject]] {
|
|
private func items() -> [[String: AnyObject]] {
|
|
var query = options.query()
|
|
var query = options.query()
|
|
- query[kSecMatchLimit as! String] = kSecMatchLimitAll
|
|
|
|
- query[kSecReturnAttributes as! String] = kCFBooleanTrue
|
|
|
|
|
|
+ query[kSecMatchLimit as String] = kSecMatchLimitAll
|
|
|
|
+ query[kSecReturnAttributes as String] = kCFBooleanTrue
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- query[kSecReturnData as! String] = kCFBooleanTrue
|
|
|
|
|
|
+ query[kSecReturnData as String] = kCFBooleanTrue
|
|
#endif
|
|
#endif
|
|
|
|
|
|
var result: AnyObject?
|
|
var result: AnyObject?
|
|
- var status = withUnsafeMutablePointer(&result) { SecItemCopyMatching(query, UnsafeMutablePointer($0)) }
|
|
|
|
|
|
+ let status = withUnsafeMutablePointer(&result) { SecItemCopyMatching(query, UnsafeMutablePointer($0)) }
|
|
|
|
|
|
switch status {
|
|
switch status {
|
|
case errSecSuccess:
|
|
case errSecSuccess:
|
|
@@ -723,7 +723,7 @@ public class Keychain {
|
|
return []
|
|
return []
|
|
}
|
|
}
|
|
|
|
|
|
- private class func prettify(#itemClass: ItemClass, items: [[String: AnyObject]]) -> [[String: AnyObject]] {
|
|
|
|
|
|
+ private class func prettify(itemClass itemClass: ItemClass, items: [[String: AnyObject]]) -> [[String: AnyObject]] {
|
|
let items = items.map { attributes -> [String: AnyObject] in
|
|
let items = items.map { attributes -> [String: AnyObject] in
|
|
var item = [String: AnyObject]()
|
|
var item = [String: AnyObject]()
|
|
|
|
|
|
@@ -731,32 +731,32 @@ public class Keychain {
|
|
|
|
|
|
switch itemClass {
|
|
switch itemClass {
|
|
case .GenericPassword:
|
|
case .GenericPassword:
|
|
- if let service = attributes[kSecAttrService as! String] as? String {
|
|
|
|
|
|
+ if let service = attributes[kSecAttrService as String] as? String {
|
|
item["service"] = service
|
|
item["service"] = service
|
|
}
|
|
}
|
|
- if let accessGroup = attributes[kSecAttrAccessGroup as! String] as? String {
|
|
|
|
|
|
+ if let accessGroup = attributes[kSecAttrAccessGroup as String] as? String {
|
|
item["accessGroup"] = accessGroup
|
|
item["accessGroup"] = accessGroup
|
|
}
|
|
}
|
|
case .InternetPassword:
|
|
case .InternetPassword:
|
|
- if let server = attributes[kSecAttrServer as! String] as? String {
|
|
|
|
|
|
+ if let server = attributes[kSecAttrServer as String] as? String {
|
|
item["server"] = server
|
|
item["server"] = server
|
|
}
|
|
}
|
|
- if let proto = attributes[kSecAttrProtocol as! String] as? String {
|
|
|
|
|
|
+ if let proto = attributes[kSecAttrProtocol as String] as? String {
|
|
if let protocolType = ProtocolType(rawValue: proto) {
|
|
if let protocolType = ProtocolType(rawValue: proto) {
|
|
item["protocol"] = protocolType.description
|
|
item["protocol"] = protocolType.description
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if let auth = attributes[kSecAttrAuthenticationType as! String] as? String {
|
|
|
|
|
|
+ if let auth = attributes[kSecAttrAuthenticationType as String] as? String {
|
|
if let authenticationType = AuthenticationType(rawValue: auth) {
|
|
if let authenticationType = AuthenticationType(rawValue: auth) {
|
|
item["authenticationType"] = authenticationType.description
|
|
item["authenticationType"] = authenticationType.description
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if let key = attributes[kSecAttrAccount as! String] as? String {
|
|
|
|
|
|
+ if let key = attributes[kSecAttrAccount as String] as? String {
|
|
item["key"] = key
|
|
item["key"] = key
|
|
}
|
|
}
|
|
- if let data = attributes[kSecValueData as! String] as? NSData {
|
|
|
|
|
|
+ if let data = attributes[kSecValueData as String] as? NSData {
|
|
if let text = NSString(data: data, encoding: NSUTF8StringEncoding) as? String {
|
|
if let text = NSString(data: data, encoding: NSUTF8StringEncoding) as? String {
|
|
item["value"] = text
|
|
item["value"] = text
|
|
} else {
|
|
} else {
|
|
@@ -764,12 +764,12 @@ public class Keychain {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if let accessible = attributes[kSecAttrAccessible as! String] as? String {
|
|
|
|
|
|
+ if let accessible = attributes[kSecAttrAccessible as String] as? String {
|
|
if let accessibility = Accessibility(rawValue: accessible) {
|
|
if let accessibility = Accessibility(rawValue: accessible) {
|
|
item["accessibility"] = accessibility.description
|
|
item["accessibility"] = accessibility.description
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if let synchronizable = attributes[kSecAttrSynchronizable as! String] as? Bool {
|
|
|
|
|
|
+ if let synchronizable = attributes[kSecAttrSynchronizable as String] as? Bool {
|
|
item["synchronizable"] = synchronizable ? "true" : "false"
|
|
item["synchronizable"] = synchronizable ? "true" : "false"
|
|
}
|
|
}
|
|
|
|
|
|
@@ -780,27 +780,27 @@ public class Keychain {
|
|
|
|
|
|
// MARK:
|
|
// MARK:
|
|
|
|
|
|
- private class func conversionError(#message: String) -> NSError {
|
|
|
|
|
|
+ private class func conversionError(message message: String) -> NSError {
|
|
let error = NSError(domain: KeychainAccessErrorDomain, code: Int(Status.ConversionError.rawValue), userInfo: [NSLocalizedDescriptionKey: message])
|
|
let error = NSError(domain: KeychainAccessErrorDomain, code: Int(Status.ConversionError.rawValue), userInfo: [NSLocalizedDescriptionKey: message])
|
|
- println("error:[\(error.code)] \(error.localizedDescription)")
|
|
|
|
|
|
+ print("error:[\(error.code)] \(error.localizedDescription)")
|
|
|
|
|
|
return error
|
|
return error
|
|
}
|
|
}
|
|
|
|
|
|
- private func conversionError(#message: String) -> NSError {
|
|
|
|
|
|
+ private func conversionError(message message: String) -> NSError {
|
|
return self.dynamicType.conversionError(message: message)
|
|
return self.dynamicType.conversionError(message: message)
|
|
}
|
|
}
|
|
|
|
|
|
- private class func securityError(#status: OSStatus) -> NSError {
|
|
|
|
|
|
+ private class func securityError(status status: OSStatus) -> NSError {
|
|
let message = Status(rawValue: status)!.description
|
|
let message = Status(rawValue: status)!.description
|
|
|
|
|
|
let error = NSError(domain: KeychainAccessErrorDomain, code: Int(status), userInfo: [NSLocalizedDescriptionKey: message])
|
|
let error = NSError(domain: KeychainAccessErrorDomain, code: Int(status), userInfo: [NSLocalizedDescriptionKey: message])
|
|
- println("OSStatus error:[\(error.code)] \(error.localizedDescription)")
|
|
|
|
|
|
+ print("OSStatus error:[\(error.code)] \(error.localizedDescription)")
|
|
|
|
|
|
return error
|
|
return error
|
|
}
|
|
}
|
|
|
|
|
|
- private func securityError(#status: OSStatus) -> NSError {
|
|
|
|
|
|
+ private func securityError(status status: OSStatus) -> NSError {
|
|
return self.dynamicType.securityError(status: status)
|
|
return self.dynamicType.securityError(status: status)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -828,7 +828,7 @@ struct Options {
|
|
init() {}
|
|
init() {}
|
|
}
|
|
}
|
|
|
|
|
|
-extension Keychain : Printable, DebugPrintable {
|
|
|
|
|
|
+extension Keychain : CustomStringConvertible, CustomDebugStringConvertible {
|
|
public var description: String {
|
|
public var description: String {
|
|
let items = allItems()
|
|
let items = allItems()
|
|
if items.isEmpty {
|
|
if items.isEmpty {
|
|
@@ -853,30 +853,30 @@ extension Options {
|
|
func query() -> [String: AnyObject] {
|
|
func query() -> [String: AnyObject] {
|
|
var query = [String: AnyObject]()
|
|
var query = [String: AnyObject]()
|
|
|
|
|
|
- query[kSecClass as! String] = itemClass.rawValue
|
|
|
|
- query[kSecAttrSynchronizable as! String] = kSecAttrSynchronizableAny
|
|
|
|
|
|
+ query[kSecClass as String] = itemClass.rawValue
|
|
|
|
+ query[kSecAttrSynchronizable as String] = kSecAttrSynchronizableAny
|
|
|
|
|
|
switch itemClass {
|
|
switch itemClass {
|
|
case .GenericPassword:
|
|
case .GenericPassword:
|
|
- query[kSecAttrService as! String] = service
|
|
|
|
|
|
+ query[kSecAttrService as String] = service
|
|
#if (!arch(i386) && !arch(x86_64)) || !os(iOS)
|
|
#if (!arch(i386) && !arch(x86_64)) || !os(iOS)
|
|
if let accessGroup = self.accessGroup {
|
|
if let accessGroup = self.accessGroup {
|
|
query[kSecAttrAccessGroup as! String] = accessGroup
|
|
query[kSecAttrAccessGroup as! String] = accessGroup
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
case .InternetPassword:
|
|
case .InternetPassword:
|
|
- query[kSecAttrServer as! String] = server.host
|
|
|
|
- query[kSecAttrPort as! String] = server.port
|
|
|
|
- query[kSecAttrProtocol as! String] = protocolType.rawValue
|
|
|
|
- query[kSecAttrAuthenticationType as! String] = authenticationType.rawValue
|
|
|
|
|
|
+ query[kSecAttrServer as String] = server.host
|
|
|
|
+ query[kSecAttrPort as String] = server.port
|
|
|
|
+ query[kSecAttrProtocol as String] = protocolType.rawValue
|
|
|
|
+ query[kSecAttrAuthenticationType as String] = authenticationType.rawValue
|
|
}
|
|
}
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
if authenticationPrompt != nil {
|
|
if authenticationPrompt != nil {
|
|
if floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_7_1) {
|
|
if floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_7_1) {
|
|
- query[kSecUseOperationPrompt as! String] = authenticationPrompt
|
|
|
|
|
|
+ query[kSecUseOperationPrompt as String] = authenticationPrompt
|
|
} else {
|
|
} else {
|
|
- println("Unavailable 'authenticationPrompt' attribute on iOS versions prior to 8.0.")
|
|
|
|
|
|
+ print("Unavailable 'authenticationPrompt' attribute on iOS versions prior to 8.0.")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
@@ -884,23 +884,23 @@ extension Options {
|
|
return query
|
|
return query
|
|
}
|
|
}
|
|
|
|
|
|
- func attributes(#key: String?, value: NSData) -> ([String: AnyObject], NSError?) {
|
|
|
|
|
|
+ func attributes(key key: String?, value: NSData) -> ([String: AnyObject], NSError?) {
|
|
var attributes: [String: AnyObject]
|
|
var attributes: [String: AnyObject]
|
|
|
|
|
|
if key != nil {
|
|
if key != nil {
|
|
attributes = query()
|
|
attributes = query()
|
|
- attributes[kSecAttrAccount as! String] = key
|
|
|
|
|
|
+ attributes[kSecAttrAccount as String] = key
|
|
} else {
|
|
} else {
|
|
attributes = [String: AnyObject]()
|
|
attributes = [String: AnyObject]()
|
|
}
|
|
}
|
|
|
|
|
|
- attributes[kSecValueData as! String] = value
|
|
|
|
|
|
+ attributes[kSecValueData as String] = value
|
|
|
|
|
|
if label != nil {
|
|
if label != nil {
|
|
- attributes[kSecAttrLabel as! String] = label
|
|
|
|
|
|
+ attributes[kSecAttrLabel as String] = label
|
|
}
|
|
}
|
|
if comment != nil {
|
|
if comment != nil {
|
|
- attributes[kSecAttrComment as! String] = comment
|
|
|
|
|
|
+ attributes[kSecAttrComment as String] = comment
|
|
}
|
|
}
|
|
|
|
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
@@ -914,7 +914,7 @@ extension Options {
|
|
let accessControl = SecAccessControlCreateWithFlags(
|
|
let accessControl = SecAccessControlCreateWithFlags(
|
|
kCFAllocatorDefault,
|
|
kCFAllocatorDefault,
|
|
accessibility.rawValue,
|
|
accessibility.rawValue,
|
|
- SecAccessControlCreateFlags(policy.rawValue),
|
|
|
|
|
|
+ SecAccessControlCreateFlags(rawValue: policy.rawValue),
|
|
&error
|
|
&error
|
|
)
|
|
)
|
|
if let error = error?.takeUnretainedValue() {
|
|
if let error = error?.takeUnretainedValue() {
|
|
@@ -924,27 +924,27 @@ extension Options {
|
|
let message = Status.UnexpectedError.description
|
|
let message = Status.UnexpectedError.description
|
|
return (attributes, NSError(domain: KeychainAccessErrorDomain, code: Int(Status.UnexpectedError.rawValue), userInfo: [NSLocalizedDescriptionKey: message]))
|
|
return (attributes, NSError(domain: KeychainAccessErrorDomain, code: Int(Status.UnexpectedError.rawValue), userInfo: [NSLocalizedDescriptionKey: message]))
|
|
}
|
|
}
|
|
- attributes[kSecAttrAccessControl as! String] = accessControl.takeUnretainedValue()
|
|
|
|
|
|
+ attributes[kSecAttrAccessControl as String] = accessControl.takeUnretainedValue()
|
|
} else {
|
|
} else {
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- println("Unavailable 'Touch ID integration' on iOS versions prior to 8.0.")
|
|
|
|
|
|
+ print("Unavailable 'Touch ID integration' on iOS versions prior to 8.0.")
|
|
#else
|
|
#else
|
|
- println("Unavailable 'Touch ID integration' on OS X versions prior to 10.10.")
|
|
|
|
|
|
+ print("Unavailable 'Touch ID integration' on OS X versions prior to 10.10.")
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if floor(NSFoundationVersionNumber) <= floor(iOS_7_1_or_10_9_2) && accessibility == .WhenPasscodeSetThisDeviceOnly {
|
|
if floor(NSFoundationVersionNumber) <= floor(iOS_7_1_or_10_9_2) && accessibility == .WhenPasscodeSetThisDeviceOnly {
|
|
#if os(iOS)
|
|
#if os(iOS)
|
|
- println("Unavailable 'Accessibility.WhenPasscodeSetThisDeviceOnly' attribute on iOS versions prior to 8.0.")
|
|
|
|
|
|
+ print("Unavailable 'Accessibility.WhenPasscodeSetThisDeviceOnly' attribute on iOS versions prior to 8.0.")
|
|
#else
|
|
#else
|
|
- println("Unavailable 'Accessibility.WhenPasscodeSetThisDeviceOnly' attribute on OS X versions prior to 10.10.")
|
|
|
|
|
|
+ print("Unavailable 'Accessibility.WhenPasscodeSetThisDeviceOnly' attribute on OS X versions prior to 10.10.")
|
|
#endif
|
|
#endif
|
|
} else {
|
|
} else {
|
|
- attributes[kSecAttrAccessible as! String] = accessibility.rawValue
|
|
|
|
|
|
+ attributes[kSecAttrAccessible as String] = accessibility.rawValue
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- attributes[kSecAttrSynchronizable as! String] = synchronizable
|
|
|
|
|
|
+ attributes[kSecAttrSynchronizable as String] = synchronizable
|
|
|
|
|
|
return (attributes, nil)
|
|
return (attributes, nil)
|
|
}
|
|
}
|
|
@@ -952,13 +952,13 @@ extension Options {
|
|
|
|
|
|
// MARK:
|
|
// MARK:
|
|
|
|
|
|
-extension ItemClass : RawRepresentable, Printable {
|
|
|
|
|
|
+extension ItemClass : RawRepresentable, CustomStringConvertible {
|
|
|
|
|
|
public init?(rawValue: String) {
|
|
public init?(rawValue: String) {
|
|
switch rawValue {
|
|
switch rawValue {
|
|
- case kSecClassGenericPassword as! String:
|
|
|
|
|
|
+ case String(kSecClassGenericPassword):
|
|
self = GenericPassword
|
|
self = GenericPassword
|
|
- case kSecClassInternetPassword as! String:
|
|
|
|
|
|
+ case String(kSecClassInternetPassword):
|
|
self = InternetPassword
|
|
self = InternetPassword
|
|
default:
|
|
default:
|
|
return nil
|
|
return nil
|
|
@@ -968,9 +968,9 @@ extension ItemClass : RawRepresentable, Printable {
|
|
public var rawValue: String {
|
|
public var rawValue: String {
|
|
switch self {
|
|
switch self {
|
|
case GenericPassword:
|
|
case GenericPassword:
|
|
- return kSecClassGenericPassword as! String
|
|
|
|
|
|
+ return String(kSecClassGenericPassword)
|
|
case InternetPassword:
|
|
case InternetPassword:
|
|
- return kSecClassInternetPassword as! String
|
|
|
|
|
|
+ return String(kSecClassInternetPassword)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -984,71 +984,71 @@ extension ItemClass : RawRepresentable, Printable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-extension ProtocolType : RawRepresentable, Printable {
|
|
|
|
|
|
+extension ProtocolType : RawRepresentable, CustomStringConvertible {
|
|
|
|
|
|
public init?(rawValue: String) {
|
|
public init?(rawValue: String) {
|
|
switch rawValue {
|
|
switch rawValue {
|
|
- case kSecAttrProtocolFTP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolFTP):
|
|
self = FTP
|
|
self = FTP
|
|
- case kSecAttrProtocolFTPAccount as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolFTPAccount):
|
|
self = FTPAccount
|
|
self = FTPAccount
|
|
- case kSecAttrProtocolHTTP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolHTTP):
|
|
self = HTTP
|
|
self = HTTP
|
|
- case kSecAttrProtocolIRC as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolIRC):
|
|
self = IRC
|
|
self = IRC
|
|
- case kSecAttrProtocolNNTP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolNNTP):
|
|
self = NNTP
|
|
self = NNTP
|
|
- case kSecAttrProtocolPOP3 as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolPOP3):
|
|
self = POP3
|
|
self = POP3
|
|
- case kSecAttrProtocolSMTP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolSMTP):
|
|
self = SMTP
|
|
self = SMTP
|
|
- case kSecAttrProtocolSOCKS as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolSOCKS):
|
|
self = SOCKS
|
|
self = SOCKS
|
|
- case kSecAttrProtocolIMAP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolIMAP):
|
|
self = IMAP
|
|
self = IMAP
|
|
- case kSecAttrProtocolLDAP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolLDAP):
|
|
self = LDAP
|
|
self = LDAP
|
|
- case kSecAttrProtocolAppleTalk as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolAppleTalk):
|
|
self = AppleTalk
|
|
self = AppleTalk
|
|
- case kSecAttrProtocolAFP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolAFP):
|
|
self = AFP
|
|
self = AFP
|
|
- case kSecAttrProtocolTelnet as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolTelnet):
|
|
self = Telnet
|
|
self = Telnet
|
|
- case kSecAttrProtocolSSH as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolSSH):
|
|
self = SSH
|
|
self = SSH
|
|
- case kSecAttrProtocolFTPS as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolFTPS):
|
|
self = FTPS
|
|
self = FTPS
|
|
- case kSecAttrProtocolHTTPS as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolHTTPS):
|
|
self = HTTPS
|
|
self = HTTPS
|
|
- case kSecAttrProtocolHTTPProxy as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolHTTPProxy):
|
|
self = HTTPProxy
|
|
self = HTTPProxy
|
|
- case kSecAttrProtocolHTTPSProxy as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolHTTPSProxy):
|
|
self = HTTPSProxy
|
|
self = HTTPSProxy
|
|
- case kSecAttrProtocolFTPProxy as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolFTPProxy):
|
|
self = FTPProxy
|
|
self = FTPProxy
|
|
- case kSecAttrProtocolSMB as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolSMB):
|
|
self = SMB
|
|
self = SMB
|
|
- case kSecAttrProtocolRTSP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolRTSP):
|
|
self = RTSP
|
|
self = RTSP
|
|
- case kSecAttrProtocolRTSPProxy as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolRTSPProxy):
|
|
self = RTSPProxy
|
|
self = RTSPProxy
|
|
- case kSecAttrProtocolDAAP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolDAAP):
|
|
self = DAAP
|
|
self = DAAP
|
|
- case kSecAttrProtocolEPPC as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolEPPC):
|
|
self = EPPC
|
|
self = EPPC
|
|
- case kSecAttrProtocolIPP as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolIPP):
|
|
self = IPP
|
|
self = IPP
|
|
- case kSecAttrProtocolNNTPS as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolNNTPS):
|
|
self = NNTPS
|
|
self = NNTPS
|
|
- case kSecAttrProtocolLDAPS as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolLDAPS):
|
|
self = LDAPS
|
|
self = LDAPS
|
|
- case kSecAttrProtocolTelnetS as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolTelnetS):
|
|
self = TelnetS
|
|
self = TelnetS
|
|
- case kSecAttrProtocolIMAPS as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolIMAPS):
|
|
self = IMAPS
|
|
self = IMAPS
|
|
- case kSecAttrProtocolIRCS as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolIRCS):
|
|
self = IRCS
|
|
self = IRCS
|
|
- case kSecAttrProtocolPOP3S as! String:
|
|
|
|
|
|
+ case String(kSecAttrProtocolPOP3S):
|
|
self = POP3S
|
|
self = POP3S
|
|
default:
|
|
default:
|
|
return nil
|
|
return nil
|
|
@@ -1058,67 +1058,67 @@ extension ProtocolType : RawRepresentable, Printable {
|
|
public var rawValue: String {
|
|
public var rawValue: String {
|
|
switch self {
|
|
switch self {
|
|
case FTP:
|
|
case FTP:
|
|
- return kSecAttrProtocolFTP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolFTP as String
|
|
case FTPAccount:
|
|
case FTPAccount:
|
|
- return kSecAttrProtocolFTPAccount as! String
|
|
|
|
|
|
+ return kSecAttrProtocolFTPAccount as String
|
|
case HTTP:
|
|
case HTTP:
|
|
- return kSecAttrProtocolHTTP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolHTTP as String
|
|
case IRC:
|
|
case IRC:
|
|
- return kSecAttrProtocolIRC as! String
|
|
|
|
|
|
+ return kSecAttrProtocolIRC as String
|
|
case NNTP:
|
|
case NNTP:
|
|
- return kSecAttrProtocolNNTP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolNNTP as String
|
|
case POP3:
|
|
case POP3:
|
|
- return kSecAttrProtocolPOP3 as! String
|
|
|
|
|
|
+ return kSecAttrProtocolPOP3 as String
|
|
case SMTP:
|
|
case SMTP:
|
|
- return kSecAttrProtocolSMTP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolSMTP as String
|
|
case SOCKS:
|
|
case SOCKS:
|
|
- return kSecAttrProtocolSOCKS as! String
|
|
|
|
|
|
+ return kSecAttrProtocolSOCKS as String
|
|
case IMAP:
|
|
case IMAP:
|
|
- return kSecAttrProtocolIMAP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolIMAP as String
|
|
case LDAP:
|
|
case LDAP:
|
|
- return kSecAttrProtocolLDAP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolLDAP as String
|
|
case AppleTalk:
|
|
case AppleTalk:
|
|
- return kSecAttrProtocolAppleTalk as! String
|
|
|
|
|
|
+ return kSecAttrProtocolAppleTalk as String
|
|
case AFP:
|
|
case AFP:
|
|
- return kSecAttrProtocolAFP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolAFP as String
|
|
case Telnet:
|
|
case Telnet:
|
|
- return kSecAttrProtocolTelnet as! String
|
|
|
|
|
|
+ return kSecAttrProtocolTelnet as String
|
|
case SSH:
|
|
case SSH:
|
|
- return kSecAttrProtocolSSH as! String
|
|
|
|
|
|
+ return kSecAttrProtocolSSH as String
|
|
case FTPS:
|
|
case FTPS:
|
|
- return kSecAttrProtocolFTPS as! String
|
|
|
|
|
|
+ return kSecAttrProtocolFTPS as String
|
|
case HTTPS:
|
|
case HTTPS:
|
|
- return kSecAttrProtocolHTTPS as! String
|
|
|
|
|
|
+ return kSecAttrProtocolHTTPS as String
|
|
case HTTPProxy:
|
|
case HTTPProxy:
|
|
- return kSecAttrProtocolHTTPProxy as! String
|
|
|
|
|
|
+ return kSecAttrProtocolHTTPProxy as String
|
|
case HTTPSProxy:
|
|
case HTTPSProxy:
|
|
- return kSecAttrProtocolHTTPSProxy as! String
|
|
|
|
|
|
+ return kSecAttrProtocolHTTPSProxy as String
|
|
case FTPProxy:
|
|
case FTPProxy:
|
|
- return kSecAttrProtocolFTPProxy as! String
|
|
|
|
|
|
+ return kSecAttrProtocolFTPProxy as String
|
|
case SMB:
|
|
case SMB:
|
|
- return kSecAttrProtocolSMB as! String
|
|
|
|
|
|
+ return kSecAttrProtocolSMB as String
|
|
case RTSP:
|
|
case RTSP:
|
|
- return kSecAttrProtocolRTSP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolRTSP as String
|
|
case RTSPProxy:
|
|
case RTSPProxy:
|
|
- return kSecAttrProtocolRTSPProxy as! String
|
|
|
|
|
|
+ return kSecAttrProtocolRTSPProxy as String
|
|
case DAAP:
|
|
case DAAP:
|
|
- return kSecAttrProtocolDAAP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolDAAP as String
|
|
case EPPC:
|
|
case EPPC:
|
|
- return kSecAttrProtocolEPPC as! String
|
|
|
|
|
|
+ return kSecAttrProtocolEPPC as String
|
|
case IPP:
|
|
case IPP:
|
|
- return kSecAttrProtocolIPP as! String
|
|
|
|
|
|
+ return kSecAttrProtocolIPP as String
|
|
case NNTPS:
|
|
case NNTPS:
|
|
- return kSecAttrProtocolNNTPS as! String
|
|
|
|
|
|
+ return kSecAttrProtocolNNTPS as String
|
|
case LDAPS:
|
|
case LDAPS:
|
|
- return kSecAttrProtocolLDAPS as! String
|
|
|
|
|
|
+ return kSecAttrProtocolLDAPS as String
|
|
case TelnetS:
|
|
case TelnetS:
|
|
- return kSecAttrProtocolTelnetS as! String
|
|
|
|
|
|
+ return kSecAttrProtocolTelnetS as String
|
|
case IMAPS:
|
|
case IMAPS:
|
|
- return kSecAttrProtocolIMAPS as! String
|
|
|
|
|
|
+ return kSecAttrProtocolIMAPS as String
|
|
case IRCS:
|
|
case IRCS:
|
|
- return kSecAttrProtocolIRCS as! String
|
|
|
|
|
|
+ return kSecAttrProtocolIRCS as String
|
|
case POP3S:
|
|
case POP3S:
|
|
- return kSecAttrProtocolPOP3S as! String
|
|
|
|
|
|
+ return kSecAttrProtocolPOP3S as String
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1190,25 +1190,25 @@ extension ProtocolType : RawRepresentable, Printable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-extension AuthenticationType : RawRepresentable, Printable {
|
|
|
|
|
|
+extension AuthenticationType : RawRepresentable, CustomStringConvertible {
|
|
|
|
|
|
public init?(rawValue: String) {
|
|
public init?(rawValue: String) {
|
|
switch rawValue {
|
|
switch rawValue {
|
|
- case kSecAttrAuthenticationTypeNTLM as! String:
|
|
|
|
|
|
+ case String(kSecAttrAuthenticationTypeNTLM):
|
|
self = NTLM
|
|
self = NTLM
|
|
- case kSecAttrAuthenticationTypeMSN as! String:
|
|
|
|
|
|
+ case String(kSecAttrAuthenticationTypeMSN):
|
|
self = MSN
|
|
self = MSN
|
|
- case kSecAttrAuthenticationTypeDPA as! String:
|
|
|
|
|
|
+ case String(kSecAttrAuthenticationTypeDPA):
|
|
self = DPA
|
|
self = DPA
|
|
- case kSecAttrAuthenticationTypeRPA as! String:
|
|
|
|
|
|
+ case String(kSecAttrAuthenticationTypeRPA):
|
|
self = RPA
|
|
self = RPA
|
|
- case kSecAttrAuthenticationTypeHTTPBasic as! String:
|
|
|
|
|
|
+ case String(kSecAttrAuthenticationTypeHTTPBasic):
|
|
self = HTTPBasic
|
|
self = HTTPBasic
|
|
- case kSecAttrAuthenticationTypeHTTPDigest as! String:
|
|
|
|
|
|
+ case String(kSecAttrAuthenticationTypeHTTPDigest):
|
|
self = HTTPDigest
|
|
self = HTTPDigest
|
|
- case kSecAttrAuthenticationTypeHTMLForm as! String:
|
|
|
|
|
|
+ case String(kSecAttrAuthenticationTypeHTMLForm):
|
|
self = HTMLForm
|
|
self = HTMLForm
|
|
- case kSecAttrAuthenticationTypeDefault as! String:
|
|
|
|
|
|
+ case String(kSecAttrAuthenticationTypeDefault):
|
|
self = Default
|
|
self = Default
|
|
default:
|
|
default:
|
|
return nil
|
|
return nil
|
|
@@ -1218,21 +1218,21 @@ extension AuthenticationType : RawRepresentable, Printable {
|
|
public var rawValue: String {
|
|
public var rawValue: String {
|
|
switch self {
|
|
switch self {
|
|
case NTLM:
|
|
case NTLM:
|
|
- return kSecAttrAuthenticationTypeNTLM as! String
|
|
|
|
|
|
+ return kSecAttrAuthenticationTypeNTLM as String
|
|
case MSN:
|
|
case MSN:
|
|
- return kSecAttrAuthenticationTypeMSN as! String
|
|
|
|
|
|
+ return kSecAttrAuthenticationTypeMSN as String
|
|
case DPA:
|
|
case DPA:
|
|
- return kSecAttrAuthenticationTypeDPA as! String
|
|
|
|
|
|
+ return kSecAttrAuthenticationTypeDPA as String
|
|
case RPA:
|
|
case RPA:
|
|
- return kSecAttrAuthenticationTypeRPA as! String
|
|
|
|
|
|
+ return kSecAttrAuthenticationTypeRPA as String
|
|
case HTTPBasic:
|
|
case HTTPBasic:
|
|
- return kSecAttrAuthenticationTypeHTTPBasic as! String
|
|
|
|
|
|
+ return kSecAttrAuthenticationTypeHTTPBasic as String
|
|
case HTTPDigest:
|
|
case HTTPDigest:
|
|
- return kSecAttrAuthenticationTypeHTTPDigest as! String
|
|
|
|
|
|
+ return kSecAttrAuthenticationTypeHTTPDigest as String
|
|
case HTMLForm:
|
|
case HTMLForm:
|
|
- return kSecAttrAuthenticationTypeHTMLForm as! String
|
|
|
|
|
|
+ return kSecAttrAuthenticationTypeHTMLForm as String
|
|
case Default:
|
|
case Default:
|
|
- return kSecAttrAuthenticationTypeDefault as! String
|
|
|
|
|
|
+ return kSecAttrAuthenticationTypeDefault as String
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1258,23 +1258,23 @@ extension AuthenticationType : RawRepresentable, Printable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-extension Accessibility : RawRepresentable, Printable {
|
|
|
|
|
|
+extension Accessibility : RawRepresentable, CustomStringConvertible {
|
|
|
|
|
|
public init?(rawValue: String) {
|
|
public init?(rawValue: String) {
|
|
switch rawValue {
|
|
switch rawValue {
|
|
- case kSecAttrAccessibleWhenUnlocked as! String:
|
|
|
|
|
|
+ case String(kSecAttrAccessibleWhenUnlocked):
|
|
self = WhenUnlocked
|
|
self = WhenUnlocked
|
|
- case kSecAttrAccessibleAfterFirstUnlock as! String:
|
|
|
|
|
|
+ case String(kSecAttrAccessibleAfterFirstUnlock):
|
|
self = AfterFirstUnlock
|
|
self = AfterFirstUnlock
|
|
- case kSecAttrAccessibleAlways as! String:
|
|
|
|
|
|
+ case String(kSecAttrAccessibleAlways):
|
|
self = Always
|
|
self = Always
|
|
- case kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly as! String:
|
|
|
|
|
|
+ case String(kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly):
|
|
self = WhenPasscodeSetThisDeviceOnly
|
|
self = WhenPasscodeSetThisDeviceOnly
|
|
- case kSecAttrAccessibleWhenUnlockedThisDeviceOnly as! String:
|
|
|
|
|
|
+ case String(kSecAttrAccessibleWhenUnlockedThisDeviceOnly):
|
|
self = WhenUnlockedThisDeviceOnly
|
|
self = WhenUnlockedThisDeviceOnly
|
|
- case kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly as! String:
|
|
|
|
|
|
+ case String(kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly):
|
|
self = AfterFirstUnlockThisDeviceOnly
|
|
self = AfterFirstUnlockThisDeviceOnly
|
|
- case kSecAttrAccessibleAlwaysThisDeviceOnly as! String:
|
|
|
|
|
|
+ case String(kSecAttrAccessibleAlwaysThisDeviceOnly):
|
|
self = AlwaysThisDeviceOnly
|
|
self = AlwaysThisDeviceOnly
|
|
default:
|
|
default:
|
|
return nil
|
|
return nil
|
|
@@ -1284,19 +1284,19 @@ extension Accessibility : RawRepresentable, Printable {
|
|
public var rawValue: String {
|
|
public var rawValue: String {
|
|
switch self {
|
|
switch self {
|
|
case WhenUnlocked:
|
|
case WhenUnlocked:
|
|
- return kSecAttrAccessibleWhenUnlocked as! String
|
|
|
|
|
|
+ return kSecAttrAccessibleWhenUnlocked as String
|
|
case AfterFirstUnlock:
|
|
case AfterFirstUnlock:
|
|
- return kSecAttrAccessibleAfterFirstUnlock as! String
|
|
|
|
|
|
+ return kSecAttrAccessibleAfterFirstUnlock as String
|
|
case Always:
|
|
case Always:
|
|
- return kSecAttrAccessibleAlways as! String
|
|
|
|
|
|
+ return kSecAttrAccessibleAlways as String
|
|
case WhenPasscodeSetThisDeviceOnly:
|
|
case WhenPasscodeSetThisDeviceOnly:
|
|
- return kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly as! String
|
|
|
|
|
|
+ return kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly as String
|
|
case WhenUnlockedThisDeviceOnly:
|
|
case WhenUnlockedThisDeviceOnly:
|
|
- return kSecAttrAccessibleWhenUnlockedThisDeviceOnly as! String
|
|
|
|
|
|
+ return kSecAttrAccessibleWhenUnlockedThisDeviceOnly as String
|
|
case AfterFirstUnlockThisDeviceOnly:
|
|
case AfterFirstUnlockThisDeviceOnly:
|
|
- return kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly as! String
|
|
|
|
|
|
+ return kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly as String
|
|
case AlwaysThisDeviceOnly:
|
|
case AlwaysThisDeviceOnly:
|
|
- return kSecAttrAccessibleAlwaysThisDeviceOnly as! String
|
|
|
|
|
|
+ return kSecAttrAccessibleAlwaysThisDeviceOnly as String
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1320,10 +1320,10 @@ extension Accessibility : RawRepresentable, Printable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-extension AuthenticationPolicy : RawRepresentable, Printable {
|
|
|
|
|
|
+extension AuthenticationPolicy : RawRepresentable, CustomStringConvertible {
|
|
|
|
|
|
public init?(rawValue: Int) {
|
|
public init?(rawValue: Int) {
|
|
- var flags = SecAccessControlCreateFlags.UserPresence
|
|
|
|
|
|
+ let flags = SecAccessControlCreateFlags.UserPresence
|
|
|
|
|
|
switch rawValue {
|
|
switch rawValue {
|
|
case flags.rawValue:
|
|
case flags.rawValue:
|
|
@@ -1348,7 +1348,7 @@ extension AuthenticationPolicy : RawRepresentable, Printable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-extension FailableOf: Printable, DebugPrintable {
|
|
|
|
|
|
+extension FailableOf: CustomStringConvertible, CustomDebugStringConvertible {
|
|
public var description: String {
|
|
public var description: String {
|
|
switch self {
|
|
switch self {
|
|
case .Success(let success):
|
|
case .Success(let success):
|
|
@@ -1373,9 +1373,9 @@ extension FailableOf: Printable, DebugPrintable {
|
|
|
|
|
|
extension CFError {
|
|
extension CFError {
|
|
var error: NSError {
|
|
var error: NSError {
|
|
- var domain = CFErrorGetDomain(self) as String
|
|
|
|
- var code = CFErrorGetCode(self)
|
|
|
|
- var userInfo = CFErrorCopyUserInfo(self) as [NSObject: AnyObject]
|
|
|
|
|
|
+ let domain = CFErrorGetDomain(self) as String
|
|
|
|
+ let code = CFErrorGetCode(self)
|
|
|
|
+ let userInfo = CFErrorCopyUserInfo(self) as [NSObject: AnyObject]
|
|
|
|
|
|
return NSError(domain: domain, code: code, userInfo: userInfo)
|
|
return NSError(domain: domain, code: code, userInfo: userInfo)
|
|
}
|
|
}
|
|
@@ -1761,7 +1761,7 @@ public enum Status : OSStatus {
|
|
case UnexpectedError
|
|
case UnexpectedError
|
|
}
|
|
}
|
|
|
|
|
|
-extension Status : RawRepresentable, Printable {
|
|
|
|
|
|
+extension Status : RawRepresentable, CustomStringConvertible {
|
|
|
|
|
|
public init?(rawValue: OSStatus) {
|
|
public init?(rawValue: OSStatus) {
|
|
switch rawValue {
|
|
switch rawValue {
|