class Tug::Keychain
Attributes
apple_certificate[R]
distribution_certificate[R]
distribution_profile[R]
name[RW]
private_key[R]
private_key_password[RW]
Public Class Methods
keychain(config)
click to toggle source
# File lib/tug/keychain/keychain.rb, line 12 def keychain(config) if config.has_key?("keychain") Tug::Keychain.new(config["keychain"]) end end
new(keychain_yaml)
click to toggle source
# File lib/tug/keychain/keychain.rb, line 19 def initialize(keychain_yaml) @apple_certificate = keychain_yaml["apple_certificate"] @distribution_certificate = keychain_yaml["distribution_certificate"] @distribution_profile = keychain_yaml["distribution_profile"] @private_key = keychain_yaml["private_key"] # these defaults are also set in Interface @private_key_password = ENV['TUG_P12_PASSWORD'] @name = "tug" end
Public Instance Methods
configure(options)
click to toggle source
# File lib/tug/keychain/keychain.rb, line 30 def configure(options) @name = options["keychain"] @private_key_password = options["password"] end
create_keychain()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 35 def create_keychain system("security create-keychain -p tug #{name}.keychain") end
delete_keychain()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 43 def delete_keychain system("security delete-keychain #{name}.keychain") end
import_apple_certificate()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 55 def import_apple_certificate system(import_command(apple_certificate)) end
import_distribution_certificate()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 59 def import_distribution_certificate system(import_command(distribution_certificate)) end
import_private_key()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 63 def import_private_key system(import_command(private_key) + " -P '#{private_key_password}'") end
import_profile()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 67 def import_profile FileUtils.mkdir_p "#{File.expand_path('~')}/Library/MobileDevice/Provisioning\ Profiles/" system("cp #{distribution_profile} #{profile_export_path}") end
select_keychain(keychain_name=name)
click to toggle source
# File lib/tug/keychain/keychain.rb, line 39 def select_keychain(keychain_name=name) system("security default-keychain -s #{keychain_name}.keychain") end
set_timeout()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 51 def set_timeout system("security set-keychain-settings -t 3600 -u #{name}.keychain") end
unlock_keychain()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 47 def unlock_keychain system("security unlock-keychain -p tug #{name}.keychain") end
Private Instance Methods
import_command(file)
click to toggle source
# File lib/tug/keychain/keychain.rb, line 78 def import_command(file) "security import #{file} -k #{keychain_path} -T /usr/bin/codesign" end
keychain_path()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 82 def keychain_path "#{File.expand_path('~')}/Library/Keychains/#{name}.keychain" end
profile_export_path()
click to toggle source
# File lib/tug/keychain/keychain.rb, line 74 def profile_export_path "#{File.expand_path('~')}/Library/MobileDevice/Provisioning\\ Profiles/" end