saml-kit-cli 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,42 +0,0 @@
1
- require 'uri'
2
-
3
- module Saml
4
- module Kit
5
- module Cli
6
- class XmlDigitalSignature < Thor
7
- desc "verify file", "Verify if the contents of a file has a valid signature."
8
- method_option :format, default: "short", required: false, enum: ["short", "full"]
9
- def verify(file)
10
- format = options[:format]
11
- path = File.expand_path(file)
12
-
13
- if File.exist?(path)
14
- path = File.expand_path(file)
15
- say_status :status, "Attempting to read #{path}...", :yellow
16
- content = IO.read(path)
17
- else
18
- uri = URI.parse(file) rescue nil
19
- say_status :status, "Downloading from #{uri}...", :yellow
20
- content = Net::HTTP.get_response(uri).body.chomp
21
- end
22
- document = ::Xml::Kit::Document.new(content)
23
- say document.to_xml(pretty: true)
24
- if document.valid?
25
- say_status :success, "#{file} is valid", :green
26
- else
27
- document.errors.full_messages.each do |error|
28
- say_status :error, error, :red
29
- end
30
-
31
- if "full" == format
32
- document.send(:invalid_signatures).each_with_index do |invalid_signature, index|
33
- say "Signature: #{index}"
34
- say invalid_signature.signature.to_xml(indent: 2), :red
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end