Class: EzCrypto::Name
- Inherits:
-
Object
- Object
- EzCrypto::Name
- Defined in:
- lib/gems/ezcrypto-0.7/lib/ezsig.rb
Overview
A handy ruby wrapper around OpenSSL’s Name object. This was created to make it really easy to extract information out of the certificate.
Instance Method Summary collapse
-
#[](attr_key) ⇒ Object
Lookup fields in the certificate.
-
#common_name ⇒ Object
(also: #name, #cn)
The common name.
-
#country ⇒ Object
(also: #c)
The 2 letter country code of the name.
-
#email ⇒ Object
Returns the email if present in the name.
-
#initialize(name) ⇒ Name
constructor
Initializes the Name object with the underlying OpenSSL Name object.
-
#locality ⇒ Object
(also: #l)
The locality.
- #method_missing(method) ⇒ Object
-
#organization ⇒ Object
(also: #o, #organisation)
The Organization.
-
#organizational_unit ⇒ Object
(also: #ou, #organisational_unit)
The Organizational Unit.
-
#state ⇒ Object
(also: #st, #province)
The state or province code.
-
#to_s ⇒ Object
Returns the full name object in classic horrible X500 format.
Constructor Details
#initialize(name) ⇒ Name
Initializes the Name object with the underlying OpenSSL Name object. You generally do not need to use this.
Rather use the Certificates subject or issuer methods.
385 386 387 388 389 390 391 392 393 394 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 385 def initialize(name) @name=name @attributes={} name.to_s.split(/\//).each do |field| key, val = field.split(/=/,2) if key @attributes[key.to_sym]=val end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
467 468 469 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 467 def method_missing(method) self[method] end |
Instance Method Details
#[](attr_key) ⇒ Object
Lookup fields in the certificate.
463 464 465 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 463 def [](attr_key) @attributes[attr_key.to_sym] end |
#common_name ⇒ Object Also known as: name, cn
The common name. For SSL this means the domain name. For personal certificates it is the name.
454 455 456 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 454 def common_name self[:CN] end |
#country ⇒ Object Also known as: c
The 2 letter country code of the name
412 413 414 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 412 def country self[:C] end |
#email ⇒ Object
Returns the email if present in the name
406 407 408 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 406 def email self[:emailAddress] end |
#locality ⇒ Object Also known as: l
The locality
428 429 430 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 428 def locality self[:L] end |
#organization ⇒ Object Also known as: o, organisation
The Organization
445 446 447 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 445 def organization self[:O] end |
#organizational_unit ⇒ Object Also known as: ou, organisational_unit
The Organizational Unit
436 437 438 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 436 def organizational_unit self[:OU] end |
#state ⇒ Object Also known as: st, province
The state or province code
419 420 421 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 419 def state self[:ST] end |
#to_s ⇒ Object
Returns the full name object in classic horrible X500 format.
399 400 401 |
# File 'lib/gems/ezcrypto-0.7/lib/ezsig.rb', line 399 def to_s @name.to_s end |