Class: Yoti::AnchorProcessor
- Inherits:
-
Object
- Object
- Yoti::AnchorProcessor
- Defined in:
- lib/yoti/util/anchor_processor.rb
Overview
Parse attribute anchors
Instance Method Summary collapse
-
#anchor_types ⇒ Hash
deprecated
Deprecated.
no longer in use
-
#convert_certs_list_to_X509(certs_list) ⇒ Array<OpenSSL::X509::Certificate>
Convert certificate list to a list of X509 certificates.
-
#get_anchor_by_oid(cert, oid, sub_type, signed_time_stamp, x509_certs_list) ⇒ Yoti::Anchor?
deprecated
Deprecated.
no longer in use
-
#get_anchor_value_by_asn1_data(value, oid) ⇒ String?
deprecated
Deprecated.
no longer in use
-
#get_anchor_value_by_asn1_sequence(obj, oid) ⇒ String?
deprecated
Deprecated.
no longer in use
-
#get_anchor_value_by_oid(obj, oid) ⇒ String?
deprecated
Deprecated.
no longer in use
-
#initialize(anchors_list) ⇒ AnchorProcessor
constructor
A new instance of AnchorProcessor.
-
#process ⇒ Array<Yoti::Anchor>
Extract matching Attribute Anchors from list.
-
#process_signed_time_stamp(signed_time_stamp_binary) ⇒ Yoti::SignedTimeStamp
Return signed timestamp.
Constructor Details
#initialize(anchors_list) ⇒ AnchorProcessor
Returns a new instance of AnchorProcessor.
12 13 14 15 |
# File 'lib/yoti/util/anchor_processor.rb', line 12 def initialize(anchors_list) @anchors_list = anchors_list @get_next = false end |
Instance Method Details
#anchor_types ⇒ Hash
Deprecated.
no longer in use
Mapping of anchor types to oid.
152 153 154 |
# File 'lib/yoti/util/anchor_processor.rb', line 152 def anchor_types ANCHOR_LIST_KEYS end |
#convert_certs_list_to_X509(certs_list) ⇒ Array<OpenSSL::X509::Certificate>
Convert certificate list to a list of X509 certificates.
43 44 45 46 47 48 49 |
# File 'lib/yoti/util/anchor_processor.rb', line 43 def convert_certs_list_to_X509(certs_list) x509_certs_list = [] certs_list.each do |cert| x509_certs_list.push OpenSSL::X509::Certificate.new(cert) end x509_certs_list end |
#get_anchor_by_oid(cert, oid, sub_type, signed_time_stamp, x509_certs_list) ⇒ Yoti::Anchor?
Deprecated.
no longer in use
Return Anchor for provided oid.
77 78 79 80 81 82 |
# File 'lib/yoti/util/anchor_processor.rb', line 77 def get_anchor_by_oid(cert, oid, sub_type, signed_time_stamp, x509_certs_list) asn1_obj = OpenSSL::ASN1.decode(cert) anchor_value = get_anchor_value_by_oid(asn1_obj, oid) Yoti::Anchor.new(anchor_value, sub_type, signed_time_stamp, x509_certs_list) unless anchor_value.nil? end |
#get_anchor_value_by_asn1_data(value, oid) ⇒ String?
Deprecated.
no longer in use
Return Anchor value for ASN1 data.
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/yoti/util/anchor_processor.rb', line 116 def get_anchor_value_by_asn1_data(value, oid) if value.respond_to?(:to_s) && value == oid @get_next = true elsif value.respond_to?(:to_s) && @get_next @get_next = false return OpenSSL::ASN1.decode(value).value[0].value end get_anchor_value_by_oid(value, oid) end |
#get_anchor_value_by_asn1_sequence(obj, oid) ⇒ String?
Deprecated.
no longer in use
Return Anchor value for ASN1 sequence.
137 138 139 140 141 142 143 |
# File 'lib/yoti/util/anchor_processor.rb', line 137 def get_anchor_value_by_asn1_sequence(obj, oid) obj.each do |child_obj| result = get_anchor_value_by_oid(child_obj, oid) return result unless result.nil? end nil end |
#get_anchor_value_by_oid(obj, oid) ⇒ String?
Deprecated.
no longer in use
Return Anchor value for provided oid.
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/yoti/util/anchor_processor.rb', line 94 def get_anchor_value_by_oid(obj, oid) case obj when OpenSSL::ASN1::Sequence, Array return get_anchor_value_by_asn1_sequence(obj, oid) when OpenSSL::ASN1::ASN1Data return get_anchor_value_by_asn1_data(obj.value, oid) end # In case it's not a valid object nil end |
#process ⇒ Array<Yoti::Anchor>
Extract matching Attribute Anchors from list.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yoti/util/anchor_processor.rb', line 22 def process result_data = ANCHOR_LIST_KEYS.map { |key, _value| [key, []] }.to_h @anchors_list.each do |anchor| x509_certs_list = convert_certs_list_to_X509(anchor.origin_server_certs) signed_time_stamp = process_signed_time_stamp(anchor.signed_time_stamp) yoti_anchor = get_anchor_from_certs(x509_certs_list, anchor.sub_type, signed_time_stamp) anchor_list_key = get_anchor_list_key_by_type(yoti_anchor.type) result_data[anchor_list_key].push(yoti_anchor) end result_data end |
#process_signed_time_stamp(signed_time_stamp_binary) ⇒ Yoti::SignedTimeStamp
Return signed timestamp.
58 59 60 61 62 |
# File 'lib/yoti/util/anchor_processor.rb', line 58 def process_signed_time_stamp(signed_time_stamp_binary) signed_time_stamp = Yoti::Protobuf::Compubapi::SignedTimestamp.decode(signed_time_stamp_binary) time_in_sec = signed_time_stamp..quo(1000000) Yoti::SignedTimeStamp.new(signed_time_stamp.version, Time.at(time_in_sec)) end |