Sha256: ab047b9e029f1972d9cc3cf3e45892249dd5d93bd3c0309b666b807087453139

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Saml
  module Kit
    module Cli
      class XmlDigitalSignature < Thor
        desc "verify file", "Verify if the contents of a file has a valid signature."
        method_option :format, default: "short", required: false, enum: ["short", "full"]
        def verify(file)
          format = options[:format]
          path = File.expand_path(file)
          say_status :status, "Attempting to read #{path}...", :yellow
          content = IO.read(path)
          document = ::Xml::Kit::Document.new(content)

          if document.valid?
            say_status :success, "#{file} is valid", :green
          else
            document.errors.full_messages.each do |error|
              say_status :error, error, :red
            end

            if "full" == format
              document.send(:invalid_signatures).each_with_index do |invalid_signature, index|
                say "Signature: #{index}"
                say invalid_signature.signature.to_xml(indent: 2), :red
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
saml-kit-cli-0.3.0 lib/saml/kit/cli/xml_digital_signature.rb