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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +15 -0
- data/.rubocop.yml +81 -0
- data/.travis.yml +7 -1
- data/Gemfile +4 -2
- data/README.md +16 -19
- data/Rakefile +10 -3
- data/bin/cibuild +21 -0
- data/bin/console +4 -3
- data/bin/lint +11 -0
- data/bin/test +17 -0
- data/exe/saml-kit +4 -3
- data/lib/saml/kit/cli/certificate_report.rb +38 -0
- data/lib/saml/kit/cli/commands/certificate.rb +31 -0
- data/lib/saml/kit/cli/commands/decode.rb +54 -0
- data/lib/saml/kit/cli/commands/metadata.rb +42 -0
- data/lib/saml/kit/cli/commands/xml_digital_signature.rb +26 -0
- data/lib/saml/kit/cli/commands.rb +6 -0
- data/lib/saml/kit/cli/generate_key_pair.rb +40 -0
- data/lib/saml/kit/cli/report.rb +20 -90
- data/lib/saml/kit/cli/signature_report.rb +56 -0
- data/lib/saml/kit/cli/version.rb +3 -1
- data/lib/saml/kit/cli/yaml_registry.rb +9 -10
- data/lib/saml/kit/cli.rb +36 -19
- data/lib/saml/kit/core_ext/assertion.rb +26 -0
- data/lib/saml/kit/core_ext/authentication_request.rb +14 -0
- data/lib/saml/kit/core_ext/document.rb +25 -0
- data/lib/saml/kit/core_ext/logout_request.rb +13 -0
- data/lib/saml/kit/core_ext/metadata.rb +40 -0
- data/lib/saml/kit/core_ext/response.rb +13 -0
- data/lib/saml/kit/core_ext/signature.rb +28 -0
- data/saml-kit-cli.gemspec +22 -17
- metadata +69 -11
- data/lib/saml/kit/cli/certificate.rb +0 -45
- data/lib/saml/kit/cli/decode.rb +0 -44
- data/lib/saml/kit/cli/metadata.rb +0 -35
- data/lib/saml/kit/cli/xml_digital_signature.rb +0 -42
@@ -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
|