Sha256: d2ac65943cfb8fb0003f0f8389870cbe53f8937431208c919eae2537eca30e35

Contents?: true

Size: 1.73 KB

Versions: 13

Compression:

Stored size: 1.73 KB

Contents

module MDQT

  class CLI

    require 'mdqt/cli/base'

    class List < Base

      def run

        options.validate = true

        advise_on_xml_signing_support

        halt!("Cannot check a metadata file without XML support: please install additional gems") unless MDQT::Client.verification_available?

        response = get_response
        result = verify_result(response)

        puts result.entity_ids

      end

      def get_response

        client = MDQT::Client.new(
          service_url(options),
          verbose: options.verbose,
          explain: options.explain ? true : false,
          tls_risky: options.tls_risky ? true : false,
          cache_type: MDQT::CLI::CacheControl.cache_type(options),
        )

        client.get_metadata("")

      end

      def verify_result(result)

        if options.validate
          halt! "The data for #{result.identifier} is not valid when checked against schema:\n#{result.validation_error}" unless result.valid?
          btw "Data for #{result.identifier.empty? ? 'aggregate' : result.identifier } has been validated against schema" ## FIXME - needs constistent #label maybe?
        end

        return result unless options.verify_with

        cert_paths = extract_certificate_paths(options.verify_with)

        halt! "Data from #{options.service} is not signed, cannot verify!" unless result.signed?
        halt! "The data for #{result.identifier} cannot be verified using #{cert_paths.to_sentence}" unless result.verified_signature?(cert_paths)
        btw "Data for #{result.identifier.empty? ? 'aggregate' : result.identifier } has been verified using '#{cert_paths.to_sentence}'" ## FIXME - needs constistent #label maybe?

        result

      end

    end

    private

  end

end


Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
aaf-mdqt-0.8.8 lib/mdqt/cli/list.rb
aaf-mdqt-0.8.7 lib/mdqt/cli/list.rb
aaf-mdqt-0.8.6 lib/mdqt/cli/list.rb
aaf-mdqt-0.8.5 lib/mdqt/cli/list.rb
aaf-mdqt-0.8.4 lib/mdqt/cli/list.rb
aaf-mdqt-0.8.3 lib/mdqt/cli/list.rb
aaf-mdqt-0.8.2 lib/mdqt/cli/list.rb
aaf-mdqt-0.8.1 lib/mdqt/cli/list.rb
aaf-mdqt-0.8.0 lib/mdqt/cli/list.rb
mdqt-0.8.0 lib/mdqt/cli/list.rb
mdqt-0.7.0 lib/mdqt/cli/list.rb
mdqt-0.6.0 lib/mdqt/cli/list.rb
mdqt-0.5.0 lib/mdqt/cli/list.rb