-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create and adopt SharedAccessGroupIdentifier
- Loading branch information
Showing
19 changed files
with
294 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// SharedAccessGroupIdentifier.swift | ||
// Valet | ||
// | ||
// Created by Dan Federman on 2/25/20. | ||
// Copyright © 2020 Square, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
public struct SharedAccessGroupIdentifier: CustomStringConvertible { | ||
|
||
// MARK: Initialization | ||
|
||
/// A representation of a shared access group identifier. | ||
/// - Parameters: | ||
/// - appIDPrefix: The application's App ID prefix. This string can be found by inspecting the application's provisioning profile, or viewing the application's App ID Configuration on developer.apple.com. This string must not be empty. | ||
/// - groupIdentifier: An identifier that cooresponds to a value in keychain-access-groups in the application's Entitlements file. This string must not be empty. | ||
/// - SeeAlso: https://developer.apple.com/documentation/security/keychain_services/keychain_items/sharing_access_to_keychain_items_among_a_collection_of_apps | ||
public init?(appIDPrefix: String, nonEmptyGroup groupIdentifier: String?) { | ||
guard !appIDPrefix.isEmpty, let groupIdentifier = groupIdentifier, !groupIdentifier.isEmpty else { | ||
return nil | ||
} | ||
|
||
self.appIDPrefix = appIDPrefix | ||
self.groupIdentifier = groupIdentifier | ||
} | ||
|
||
// MARK: CustomStringConvertible | ||
|
||
public var description: String { | ||
return appIDPrefix + "." + groupIdentifier | ||
} | ||
|
||
// MARK: Internal Properties | ||
|
||
internal let appIDPrefix: String | ||
internal let groupIdentifier: String | ||
|
||
internal var asIdentifier: Identifier { | ||
// It is safe to force unwrap because we've already validated that our description is non-empty. | ||
Identifier(nonEmpty: description)! | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.