Class: CertValidator::CrlValidator::Extractor
- Inherits:
-
Object
- Object
- CertValidator::CrlValidator::Extractor
- Defined in:
- lib/cert_validator/crl/extractor.rb
Instance Attribute Summary collapse
-
#certificate ⇒ Object
readonly
Returns the value of attribute certificate.
Instance Method Summary collapse
- #crl_extension ⇒ Object
- #crl_extension_payload ⇒ Object
- #decoded_payload ⇒ Object
- #descend_to_string(asn_data) ⇒ Object
- #distribution_points ⇒ Object
- #has_crl_extension? ⇒ Boolean
- #has_distribution_points? ⇒ Boolean
-
#initialize(cert) ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
#initialize(cert) ⇒ Extractor
Returns a new instance of Extractor.
6 7 8 |
# File 'lib/cert_validator/crl/extractor.rb', line 6 def initialize(cert) @certificate = cert end |
Instance Attribute Details
#certificate ⇒ Object (readonly)
Returns the value of attribute certificate.
4 5 6 |
# File 'lib/cert_validator/crl/extractor.rb', line 4 def certificate @certificate end |
Instance Method Details
#crl_extension ⇒ Object
23 24 25 |
# File 'lib/cert_validator/crl/extractor.rb', line 23 def crl_extension @crl_extension ||= certificate.extensions.detect{ |e| e.oid == 'crlDistributionPoints' } end |
#crl_extension_payload ⇒ Object
27 28 29 |
# File 'lib/cert_validator/crl/extractor.rb', line 27 def crl_extension_payload @crl_extension_payload ||= Asn1.new(crl_extension.to_der).extension_payload end |
#decoded_payload ⇒ Object
31 32 33 |
# File 'lib/cert_validator/crl/extractor.rb', line 31 def decoded_payload @decoded_payload ||= Asn1.new(crl_extension_payload).decode end |
#descend_to_string(asn_data) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cert_validator/crl/extractor.rb', line 35 def descend_to_string(asn_data) seen = Set.new current = asn_data loop do raise RecursiveExtractError.new if seen.include? current seen.add current current = current.first.value return current if current.is_a? String end end |
#distribution_points ⇒ Object
10 11 12 13 |
# File 'lib/cert_validator/crl/extractor.rb', line 10 def distribution_points return [] unless has_crl_extension? decoded_payload.value.map{ |v| descend_to_string v.value } end |
#has_crl_extension? ⇒ Boolean
19 20 21 |
# File 'lib/cert_validator/crl/extractor.rb', line 19 def has_crl_extension? !! crl_extension end |
#has_distribution_points? ⇒ Boolean
15 16 17 |
# File 'lib/cert_validator/crl/extractor.rb', line 15 def has_distribution_points? ! distribution_points.empty? end |