Class: X509Sleuth::ScannerPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/x509_sleuth/scanner_presenter.rb

Direct Known Subclasses

ScannerDetailedPresenter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scanner) ⇒ ScannerPresenter

Returns a new instance of ScannerPresenter.



7
8
9
# File 'lib/x509_sleuth/scanner_presenter.rb', line 7

def initialize(scanner)
  @scanner = scanner
end

Instance Attribute Details

#scannerObject (readonly)

Returns the value of attribute scanner.



5
6
7
# File 'lib/x509_sleuth/scanner_presenter.rb', line 5

def scanner
  @scanner
end

Instance Method Details

#filterObject



11
12
13
14
15
# File 'lib/x509_sleuth/scanner_presenter.rb', line 11

def filter
  @scanner.clients.reject do |client|
    client.connect_failed?
  end
end

#tableize(clients) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/x509_sleuth/scanner_presenter.rb', line 17

def tableize(clients)
  clients.collect do |client|
    if client.peer_certificate
      {
        host:       client.host,
        subject:    client.peer_certificate.subject,
        issuer:     client.peer_certificate.issuer,
        serial:     client.peer_certificate.serial,
        not_before: client.peer_certificate.not_before, 
        not_after:  client.peer_certificate.not_after
      }
    else
      {
        host:       client.host,
        subject:    "",
        issuer:     "",
        serial:     "",
        not_before: "", 
        not_after:  ""
      }
    end
  end
end

#to_sObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/x509_sleuth/scanner_presenter.rb', line 41

def to_s
  Formatador.display_compact_table(
    tableize(filter),
    [
      :host,
      :subject,
      :serial,
      :not_before,
      :not_after
    ]
  )
end