Class: Configuration
- Inherits:
-
Object
- Object
- Configuration
- Defined in:
- lib/action_mailer_x509/configuration.rb
Instance Method Summary collapse
- #certs_path ⇒ Object
- #certs_path=(path) ⇒ Object
- #crypt_cert ⇒ Object
- #crypt_cert_p12 ⇒ Object
- #crypt_key ⇒ Object
- #crypt_require? ⇒ Boolean
- #get_certificate_info ⇒ Object
- #get_crypter ⇒ Object
- #get_signer ⇒ Object
-
#initialize(params = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #sign_cert ⇒ Object
- #sign_cert_p12 ⇒ Object
- #sign_key ⇒ Object
- #sign_require? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(params = {}) ⇒ Configuration
Returns a new instance of Configuration.
4 5 6 7 |
# File 'lib/action_mailer_x509/configuration.rb', line 4 def initialize(params = {}) params.symbolize_keys! params.each_pair { |k, v| self.send("#{k}=".to_sym, v) } end |
Instance Method Details
#certs_path ⇒ Object
38 39 40 |
# File 'lib/action_mailer_x509/configuration.rb', line 38 def certs_path @certs_path || ActionMailerX509.default_certs_path end |
#certs_path=(path) ⇒ Object
42 43 44 |
# File 'lib/action_mailer_x509/configuration.rb', line 42 def certs_path=(path) @certs_path = Pathname.new(path) end |
#crypt_cert ⇒ Object
58 59 60 |
# File 'lib/action_mailer_x509/configuration.rb', line 58 def crypt_cert certs_path.join(@crypt_cert) end |
#crypt_cert_p12 ⇒ Object
62 63 64 |
# File 'lib/action_mailer_x509/configuration.rb', line 62 def crypt_cert_p12 certs_path.join(@crypt_cert_p12) end |
#crypt_key ⇒ Object
66 67 68 |
# File 'lib/action_mailer_x509/configuration.rb', line 66 def crypt_key certs_path.join(@crypt_key) end |
#crypt_require? ⇒ Boolean
34 35 36 |
# File 'lib/action_mailer_x509/configuration.rb', line 34 def crypt_require? crypt_enable == true end |
#get_certificate_info ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/action_mailer_x509/configuration.rb', line 78 def get_certificate_info if valid? if sign_require? || crypt_require? worker = sign_require? ? get_signer : get_crypter subject_attrs = worker.certificate.subject.to_a subject_attrs = subject_attrs.each_with_object({}) do |attr, obj| obj.update(SecurityObject::ATTRS[attr.first] => attr[1]) end { from: worker.certificate.not_before, to: worker.certificate.not_after, }.reverse_merge!(subject_attrs) end || {} end || {} end |
#get_crypter ⇒ Object
70 71 72 |
# File 'lib/action_mailer_x509/configuration.rb', line 70 def get_crypter ActionMailerX509::X509.new(crypt_configuration) end |
#get_signer ⇒ Object
74 75 76 |
# File 'lib/action_mailer_x509/configuration.rb', line 74 def get_signer ActionMailerX509::X509.new(sign_configuration) end |
#sign_cert ⇒ Object
46 47 48 |
# File 'lib/action_mailer_x509/configuration.rb', line 46 def sign_cert certs_path.join(@sign_cert) end |
#sign_cert_p12 ⇒ Object
50 51 52 |
# File 'lib/action_mailer_x509/configuration.rb', line 50 def sign_cert_p12 certs_path.join(@sign_cert_p12) end |
#sign_key ⇒ Object
54 55 56 |
# File 'lib/action_mailer_x509/configuration.rb', line 54 def sign_key certs_path.join(@sign_key) end |
#sign_require? ⇒ Boolean
30 31 32 |
# File 'lib/action_mailer_x509/configuration.rb', line 30 def sign_require? sign_enable == true end |
#valid? ⇒ Boolean
96 97 98 |
# File 'lib/action_mailer_x509/configuration.rb', line 96 def valid? validate_sign && validate_crypt end |