lib/saml/kit/cli/xml_digital_signature.rb in saml-kit-cli-0.3.3 vs lib/saml/kit/cli/xml_digital_signature.rb in saml-kit-cli-0.3.4
- old
+ new
@@ -6,16 +6,17 @@
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]
- uri = URI.parse(file) rescue nil
+ path = File.expand_path(file)
- if uri.nil?
+ if File.exist?(path)
path = File.expand_path(file)
say_status :status, "Attempting to read #{path}...", :yellow
content = IO.read(path)
else
+ uri = URI.parse(file) rescue nil
say_status :status, "Downloading from #{uri}...", :yellow
content = Net::HTTP.get_response(uri).body.chomp
end
document = ::Xml::Kit::Document.new(content)
say document.to_xml(pretty: true)