module Faf::Security

Public Class Methods

get(options) click to toggle source
# File lib/faf/security.rb, line 8
def get(options)
  Faf::Shell.system!(security('find', options))
rescue RuntimeError
  nil
end
store!(options) click to toggle source
# File lib/faf/security.rb, line 4
def store!(options)
  Faf::Shell.system!(security('add', options))
end

Private Class Methods

security(command = nil, options = nil) click to toggle source
# File lib/faf/security.rb, line 16
def security(command = nil, options = nil)
  run = [security_path]
  run << "#{command}-internet-password"
  run << "-a #{options[:username]}"
  run << "-s #{options[:server]}"
  if command == 'add'
    run << "-l #{options[:label]}"
    run << '-U'
    run << "-w #{options[:password]}" if options.key?(:password)
  else
    run << '-w'
  end
  run.join ' '
end
security_path() click to toggle source
# File lib/faf/security.rb, line 31
def security_path
  @security_path ||= begin
    `which security`.chomp
  rescue StandardError
    'security'
  end
end