Class: SSLyze::X509::Domain
- Inherits:
-
Object
- Object
- SSLyze::X509::Domain
- Defined in:
- lib/sslyze/x509/domain.rb
Overview
Represents a domain name pattern.
Instance Attribute Summary collapse
-
#domain ⇒ String
readonly
The domain part of the subject name.
-
#name ⇒ String
(also: #to_s, #to_str)
readonly
The subject name.
-
#suffix ⇒ String
readonly
The literal suffix of the subject name.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares two subject names.
-
#include?(domain) ⇒ Boolean
(also: #===)
Tests whether the domain is matched by the subject name.
-
#initialize(name) ⇒ Domain
constructor
Initializes the subject name.
-
#inspect ⇒ String
Inspects the subject name.
Constructor Details
#initialize(name) ⇒ Domain
Initializes the subject name.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sslyze/x509/domain.rb', line 31 def initialize(name) @name = name if @name.start_with?('*.') @suffix = @name[1..-1] @domain = @name[2..-1] else @domain = @name end end |
Instance Attribute Details
#domain ⇒ String (readonly)
The domain part of the subject name.
18 19 20 |
# File 'lib/sslyze/x509/domain.rb', line 18 def domain @domain end |
#name ⇒ String (readonly) Also known as: to_s, to_str
The subject name.
13 14 15 |
# File 'lib/sslyze/x509/domain.rb', line 13 def name @name end |
#suffix ⇒ String (readonly)
The literal suffix of the subject name.
23 24 25 |
# File 'lib/sslyze/x509/domain.rb', line 23 def suffix @suffix end |
Instance Method Details
#==(other) ⇒ Boolean
Compares two subject names.
47 48 49 |
# File 'lib/sslyze/x509/domain.rb', line 47 def ==(other) other.kind_of?(self.class) && @name == other.name end |
#include?(domain) ⇒ Boolean Also known as: ===
Tests whether the domain is matched by the subject name.
54 55 56 57 58 59 60 61 |
# File 'lib/sslyze/x509/domain.rb', line 54 def include?(domain) if @name.start_with?('*.') # wildcard domain.end_with?(@suffix) || # does the domain share the suffix domain == @domain # does the domain match the suffix else # exact match domain == @name end end |
#inspect ⇒ String
Inspects the subject name.
73 74 75 |
# File 'lib/sslyze/x509/domain.rb', line 73 def inspect "#<#{self.class}: #{self}>" end |