Class: Provisioning
- Inherits:
-
Object
- Object
- Provisioning
- Defined in:
- lib/provisinfo/provisioning.rb
Instance Attribute Summary collapse
-
#appID ⇒ Object
Returns the value of attribute appID.
-
#expirationDate ⇒ Object
Returns the value of attribute expirationDate.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#name ⇒ Object
Returns the value of attribute name.
-
#teamID ⇒ Object
Returns the value of attribute teamID.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename = nil) ⇒ Provisioning
constructor
by default, it will load the first .mobileprovision file in current directory.
- #is_expired ⇒ Object
- #load_from_file ⇒ Object
- #matches_certificate?(certificate_filename, password) ⇒ Boolean
- #show_info ⇒ Object
Constructor Details
#initialize(filename = nil) ⇒ Provisioning
by default, it will load the first .mobileprovision file in current directory
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/provisinfo/provisioning.rb', line 26 def initialize(filename = nil) if filename.nil? @filename = self.class.list_provisioning_files().first else @filename = filename end if @filename self.load_from_file() else @name ="Unknown" end end |
Instance Attribute Details
#appID ⇒ Object
Returns the value of attribute appID.
19 20 21 |
# File 'lib/provisinfo/provisioning.rb', line 19 def appID @appID end |
#expirationDate ⇒ Object
Returns the value of attribute expirationDate.
22 23 24 |
# File 'lib/provisinfo/provisioning.rb', line 22 def expirationDate @expirationDate end |
#filename ⇒ Object
Returns the value of attribute filename.
21 22 23 |
# File 'lib/provisinfo/provisioning.rb', line 21 def filename @filename end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/provisinfo/provisioning.rb', line 16 def name @name end |
#teamID ⇒ Object
Returns the value of attribute teamID.
20 21 22 |
# File 'lib/provisinfo/provisioning.rb', line 20 def teamID @teamID end |
#type ⇒ Object
Returns the value of attribute type.
17 18 19 |
# File 'lib/provisinfo/provisioning.rb', line 17 def type @type end |
#uuid ⇒ Object
Returns the value of attribute uuid.
18 19 20 |
# File 'lib/provisinfo/provisioning.rb', line 18 def uuid @uuid end |
Class Method Details
.list_provisioning_files ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/provisinfo/provisioning.rb', line 54 def self.list_provisioning_files() provisioning_file_paths = [] Dir.entries('.').each do |path| provisioning_file_paths << path if path=~ /.*\.mobileprovision$/ end provisioning_file_paths end |
Instance Method Details
#is_expired ⇒ Object
62 63 64 65 |
# File 'lib/provisinfo/provisioning.rb', line 62 def is_expired() now = DateTime.now return self.expirationDate < now end |
#load_from_file ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/provisinfo/provisioning.rb', line 43 def load_from_file() xml_raw = `security cms -D -i #{@filename}` xml_parsed = Plist::parse_xml(xml_raw) @teamID = xml_parsed['Entitlements']['com.apple.developer.team-identifier'] @name = xml_parsed['Name'] @uuid = xml_parsed['UUID'] @appID = xml_parsed['Entitlements']['application-identifier'] @expirationDate = xml_parsed['ExpirationDate'] end |
#matches_certificate?(certificate_filename, password) ⇒ Boolean
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/provisinfo/provisioning.rb', line 76 def matches_certificate?(certificate_filename, password) if certificate_filename.nil? or not File.exists?(certificate_filename) abort("can't find the certificate file.") end profile = File.read(self.filename) certificate = File.read(certificate_filename) p7 = OpenSSL::PKCS7.new(profile) cert = OpenSSL::PKCS12.new(certificate, password) store = OpenSSL::X509::Store.new p7.verify([], store) plist = REXML::Document.new(p7.data) plist.elements.each('/plist/dict/key') do |ele| if ele.text == "DeveloperCertificates" keys = ele.next_element key = keys.get_elements('//array/data')[0].text key = key.scan(/.{1,64}/).join("\n") profile_cert = "-----BEGIN CERTIFICATE-----\n" + key.gsub(/\t/, "") + "\n-----END CERTIFICATE-----\n" @provisioning_cert = OpenSSL::X509::Certificate.new(profile_cert) end end return @provisioning_cert.to_s != cert.certificate.to_s end |
#show_info ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/provisinfo/provisioning.rb', line 67 def show_info() puts "Name:"+self.name puts "UUDID:"+self.uuid puts "AppID:"+self.appID puts "TeamID:"+self.teamID puts "ExpirationDate:"+self.expirationDate.strftime("%c") end |