class RHC::Rest::Key

Public Instance Methods

delete()
Alias for: destroy
destroy() click to toggle source
# File lib/rhc/rest/key.rb, line 19
def destroy
  debug "Deleting key #{self.name}"
  rest_method "DELETE"
end
Also aliased as: delete
fingerprint() click to toggle source
# File lib/rhc/rest/key.rb, line 29
def fingerprint
  @fingerprint ||= begin
    public_key = Net::SSH::KeyFactory.load_data_public_key("#{type} #{content}")
    public_key.fingerprint
  rescue NotImplementedError, Net::SSH::Exception, OpenSSL::PKey::PKeyError
    'Invalid key'
  end if is_ssh?
end
is_kerberos?() click to toggle source
# File lib/rhc/rest/key.rb, line 10
def is_kerberos?
  type == 'krb5-principal'
end
is_ssh?() click to toggle source
# File lib/rhc/rest/key.rb, line 6
def is_ssh?
  type != 'krb5-principal'
end
principal() click to toggle source
# File lib/rhc/rest/key.rb, line 25
def principal
  content if is_kerberos?
end
update(type, content) click to toggle source
# File lib/rhc/rest/key.rb, line 14
def update(type, content)
  debug "Updating key #{self.name}"
  rest_method "UPDATE", :type => type, :content => content
end
visible_to_ssh?() click to toggle source
# File lib/rhc/rest/key.rb, line 38
def visible_to_ssh?
  is_ssh? and Net::SSH::Authentication::Agent.connect.identities.
    find{ |i| fingerprint == i.fingerprint }.present? rescue false
end