Class: Gitlab::X509::Signature

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/x509/signature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(signature_text, signed_text, email, created_at) ⇒ Signature

Returns a new instance of Signature.


12
13
14
15
16
17
# File 'lib/gitlab/x509/signature.rb', line 12

def initialize(signature_text, signed_text, email, created_at)
  @signature_text = signature_text
  @signed_text = signed_text
  @email = email
  @created_at = created_at
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at


10
11
12
# File 'lib/gitlab/x509/signature.rb', line 10

def created_at
  @created_at
end

#signature_textObject (readonly)

Returns the value of attribute signature_text


10
11
12
# File 'lib/gitlab/x509/signature.rb', line 10

def signature_text
  @signature_text
end

#signed_textObject (readonly)

Returns the value of attribute signed_text


10
11
12
# File 'lib/gitlab/x509/signature.rb', line 10

def signed_text
  @signed_text
end

Instance Method Details

#userObject


25
26
27
# File 'lib/gitlab/x509/signature.rb', line 25

def user
  User.find_by_any_email(@email)
end

#verification_statusObject


33
34
35
36
37
38
39
40
41
# File 'lib/gitlab/x509/signature.rb', line 33

def verification_status
  return :unverified if x509_certificate.nil? || x509_certificate.revoked?

  if verified_signature && certificate_email == @email
    :verified
  else
    :unverified
  end
end

#verified_signatureObject


29
30
31
# File 'lib/gitlab/x509/signature.rb', line 29

def verified_signature
  strong_memoize(:verified_signature) { verified_signature? }
end

#x509_certificateObject


19
20
21
22
23
# File 'lib/gitlab/x509/signature.rb', line 19

def x509_certificate
  return if certificate_attributes.nil?

  X509Certificate.safe_create!(certificate_attributes) unless verified_signature.nil?
end