class PasswordHelper

Constants

UI

Public Instance Methods

password(host, username) click to toggle source
# File lib/fastlane/plugin/carthage_cache_ftps/helper/password_helper.rb, line 11
def password(host, username)
  password = ENV["CARTHAGE_CACHE_FTPS_PASSWORD"]
  unless password
    item = Security::InternetPassword.find(server: server_name(host, username))
    password = item.password if item
  end

  unless password
    if !UI.interactive?
      UI.error "Neither the CARTHAGE_CACHE_FTPS_PASSWORD environment variable nor the local keychain contained a password."
      UI.error "Bailing out instead of asking for a password, since this is non-interactive mode."
      UI.user_error!("Try setting the CARTHAGE_CACHE_FTPS_PASSWORD environment variable, or temporarily enable interactive mode to store a password.")
    else
      UI.important "Enter the passphrase that should be used to login to the ftps"
      UI.important "This passphrase is specific per host and username and will be stored in your local keychain"
      password = Fastlane::Helper::CarthageCacheFtpsHelper.ask_password(confirm: false)
      store_password(host, username, password)
    end
  end

  return password
end
server_name(host, username) click to toggle source
# File lib/fastlane/plugin/carthage_cache_ftps/helper/password_helper.rb, line 7
def server_name(host, username)
  ["carthage_cache_ftps", host, username].join("_")
end
store_password(host, username, password) click to toggle source
# File lib/fastlane/plugin/carthage_cache_ftps/helper/password_helper.rb, line 34
def store_password(host, username, password)
  Security::InternetPassword.add(server_name(host, username), "", password)
end