Class: PProf::ProvisioningProfile
- Inherits:
-
Object
- Object
- PProf::ProvisioningProfile
- Defined in:
- lib/pprof/provisioning_profile.rb
Overview
Represents the content of a Provisioning Profile file
Constant Summary collapse
- DEFAULT_DIRS =
The default location where all the Provisioning Profiles are stored on a Mac
[ File.join(Dir.home, 'Library', 'MobileDevice', 'Provisioning Profiles'), File.join(Dir.home, 'Library', 'Developer', 'Xcode', 'UserData', 'Provisioning Profiles') ].freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#app_id_name ⇒ String
The name of the Application Identifier associated with this Provisioning Profile.
-
#app_id_prefix ⇒ String
The AppID prefix (which is typically the ID of the team).
-
#creation_date ⇒ DateTime
The Creation date of this Provisioning Profile.
-
#developer_certificates ⇒ Array<OpenSSL::X509::Certificate>
The list of X509 Developer Certificates associated with this profile.
-
#entitlements ⇒ Entitlements
All the entitlements associated with this Provisioning Profile.
-
#expiration_date ⇒ DateTime
The expiration date of this Provisioning Profile.
-
#initialize(file) ⇒ ProvisioningProfile
constructor
Create a new ProvisioningProfile object from a file path or UUID.
-
#name ⇒ String
The name of the Provisioning Profile.
-
#platform ⇒ Array<String>
The list of Platforms the Provisioning Profile is for.
-
#provisioned_devices ⇒ Array<String>
The list of devices provisioned with this Provisioning Profile (if any).
-
#provisions_all_devices ⇒ Bool
Indicates if this Provisioning Profile is provisioned for all devices or only for a list of some specific devices.
-
#team_ids ⇒ Array<String>
The Team IDs associated with this Provisioning Profile.
-
#team_name ⇒ String
The name of the Team associated with this Provisioning Profile.
-
#to_hash ⇒ Hash
The hash representation of this Provisioning Profile.
-
#to_s ⇒ String
The human-readable string representation of this Provisioning Profile Typically suitable for printing this Provisioning Profile information to the user.
-
#ttl ⇒ Int
The Time-To-Live of this Provisioning Profile.
-
#uuid ⇒ String
The UUID of the Provisioning Profile.
Constructor Details
#initialize(file) ⇒ ProvisioningProfile
Create a new ProvisioningProfile object from a file path or UUID
-
If the parameter given has the form of an UUID, a file named with this UUID and a ‘.mobileprovision` is searched in the default directories `DEFAULT_DIRS`
-
Otherwise, the parameter is interpreted as a file path
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pprof/provisioning_profile.rb', line 28 def initialize(file) @path = if file.match?(/^[0-9A-F-]*$/i) PProf::ProvisioningProfile::DEFAULT_DIRS.flat_map do |dir| Dir["#{dir}/#{file}.{mobileprovision,provisionprofile}"] end.compact.first else file end raise "Unable to find Provisioning Profile with UUID #{file}." if @path.nil? xml = nil begin pkcs7 = OpenSSL::PKCS7.new(File.read(@path)) pkcs7.verify([], OpenSSL::X509::Store.new) xml = pkcs7.data raise 'Empty PKCS7 payload' if xml.nil? || xml.empty? rescue StandardError # Seems like sometimes OpenSSL fails to parse the PKCS7 payload # Besides, OpenSSL is deprecated on macOS so might not be up-to-date on all machines # So as a fallback, we run the `security` command line. # (We could use `security` everytime, but invoking a command line is generally less # efficient than calling the OpenSSL gem if available, so for now it's just used as fallback) xml = `security cms -D -i "#{@path}" 2> /dev/null` end @plist = Plist.parse_xml(xml) raise "Unable to parse file #{@path}." if @plist.nil? end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/pprof/provisioning_profile.rb', line 17 def path @path end |
Instance Method Details
#app_id_name ⇒ String
This is not the AppID itself, but rather the name you associated to that AppID in your Developer Portal
The name of the Application Identifier associated with this Provisioning Profile
84 85 86 |
# File 'lib/pprof/provisioning_profile.rb', line 84 def app_id_name @plist['AppIDName'] end |
#app_id_prefix ⇒ String
The AppID prefix (which is typically the ID of the team)
91 92 93 |
# File 'lib/pprof/provisioning_profile.rb', line 91 def app_id_prefix @plist['ApplicationIdentifierPrefix'] end |
#creation_date ⇒ DateTime
The Creation date of this Provisioning Profile
98 99 100 |
# File 'lib/pprof/provisioning_profile.rb', line 98 def creation_date @plist['CreationDate'] end |
#developer_certificates ⇒ Array<OpenSSL::X509::Certificate>
The list of X509 Developer Certificates associated with this profile
134 135 136 137 138 |
# File 'lib/pprof/provisioning_profile.rb', line 134 def developer_certificates @plist['DeveloperCertificates'].map do |data| OpenSSL::X509::Certificate.new(data.string) end end |
#entitlements ⇒ Entitlements
All the entitlements associated with this Provisioning Profile
143 144 145 |
# File 'lib/pprof/provisioning_profile.rb', line 143 def entitlements PProf::Entitlements.new(@plist['Entitlements']) end |
#expiration_date ⇒ DateTime
The expiration date of this Provisioning Profile
105 106 107 |
# File 'lib/pprof/provisioning_profile.rb', line 105 def expiration_date @plist['ExpirationDate'] end |
#name ⇒ String
The name of the Provisioning Profile
59 60 61 |
# File 'lib/pprof/provisioning_profile.rb', line 59 def name @plist['Name'] end |
#platform ⇒ Array<String>
The list of Platforms the Provisioning Profile is for. Typical values include ‘OSX`, `iOS`, `xrOS`, `visionOS`, …
74 75 76 |
# File 'lib/pprof/provisioning_profile.rb', line 74 def platform @plist['Platform'] end |
#provisioned_devices ⇒ Array<String>
The list of devices provisioned with this Provisioning Profile (if any)
150 151 152 |
# File 'lib/pprof/provisioning_profile.rb', line 150 def provisioned_devices @plist['ProvisionedDevices'] end |
#provisions_all_devices ⇒ Bool
Indicates if this Provisioning Profile is provisioned for all devices or only for a list of some specific devices
158 159 160 |
# File 'lib/pprof/provisioning_profile.rb', line 158 def provisions_all_devices @plist['ProvisionsAllDevices'] || false end |
#team_ids ⇒ Array<String>
typically Provisioning Profiles contain only one team
The Team IDs associated with this Provisioning Profile
120 121 122 |
# File 'lib/pprof/provisioning_profile.rb', line 120 def team_ids @plist['TeamIdentifier'] end |
#team_name ⇒ String
The name of the Team associated with this Provisioning Profile
127 128 129 |
# File 'lib/pprof/provisioning_profile.rb', line 127 def team_name @plist['TeamName'] end |
#to_hash ⇒ Hash
The hash representation of this Provisioning Profile
165 166 167 |
# File 'lib/pprof/provisioning_profile.rb', line 165 def to_hash @plist end |
#to_s ⇒ String
The human-readable string representation of this Provisioning Profile Typically suitable for printing this Provisioning Profile information to the user.
173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/pprof/provisioning_profile.rb', line 173 def to_s lines = %i[path name uuid app_id_name app_id_prefix creation_date expiration_date ttl team_ids team_name].map do |key| "- #{key}: #{send(key.to_sym)}" end + [ "- #{developer_certificates.count} Developer Certificates", "- #{provisioned_devices.count} Provisioned Devices", '- Entitlements:' ] + entitlements.to_hash.map { |key, value| " - #{key}: #{value}" } lines.join("\n") end |
#ttl ⇒ Int
The Time-To-Live of this Provisioning Profile
111 112 113 |
# File 'lib/pprof/provisioning_profile.rb', line 111 def ttl @plist['TimeToLive'].to_i end |
#uuid ⇒ String
The UUID of the Provisioning Profile
66 67 68 |
# File 'lib/pprof/provisioning_profile.rb', line 66 def uuid @plist['UUID'] end |