Class: Gitlab::X509::Signature
- Inherits:
-
Object
- Object
- Gitlab::X509::Signature
- Includes:
- Utils::StrongMemoize, SignatureType
- Defined in:
- lib/gitlab/x509/signature.rb
Constant Summary
Constants included from SignatureType
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#signature_text ⇒ Object
readonly
Returns the value of attribute signature_text.
-
#signed_text ⇒ Object
readonly
Returns the value of attribute signed_text.
Instance Method Summary collapse
-
#initialize(signature_text, signed_text, email, created_at) ⇒ Signature
constructor
A new instance of Signature.
- #signed_by_user ⇒ Object
- #type ⇒ Object
- #verification_status ⇒ Object
- #verified_signature ⇒ Object
- #x509_certificate ⇒ Object
Constructor Details
#initialize(signature_text, signed_text, email, created_at) ⇒ Signature
Returns a new instance of Signature.
13 14 15 16 17 18 |
# File 'lib/gitlab/x509/signature.rb', line 13 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_at ⇒ Object (readonly)
Returns the value of attribute created_at.
11 12 13 |
# File 'lib/gitlab/x509/signature.rb', line 11 def created_at @created_at end |
#signature_text ⇒ Object (readonly)
Returns the value of attribute signature_text.
11 12 13 |
# File 'lib/gitlab/x509/signature.rb', line 11 def signature_text @signature_text end |
#signed_text ⇒ Object (readonly)
Returns the value of attribute signed_text.
11 12 13 |
# File 'lib/gitlab/x509/signature.rb', line 11 def signed_text @signed_text end |
Instance Method Details
#signed_by_user ⇒ Object
30 31 32 |
# File 'lib/gitlab/x509/signature.rb', line 30 def signed_by_user strong_memoize(:signed_by_user) { User.find_by_any_email(@email) } end |
#type ⇒ Object
20 21 22 |
# File 'lib/gitlab/x509/signature.rb', line 20 def type :x509 end |
#verification_status ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gitlab/x509/signature.rb', line 38 def verification_status return :unverified if x509_certificate.nil? || x509_certificate.revoked? || certificate_subject.nil? || certificate_crl.nil? || !verified_signature || signed_by_user.nil? if signed_by_user.verified_emails.include?(@email.downcase) return :verified if certificate_emails.find do |ce| ce.casecmp?(@email) end end :unverified end |
#verified_signature ⇒ Object
34 35 36 |
# File 'lib/gitlab/x509/signature.rb', line 34 def verified_signature strong_memoize(:verified_signature) { verified_signature? } end |
#x509_certificate ⇒ Object
24 25 26 27 28 |
# File 'lib/gitlab/x509/signature.rb', line 24 def x509_certificate return if certificate_attributes.nil? X509Certificate.safe_create!(certificate_attributes) unless verified_signature.nil? end |