Class: Rex::Proto::Kerberos::Model::Error::ErrorCode
- Inherits:
-
Object
- Object
- Rex::Proto::Kerberos::Model::Error::ErrorCode
- Defined in:
- lib/rex/proto/kerberos/model/error.rb
Overview
This class represents a Kerberos Error Code as defined in: datatracker.ietf.org/doc/html/rfc4120#section-7.5.9 docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4768#table-2-kerberos-ticket-flags)
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
The description of the error the code represents.
-
#name ⇒ String
readonly
The name of the error code.
-
#value ⇒ Integer
readonly
The error code that was given as a return value.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #===)
Override the equality test for ErrorCodes.
-
#initialize(name, value, description) ⇒ ErrorCode
constructor
A new instance of ErrorCode.
- #to_s ⇒ Object
Constructor Details
#initialize(name, value, description) ⇒ ErrorCode
Returns a new instance of ErrorCode.
26 27 28 29 30 31 32 33 34 |
# File 'lib/rex/proto/kerberos/model/error.rb', line 26 def initialize(name, value, description) raise ArgumentError, 'Invalid Error Name' unless name.is_a?(String) && !name.empty? raise ArgumentError, 'Invalid Error Code Value' unless value.is_a?(Integer) raise ArgumentError, 'Invalid Error Description' unless description.is_a?(String) && !description.empty? @name = name @value = value @description = description end |
Instance Attribute Details
#description ⇒ String (readonly)
Returns the description of the error the code represents.
16 17 18 |
# File 'lib/rex/proto/kerberos/model/error.rb', line 16 def description @description end |
#name ⇒ String (readonly)
Returns the name of the error code.
18 19 20 |
# File 'lib/rex/proto/kerberos/model/error.rb', line 18 def name @name end |
#value ⇒ Integer (readonly)
Returns the error code that was given as a return value.
20 21 22 |
# File 'lib/rex/proto/kerberos/model/error.rb', line 20 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: ===
Override the equality test for ErrorCodes. Equality is always tested against the #value of the error code.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rex/proto/kerberos/model/error.rb', line 42 def ==(other) if other.is_a? self.class value == other.value elsif other.is_a? Integer value == other elsif other.nil? false else raise ArgumentError, "Cannot compare a #{self.class} to a #{other.class}" end end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/rex/proto/kerberos/model/error.rb', line 56 def to_s "#{name} (#{value}) - #{description}" end |