class PProf::ProvisioningProfile
Represents the content of a Provisioning Profile file
Constants
- DEFAULT_DIR
The default location where all the Provisioning Profiles are stored on a Mac
Public Class Methods
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 directory `DEFAULT_DIR`
-
Otherwise, the parameter is interpreted as a file path
@param [String] file
File path or UUID of the ProvisioningProfile
# File lib/pprof/provisioning_profile.rb, line 21 def initialize(file) if file =~ %r/^[0-9A-F-]*$/i path = "#{PProf::ProvisioningProfile::DEFAULT_DIR}/#{file}.mobileprovision" else path = file end 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 # 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 #{file}." if @plist.nil? end
Public Instance Methods
The name of the Application Identifier associated with this Provisioning Profile
@note This is not the AppID itself, but rather the name you associated to that
AppID in your Developer Portal
@return [String]
# File lib/pprof/provisioning_profile.rb, line 65 def app_id_name @plist['AppIDName'] end
The AppID prefix (which is typically the ID of the team)
@return [String]
# File lib/pprof/provisioning_profile.rb, line 72 def app_id_prefix @plist['ApplicationIdentifierPrefix'] end
The Creation date of this Provisioning Profile
@return [DateTime]
# File lib/pprof/provisioning_profile.rb, line 79 def creation_date @plist['CreationDate'] end
The list of X509 Developer Certifiates associated with this profile
@return [Array<OpenSSL::X509::Certificate>]
# File lib/pprof/provisioning_profile.rb, line 115 def developer_certificates @plist['DeveloperCertificates'].map do |data| OpenSSL::X509::Certificate.new(data.string) end end
All the entitlements associated with this Provisioning Profile
@return [Entitlements]
# File lib/pprof/provisioning_profile.rb, line 124 def entitlements PProf::Entitlements.new(@plist['Entitlements']) end
The expiration date of this Provisioning Profile
@return [DateTime]
# File lib/pprof/provisioning_profile.rb, line 86 def expiration_date @plist['ExpirationDate'] end
The name of the Provisioning Profile
@return [String]
# File lib/pprof/provisioning_profile.rb, line 48 def name @plist['Name'] end
The list of devices provisioned with this Provisioning Profile (if any)
@return [Array<String>]
# File lib/pprof/provisioning_profile.rb, line 131 def provisioned_devices @plist['ProvisionedDevices'] end
Indicates if this Provisioning Profile is provisioned for all devices or only for a list of some specific devices
@return [Bool]
# File lib/pprof/provisioning_profile.rb, line 139 def provisions_all_devices @plist['ProvisionsAllDevices'] || false end
The Team IDs associated with this Provisioning Profile
@note typically Provisioning Profiles contain only one team
@return [Array<String>]
# File lib/pprof/provisioning_profile.rb, line 101 def team_ids @plist['TeamIdentifier'] end
The name of the Team associated with this Provisioning Profile
@return [String]
# File lib/pprof/provisioning_profile.rb, line 108 def team_name @plist['TeamName'] end
The hash representation of this Provisioning Profile
@return [Hash]
# File lib/pprof/provisioning_profile.rb, line 146 def to_hash @dict end
The human-readable string representation of this Provisioning Profile Typically suitable for printing this Provisioning Profile information to the user.
@return [String]
# File lib/pprof/provisioning_profile.rb, line 154 def to_s lines = [:name, :uuid, :app_id_name, :app_id_prefix, :creation_date, :expiration_date, :ttl, :team_ids, :team_name].map do |key| "- #{key.to_s}: #{self.send(key.to_sym)}" end + [ "- #{developer_certificates.count} Developer Certificates", "- #{provisioned_devices.count} Provisioned Devices", "- Entitlements:" ] + entitlements.to_hasg.map { |key, value| " - #{key}: #{value}" } lines.join("\n") end
The Time-To-Live of this Provisioning Profile @return [Int]
# File lib/pprof/provisioning_profile.rb, line 92 def ttl @plist['TimeToLive'].to_i end
The UUID of the Provisioning Profile
@return [String]
# File lib/pprof/provisioning_profile.rb, line 55 def uuid @plist['UUID'] end