Class: MDQT::CLI::List
- Inherits:
-
Base
- Object
- Base
- MDQT::CLI::List
show all
- Defined in:
- lib/mdqt/cli/list.rb
Instance Method Summary
collapse
Methods inherited from Base
#advise_on_xml_signing_support, #args, #btw, check_requirements, #colour_shell?, #explain, #extract_certificate_paths, #get_stdin, #halt!, #hey, #initialize, introduce, #options, #options=, #output, #pastel, #pipeable?, run, #say, #service_url, service_url, #yay
Instance Method Details
#get_response ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/mdqt/cli/list.rb', line 24
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
|
#run ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/mdqt/cli/list.rb', line 9
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
|
#verify_result(result) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/mdqt/cli/list.rb', line 38
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" end
return result unless options.verify_with
cert_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}'"
result
end
|