Sha256: ebc495ed37c80e255589b95d2a867f719aea9d848606cd70a07c302508409963

Contents?: true

Size: 917 Bytes

Versions: 2

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

require 'xml/kit/key_info/key_value'
require 'xml/kit/key_info/retrieval_method'
require 'xml/kit/key_info/rsa_key_value'

module Xml
  module Kit
    # An implementation of the KeyInfo element.
    # https://www.w3.org/TR/xmldsig-core1/#sec-KeyInfo
    #
    # @since 0.3.0
    class KeyInfo
      include Templatable
      attr_accessor :key_name
      attr_accessor :x509_data
      attr_accessor :encrypted_key

      def initialize(x509: nil)
        @x509_data = x509
        yield self if block_given?
      end

      def key_value
        @key_value ||= KeyValue.new
      end

      def retrieval_method
        @retrieval_method ||= RetrievalMethod.new
      end

      def subject_key_identifier
        ski = x509_data.extensions.find { |x| x.oid == 'subjectKeyIdentifier' }
        return if ski.nil?

        Base64.strict_encode64(ski.value)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xml-kit-0.3.1 lib/xml/kit/key_info.rb
xml-kit-0.3.0 lib/xml/kit/key_info.rb