|
| 1 | +// |
| 2 | +// Copyright Amazon.com Inc. or its affiliates. |
| 3 | +// All Rights Reserved. |
| 4 | +// |
| 5 | +// SPDX-License-Identifier: Apache-2.0 |
| 6 | +// |
| 7 | + |
| 8 | +import Foundation |
| 9 | + |
| 10 | +/// A structure representing an access group for managing keychain items. |
| 11 | +public struct AccessGroup { |
| 12 | + /// The name of the access group. |
| 13 | + public let name: String? |
| 14 | + |
| 15 | + /// A flag indicating whether to migrate keychain items. |
| 16 | + public let migrateKeychainItems: Bool |
| 17 | + |
| 18 | + /** |
| 19 | + Initializes an `AccessGroup` with the specified name and migration option. |
| 20 | + |
| 21 | + - Parameter name: The name of the access group. |
| 22 | + - Parameter migrateKeychainItemsOfUserSession: A flag indicating whether to migrate keychain items. Defaults to `false`. |
| 23 | + */ |
| 24 | + public init(name: String, migrateKeychainItemsOfUserSession: Bool = false) { |
| 25 | + self.init(name: name, migrateKeychainItems: migrateKeychainItemsOfUserSession) |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + Creates an `AccessGroup` instance with no specified name. |
| 30 | + |
| 31 | + - Parameter migrateKeychainItemsOfUserSession: A flag indicating whether to migrate keychain items. |
| 32 | + - Returns: An `AccessGroup` instance with the migration option set. |
| 33 | + */ |
| 34 | + public static func none(migrateKeychainItemsOfUserSession: Bool) -> AccessGroup { |
| 35 | + return .init(migrateKeychainItems: migrateKeychainItemsOfUserSession) |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + A static property representing an `AccessGroup` with no name and no migration. |
| 40 | + |
| 41 | + - Returns: An `AccessGroup` instance with no name and the migration option set to `false`. |
| 42 | + */ |
| 43 | + public static var none: AccessGroup { |
| 44 | + return .none(migrateKeychainItemsOfUserSession: false) |
| 45 | + } |
| 46 | + |
| 47 | + private init(name: String? = nil, migrateKeychainItems: Bool) { |
| 48 | + self.name = name |
| 49 | + self.migrateKeychainItems = migrateKeychainItems |
| 50 | + } |
| 51 | +} |
0 commit comments