class Tapjoy::LDAP::Key::Remove
Remove
a user key from user profile
Public Instance Methods
Private Instance Methods
confirm()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 66 def confirm puts 'Please confirm the following operations:' puts "Keep these keys:\n\n" print "\t #{ keep_keys }\n\n" puts "Delete these keys:\n\n" print "\t #{ delete_keys }\n\n" puts "Ignore these keys (not found in LDAP for #{ opts[:username]}):\n\n" print "\t #{ keys_not_found }\n\n" get_confirmation end
current_keys()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 42 def current_keys @current_keys ||= begin current_keys_array = [] results.each do |result| @user_dn = result.dn current_keys_array = result.sshPublicKey end current_keys_array end end
delete_keys()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 58 def delete_keys @delete_keys ||= current_keys & keys end
filter()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 34 def filter @filter ||= Net::LDAP::Filter.eq('uid', opts[:username]) end
get_confirmation()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 77 def get_confirmation print '>' confirm = STDIN.gets.chomp.downcase abort('Deletion of key aborted') unless confirm.start_with?('y') end
keep_keys()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 54 def keep_keys @keep_keys ||= current_keys.flatten - keys.flatten end
keys()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 30 def keys @keys ||= Tapjoy::LDAP::Key.get_keys_from_commandline(opts[:filename]) end
keys_not_found()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 62 def keys_not_found @keys_not_found ||= keys - current_keys end
opts()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 17 def opts @opts ||= Optimist.options do # Set help message usage 'key remove [options]' synopsis "\nThis command is for removing a user's SSH key(s)" opt :username, 'Specify username to delete key from', type: :string, required: true opt :filename, 'File to load key deletion list from', type: :string opt :force, 'Force delete', short: '-F' end end
results()
click to toggle source
# File lib/tapjoy/ldap/key/remove.rb, line 38 def results @results ||= Tapjoy::LDAP.client.search(['sshPublicKey'], filter) end