Sha256: acc54f51ea3c9cf5e1ff38569fb7fc20fb6ebb1238e0a6a33e88d8ff72289e89

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/components/base'

module Contrast
  module Config
    # Certificate Configuration
    class CertificationConfiguration
      include Contrast::Config::BaseConfiguration
      include Contrast::Components::ComponentBase

      CANON_NAME = 'api.certification'
      CONFIG_VALUES = %w[ca_file cert_file key_file enable].cs__freeze

      # @return [String] path to CA Cert file
      attr_accessor :ca_file
      # @return [String] path to Certification file
      attr_accessor :cert_file
      # @return [String] path to Certification Key file
      attr_accessor :key_file
      attr_writer :enable

      def initialize hsh = {}
        return unless hsh

        @enable = hsh[:enable]
        @ca_file = hsh[:ca_file]
        @cert_file = hsh[:cert_file]
        @key_file = hsh[:key_file]
      end

      # @return [Boolean, false]
      def enable
        @enable.nil? ? false : @enable
      end

      # Converts current configuration to effective config values class and appends them to
      # EffectiveConfig class.
      #
      # @param effective_config [Contrast::Config::Diagnostics::EffectiveConfig]
      def to_effective_config effective_config
        add_effective_config_values(effective_config, CONFIG_VALUES, CANON_NAME, CONTRAST)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
contrast-agent-7.3.2 lib/contrast/config/certification_configuration.rb
contrast-agent-7.3.1 lib/contrast/config/certification_configuration.rb
contrast-agent-7.3.0 lib/contrast/config/certification_configuration.rb
contrast-agent-7.2.0 lib/contrast/config/certification_configuration.rb
contrast-agent-7.1.0 lib/contrast/config/certification_configuration.rb