Class: Registration::SslCertificateDetails

Inherits:
Object
  • Object
show all
Includes:
ERB::Util, Yast::I18n
Defined in:
src/lib/registration/ssl_certificate_details.rb

Overview

class handling SSL certificate TODO: move it to yast2 to share it?

Constant Summary collapse

INDENT =

indent size used in summary text

" " * 3

Instance Method Summary collapse

Constructor Details

#initialize(certificate) ⇒ SslCertificateDetails


18
19
20
21
# File 'src/lib/registration/ssl_certificate_details.rb', line 18

def initialize(certificate)
  textdomain "registration"
  @certificate = certificate
end

Instance Method Details

#issuerObject


28
29
30
31
# File 'src/lib/registration/ssl_certificate_details.rb', line 28

def issuer
  identity_details(certificate.issuer_name, certificate.issuer_organization,
    certificate.issuer_organization_unit)
end

#richtext_summaryObject


50
51
52
# File 'src/lib/registration/ssl_certificate_details.rb', line 50

def richtext_summary
  Helpers.render_erb_template("certificate_summary.erb", binding)
end

#subjectObject


23
24
25
26
# File 'src/lib/registration/ssl_certificate_details.rb', line 23

def subject
  identity_details(certificate.subject_name, certificate.subject_organization,
    certificate.subject_organization_unit)
end

#summary(small_space: false) ⇒ Object


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'src/lib/registration/ssl_certificate_details.rb', line 33

def summary(small_space: false)
  summary = _("Certificate:") + "\n" + _("Issued To") + "\n" + subject +
    "\n" + _("Issued By") + "\n" + issuer + "\n" + _("SHA1 Fingerprint: ") +
    "\n" + INDENT + certificate.fingerprint(Fingerprint::SHA1).value + "\n" +
    _("SHA256 Fingerprint: ") + "\n"

  sha256 = certificate.fingerprint(Fingerprint::SHA256).value
  summary += if small_space
    # split the long SHA256 digest to two lines in small text mode UI
    INDENT + sha256[0..59] + "\n" + INDENT + sha256[60..-1]
  else
    INDENT + sha256
  end

  summary
end