Class: IOSCertEnrollment::Profile
- Inherits:
-
Object
- Object
- IOSCertEnrollment::Profile
- Defined in:
- lib/ios-cert-enrollment/profile.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#expiration ⇒ Object
Returns the value of attribute expiration.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #configuration(encrypted_content) ⇒ Object
- #encrypt(certificates) ⇒ Object
- #encrypted_service ⇒ Object
-
#initialize(url = "") ⇒ Profile
constructor
A new instance of Profile.
- #service ⇒ Object
- #sign ⇒ Object
- #signed_webclip(certificates, display_name = "WebClip", icon = nil) ⇒ Object
Constructor Details
#initialize(url = "") ⇒ Profile
Returns a new instance of Profile.
8 9 10 11 12 13 14 15 16 |
# File 'lib/ios-cert-enrollment/profile.rb', line 8 def initialize(url="") self.url = IOSCertEnrollment.base_url + url self.identifier = IOSCertEnrollment.identifier self.display_name = IOSCertEnrollment.display_name self.organization = IOSCertEnrollment.organization self.description = "" self.expiration = nil end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/ios-cert-enrollment/profile.rb', line 7 def description @description end |
#display_name ⇒ Object
Returns the value of attribute display_name.
7 8 9 |
# File 'lib/ios-cert-enrollment/profile.rb', line 7 def display_name @display_name end |
#expiration ⇒ Object
Returns the value of attribute expiration.
7 8 9 |
# File 'lib/ios-cert-enrollment/profile.rb', line 7 def expiration @expiration end |
#icon ⇒ Object
Returns the value of attribute icon.
7 8 9 |
# File 'lib/ios-cert-enrollment/profile.rb', line 7 def icon @icon end |
#identifier ⇒ Object
Returns the value of attribute identifier.
7 8 9 |
# File 'lib/ios-cert-enrollment/profile.rb', line 7 def identifier @identifier end |
#organization ⇒ Object
Returns the value of attribute organization.
7 8 9 |
# File 'lib/ios-cert-enrollment/profile.rb', line 7 def organization @organization end |
#payload ⇒ Object
Returns the value of attribute payload.
7 8 9 |
# File 'lib/ios-cert-enrollment/profile.rb', line 7 def payload @payload end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/ios-cert-enrollment/profile.rb', line 7 def url @url end |
Instance Method Details
#configuration(encrypted_content) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ios-cert-enrollment/profile.rb', line 105 def configuration(encrypted_content) payload = general_payload() payload['PayloadIdentifier'] = self.identifier+".intranet" payload['PayloadType'] = "Configuration" # do not modify # strings that show up in UI, customisable payload['PayloadDisplayName'] = self.display_name payload['PayloadDescription'] = self.description payload['PayloadExpirationDate'] = self.expiration || Date.today + (360 * 10) # expire in 10 years payload['EncryptedPayloadContent'] = StringIO.new(encrypted_content) self.payload = Plist::Emit.dump(payload) return self end |
#encrypt(certificates) ⇒ Object
127 128 129 130 131 |
# File 'lib/ios-cert-enrollment/profile.rb', line 127 def encrypt(certificates) encrypted_profile = OpenSSL::PKCS7.encrypt(certificates, self.payload, OpenSSL::Cipher::Cipher::new("des-ede3-cbc"), OpenSSL::PKCS7::BINARY) return Certificate.new(encrypted_profile.to_der, "application/x-apple-aspen-config") end |
#encrypted_service ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ios-cert-enrollment/profile.rb', line 44 def encrypted_service ## ASA encryption_cert_payload payload = general_payload() payload['PayloadIdentifier'] = self.identifier+".encrypted-profile-service" payload['PayloadType'] = "Configuration" # do not modify # strings that show up in UI, customisable payload['PayloadDisplayName'] = self.display_name payload['PayloadDescription'] = self.description payload['PayloadContent'] = [encryption_cert_request("Profile Service")]; self.payload = Plist::Emit.dump(payload) return self end |
#service ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ios-cert-enrollment/profile.rb', line 18 def service payload = general_payload() payload['PayloadType'] = "Profile Service" # do not modify payload['PayloadIdentifier'] = self.identifier+".mobileconfig.profile-service" # strings that show up in UI, customizable payload['PayloadDisplayName'] = self.display_name payload['PayloadDescription'] = self.description payload_content = Hash.new payload_content['URL'] = self.url payload_content['DeviceAttributes'] = [ "UDID", "VERSION", "PRODUCT", # ie. iPhone1,1 or iPod2,1 "DEVICE_NAME", # given device name "My iPhone" "MAC_ADDRESS_EN0", "IMEI", "ICCID" ]; payload['PayloadContent'] = payload_content self.payload = Plist::Emit.dump(payload) return self end |
#sign ⇒ Object
121 122 123 124 125 |
# File 'lib/ios-cert-enrollment/profile.rb', line 121 def sign signed_profile = OpenSSL::PKCS7.sign(SSL.certificate, SSL.key, self.payload, [], OpenSSL::PKCS7::BINARY) return Certificate.new(signed_profile.to_der, "application/x-apple-aspen-config") end |
#signed_webclip(certificates, display_name = "WebClip", icon = nil) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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 |
# File 'lib/ios-cert-enrollment/profile.rb', line 61 def signed_webclip(certificates, display_name="WebClip", icon=nil) content_payload = general_payload() content_payload['PayloadIdentifier'] = self.identifier+".webclip.intranet" content_payload['PayloadType'] = "com.apple.webClip.managed" # do not modify # strings that show up in UI, customisable content_payload['PayloadDisplayName'] = display_name content_payload['PayloadDescription'] = self.description # allow user to remove webclip content_payload['IsRemovable'] = true content_payload['Precomposed'] = true content_payload['Icon'] = icon if icon # the link content_payload['Label'] = display_name content_payload['URL'] = self.url plist_content_payload = Plist::Emit.dump([content_payload]) puts plist_content_payload encrypted_profile = OpenSSL::PKCS7.encrypt(certificates, plist_content_payload, OpenSSL::Cipher::Cipher::new("des-ede3-cbc"), OpenSSL::PKCS7::BINARY) encrypted_content = encrypted_profile.to_der payload = general_payload() payload['PayloadIdentifier'] = self.identifier+".intranet" payload['PayloadType'] = "Configuration" # do not modify # strings that show up in UI, customisable payload['PayloadDisplayName'] = self.display_name payload['PayloadDescription'] = self.description #payload['PayloadExpirationDate'] = self.expiration || Date.today + (360 * 10) payload['EncryptedPayloadContent'] = StringIO.new(encrypted_content) self.payload = Plist::Emit.dump(payload) puts self.payload return self.sign end |