Class: Certmeister::Config
- Inherits:
-
Object
- Object
- Certmeister::Config
- Defined in:
- lib/certmeister/config.rb
Instance Attribute Summary collapse
-
#fetch_policy ⇒ Object
readonly
Returns the value of attribute fetch_policy.
-
#remove_policy ⇒ Object
readonly
Returns the value of attribute remove_policy.
-
#sign_policy ⇒ Object
readonly
Returns the value of attribute sign_policy.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #ca_cert ⇒ Object
- #ca_key ⇒ Object
- #error_list ⇒ Object
- #errors ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #openssl_digest ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 |
# File 'lib/certmeister/config.rb', line 11 def initialize() @options = @store = [:store] @sign_policy = [:sign_policy] @fetch_policy = [:fetch_policy] @remove_policy = [:remove_policy] @errors = {} end |
Instance Attribute Details
#fetch_policy ⇒ Object (readonly)
Returns the value of attribute fetch_policy.
9 10 11 |
# File 'lib/certmeister/config.rb', line 9 def fetch_policy @fetch_policy end |
#remove_policy ⇒ Object (readonly)
Returns the value of attribute remove_policy.
9 10 11 |
# File 'lib/certmeister/config.rb', line 9 def remove_policy @remove_policy end |
#sign_policy ⇒ Object (readonly)
Returns the value of attribute sign_policy.
9 10 11 |
# File 'lib/certmeister/config.rb', line 9 def sign_policy @sign_policy end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
9 10 11 |
# File 'lib/certmeister/config.rb', line 9 def store @store end |
Instance Method Details
#ca_cert ⇒ Object
20 21 22 |
# File 'lib/certmeister/config.rb', line 20 def ca_cert @ca_cert ||= OpenSSL::X509::Certificate.new(@options[:ca_cert]) end |
#ca_key ⇒ Object
24 25 26 |
# File 'lib/certmeister/config.rb', line 24 def ca_key @ca_key ||= OpenSSL::PKey.read(@options[:ca_key]) end |
#error_list ⇒ Object
45 46 47 48 49 |
# File 'lib/certmeister/config.rb', line 45 def error_list @errors.keys.sort.inject([]) do |list, option| list << "#{option} #{@errors[option]}" end end |
#errors ⇒ Object
41 42 43 |
# File 'lib/certmeister/config.rb', line 41 def errors @errors end |
#openssl_digest ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/certmeister/config.rb', line 28 def openssl_digest if OpenSSL::Digest.const_defined?('SHA256') @digest = OpenSSL::Digest::SHA256 elsif OpenSSL::Digest.const_defined?('SHA1') @digest = OpenSSL::Digest::SHA1 end end |
#valid? ⇒ Boolean
36 37 38 39 |
# File 'lib/certmeister/config.rb', line 36 def valid? validate @errors.empty? end |