Class: RHC::Rest::Key
Instance Method Summary
collapse
Methods inherited from Base
#add_message, #has_param?, #initialize, #link_href, #links, #rest_method, #supports?
#define_attr, #model_name
Methods included from Attributes
#attribute, #attributes, #attributes=, #clear_attribute
Instance Method Details
#destroy ⇒ Object
Also known as:
delete
19
20
21
22
|
# File 'lib/rhc/rest/key.rb', line 19
def destroy
debug "Deleting key #{self.name}"
rest_method "DELETE"
end
|
#fingerprint ⇒ Object
29
30
31
32
33
34
35
36
|
# 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? ⇒ Boolean
10
11
12
|
# File 'lib/rhc/rest/key.rb', line 10
def is_kerberos?
type == 'krb5-principal'
end
|
#is_ssh? ⇒ Boolean
6
7
8
|
# File 'lib/rhc/rest/key.rb', line 6
def is_ssh?
type != 'krb5-principal'
end
|
#principal ⇒ Object
25
26
27
|
# File 'lib/rhc/rest/key.rb', line 25
def principal
content if is_kerberos?
end
|
#update(type, content) ⇒ Object
14
15
16
17
|
# 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? ⇒ Boolean
38
39
40
41
|
# 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
|