Class: Rails::Auth::X509::Certificate
- Inherits:
-
Object
- Object
- Rails::Auth::X509::Certificate
- Defined in:
- lib/rails/auth/x509/certificate.rb
Overview
X.509 client certificates obtained from HTTP requests
Instance Attribute Summary collapse
-
#certificate ⇒ Object
readonly
Returns the value of attribute certificate.
Instance Method Summary collapse
- #[](component) ⇒ Object
- #cn ⇒ Object (also: #common_name)
-
#initialize(certificate) ⇒ Certificate
constructor
A new instance of Certificate.
- #ou ⇒ Object (also: #organizational_unit)
Constructor Details
#initialize(certificate) ⇒ Certificate
Returns a new instance of Certificate.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rails/auth/x509/certificate.rb', line 10 def initialize(certificate) unless certificate.is_a?(OpenSSL::X509::Certificate) fail TypeError, "expecting OpenSSL::X509::Certificate, got #{certificate.class}" end @certificate = certificate.freeze @subject = {} @certificate.subject.to_a.each do |name, data, _type| @subject[name.freeze] = data.freeze end @subject.freeze end |
Instance Attribute Details
#certificate ⇒ Object (readonly)
Returns the value of attribute certificate.
8 9 10 |
# File 'lib/rails/auth/x509/certificate.rb', line 8 def certificate @certificate end |
Instance Method Details
#[](component) ⇒ Object
25 26 27 |
# File 'lib/rails/auth/x509/certificate.rb', line 25 def [](component) @subject[component.to_s.upcase] end |
#cn ⇒ Object Also known as: common_name
29 30 31 |
# File 'lib/rails/auth/x509/certificate.rb', line 29 def cn @subject["CN".freeze] end |
#ou ⇒ Object Also known as: organizational_unit
34 35 36 |
# File 'lib/rails/auth/x509/certificate.rb', line 34 def ou @subject["OU".freeze] end |