Module: ForemanX509::CertificatesHelper

Defined in:
app/helpers/foreman_x509/certificates_helper.rb

Instance Method Summary collapse

Instance Method Details

#certificate_detailsObject



3
4
5
6
7
8
9
# File 'app/helpers/foreman_x509/certificates_helper.rb', line 3

def certificate_details
  if @certificate.certificate.present?
    @certificate.certificate.to_text
  else
    @certificate.subject.to_s(OpenSSL::X509::Name::MULTILINE)
  end
end


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/foreman_x509/certificates_helper.rb', line 16

def certificate_download_links
  links = []

  links << link_to(_('Download Certificate'), certificate_certificate_path(@certificate),
                   class: 'btn btn-default',
                   title: _('Download the PEM format certificate')) unless @certificate.certificate.nil?

  links << link_to(_('Sign Request'), request_path(@certificate.request),
                   class: 'btn btn-default',
                   title: _('Upload the signed certificate')) unless @certificate.request.nil?

  links << link_to(_('Download Key'), key_certificate_path(@certificate),
                   class: 'btn btn-default',
                   title: _('Download the PEM format private key')) unless @certificate.key.nil?

  links
end

#generation_actions(generation) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/foreman_x509/certificates_helper.rb', line 34

def generation_actions(generation)
  buttons = []

  params = [generation.owner, generation]

  buttons << link_to(_('Activate'), generation_path(*params, generation: { active: true }), method: :put) if generation.status == 'inactive'
  buttons << link_to(_('Download Certificate'), certificate_generation_path(*params)) unless generation.status == 'pending'
  buttons << link_to(_('Upload Certificate'), request_path(generation.request)) if generation.status == 'pending'
  buttons << link_to(_('Download Request'), request_path(generation.request, format: :pem)) if generation.status == 'pending'
  buttons << link_to(_('Download Key'), key_generation_path(*params)) unless generation.key.nil?
  buttons << link_to(_('Delete'), generation_path(*params), method: :delete, data: { confirm: _("Are you sure?") }) unless generation.active?

  action_buttons(buttons)
end


11
12
13
14
# File 'app/helpers/foreman_x509/certificates_helper.rb', line 11

def issuer_link(certificate)
  return if certificate.issuer.nil?
  link_to certificate.issuer.name, issuer_path(certificate.issuer)
end