Class: DopCommon::Credential
Constant Summary
collapse
- VALID_TYPES =
[:username_password, :kerberos, :ssh_key]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from HashParser
deep_symbolize_keys, hash_of_pattern_lists_valid?, is_valid_regexp?, key_aliases, load_content, load_content_valid?, parse_hash_of_pattern_lists, parse_pattern_list, pattern_list_valid?, represents_regexp?, symbolize_keys
Methods included from Validator
#log_validation_method, #set_not_valid, #try_validate_obj, #valid?
Constructor Details
#initialize(name, hash) ⇒ Credential
Returns a new instance of Credential.
14
15
16
17
18
|
# File 'lib/dop_common/credential.rb', line 14
def initialize(name, hash)
@name = name
@hash = deep_symbolize_keys(hash)
DopCommon.add_log_filter(Proc.new {|msg| filter_secrets(msg)})
end
|
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
10
11
12
|
# File 'lib/dop_common/credential.rb', line 10
def hash
@hash
end
|
#name ⇒ Object
Returns the value of attribute name.
10
11
12
|
# File 'lib/dop_common/credential.rb', line 10
def name
@name
end
|
Instance Method Details
#filter_secrets(msg) ⇒ Object
This method filters the secrets from a message
25
26
27
28
29
30
|
# File 'lib/dop_common/credential.rb', line 25
def filter_secrets(msg)
case type
when :username_password then msg.gsub(password, '****')
else msg
end
end
|
#keytab ⇒ Object
52
53
54
|
# File 'lib/dop_common/credential.rb', line 52
def keytab
@keytab ||= keytab_valid? ? load_content(@hash[:keytab]) : nil
end
|
#password ⇒ Object
40
41
42
|
# File 'lib/dop_common/credential.rb', line 40
def password
@password ||= password_valid? ? load_content(@hash[:password]) : nil
end
|
#private_key ⇒ Object
56
57
58
|
# File 'lib/dop_common/credential.rb', line 56
def private_key
@private_key ||= private_key_valid? ? load_content(@hash[:private_key]) : nil
end
|
#public_key ⇒ Object
60
61
62
|
# File 'lib/dop_common/credential.rb', line 60
def public_key
@public_key ||= public_key_valid? ? load_content(@hash[:public_key]) : nil
end
|
#realm ⇒ Object
44
45
46
|
# File 'lib/dop_common/credential.rb', line 44
def realm
@realm ||= realm_valid? ? @hash[:realm] : nil
end
|
#service ⇒ Object
48
49
50
|
# File 'lib/dop_common/credential.rb', line 48
def service
@service ||= service_valid? ? @hash[:service] : nil
end
|
#type ⇒ Object
32
33
34
|
# File 'lib/dop_common/credential.rb', line 32
def type
@type ||= type_valid? ? @hash[:type].to_sym : nil
end
|
#username ⇒ Object
36
37
38
|
# File 'lib/dop_common/credential.rb', line 36
def username
@username ||= username_valid? ? @hash[:username] : nil
end
|
#validate ⇒ Object
20
21
22
|
# File 'lib/dop_common/credential.rb', line 20
def validate
log_validation_method('type_valid?')
end
|