Class: RhaAuthkeys

Inherits:
Object
  • Object
show all
Defined in:
lib/rha/authkeys.rb

Overview

RhaAuthkeys are authentication configurations for heartbeat.

Instance Method Summary collapse

Constructor Details

#initializeRhaAuthkeys

Returns a new RhaConfig Object



19
20
21
# File 'lib/rha/authkeys.rb', line 19

def initialize()
  @num ||= []
end

Instance Method Details

#add_crc(auth_num, method_num) ⇒ Object

Cyclic Redundancy Check hash method. This method does not require a shared secret and is insecure; it’s use is strongly discouraged.



63
64
65
66
67
68
69
70
71
# File 'lib/rha/authkeys.rb', line 63

def add_crc(auth_num, method_num)
  begin
    num_index = @num.index("auth #{auth_num}")
    @num.insert(num_index + 1, method_num.to_s + " crc " + "\n")
  rescue
    puts "no such auth num #{auth_num}"
    return false
  end
end

#add_md5(auth_num, method_num, secret) ⇒ Object

MD5 hash method. This method requires a shared secret.



36
37
38
39
40
41
42
43
44
# File 'lib/rha/authkeys.rb', line 36

def add_md5(auth_num, method_num, secret)
  begin
    num_index = @num.index("auth #{auth_num}")
    @num.insert(num_index + 1, method_num.to_s + " md5 " + secret.to_s + "\n")
  rescue
    puts "no such auth num #{auth_num}"
    return false
  end
end

#add_sha1(auth_num, method_num, secret) ⇒ Object

SHA-1 hash method. This method requires a shared secret.



49
50
51
52
53
54
55
56
57
# File 'lib/rha/authkeys.rb', line 49

def add_sha1(auth_num, method_num, secret)
  begin
    num_index = @num.index("auth #{auth_num}")
    @num.insert(num_index + 1, method_num.to_s + " sha1 " + secret.to_s + "\n")
  rescue
    puts "no such auth num #{auth_num}"
    return false
  end
end

#auth(value) ⇒ Object

auth num selects the currently active authentication method and secret.

num is a numerical identifier, between 1 and 15 inclusive. It must be unique within the file.



29
30
31
# File 'lib/rha/authkeys.rb', line 29

def auth(value)
  @num.push("auth #{value}")
end

#configObject

Return the RhaAuthkeys configuration



76
77
78
# File 'lib/rha/authkeys.rb', line 76

def config
  return @num
end