Sha256: 758264e119fa9d9d4da44f17a34bcc99f7cf12c4fd7dd942751e39f8f6d5b1c0

Contents?: true

Size: 982 Bytes

Versions: 1

Compression:

Stored size: 982 Bytes

Contents

module SmartId
  module AuthenticationCertificate
    class Content
      def initialize(raw_content)
        @raw_content = raw_content
      end

      def given_name
        structured_raw_content["GN"].gsub(",", " ")
      end

      def surname
        structured_raw_content["SN"].gsub(",", " ")
      end
      
      def country
        structured_raw_content["C"].gsub(",", " ")
      end

      def all_info
        structured_raw_content["CN"]
      end

      def organizational_unit
        structured_raw_content["OU"]
      end

      def serial_number
        structured_raw_content["serialNumber"]
      end

      private

      def structured_raw_content
        return @structured_raw_content if @structured_raw_content
        @structured_raw_content = @raw_content.split("/").each_with_object({}) do |c, result|
          if c.include?("=")
            key, val = c.split("=")
            result[key] = val
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_id-0.1.0 lib/smart_id/authentication_certificate/content.rb