Class: Rex::Proto::Kerberos::Model::KerberosFlags
- Inherits:
-
Object
- Object
- Rex::Proto::Kerberos::Model::KerberosFlags
- Defined in:
- lib/rex/proto/kerberos/model/kerberos_flags.rb
Overview
Represents KerberosFlags. www.rfc-editor.org/rfc/rfc4120.txt
Direct Known Subclasses
Instance Attribute Summary collapse
-
#value ⇒ Integer
readonly
The integer value of the kerberos flags.
Class Method Summary collapse
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #===)
Override the equality test for KdcOptionFlags.
-
#enabled_flag_names ⇒ Array<String>
The enabled flag names.
-
#include?(flag) ⇒ Boolean
Whether the flag is present within the current KdcOptionFlags.
-
#initialize(value) ⇒ KerberosFlags
constructor
A new instance of KerberosFlags.
- #to_i ⇒ Object
Constructor Details
#initialize(value) ⇒ KerberosFlags
Returns a new instance of KerberosFlags.
15 16 17 18 |
# File 'lib/rex/proto/kerberos/model/kerberos_flags.rb', line 15 def initialize(value) raise ArgumentError, 'Invalid value' unless value.is_a?(Integer) @value = value end |
Instance Attribute Details
#value ⇒ Integer (readonly)
Returns the integer value of the kerberos flags.
11 12 13 |
# File 'lib/rex/proto/kerberos/model/kerberos_flags.rb', line 11 def value @value end |
Class Method Details
.from_flags(flags) ⇒ Rex::Proto::Kerberos::Model::KdcOptionFlags
22 23 24 25 26 27 28 29 |
# File 'lib/rex/proto/kerberos/model/kerberos_flags.rb', line 22 def self.from_flags(flags) value = 0 flags.each do |flag| value |= 1 << (31 - flag) end new(value) end |
.name(value) ⇒ Object
49 50 51 |
# File 'lib/rex/proto/kerberos/model/kerberos_flags.rb', line 49 def self.name(value) constants.select { |c| c.upcase == c }.find { |c| const_get(c) == value } end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: ===
Override the equality test for KdcOptionFlags. Equality is always tested against the #value of the KdcOptionFlags.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rex/proto/kerberos/model/kerberos_flags.rb', line 59 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 |
#enabled_flag_names ⇒ Array<String>
Returns The enabled flag names.
42 43 44 45 46 47 |
# File 'lib/rex/proto/kerberos/model/kerberos_flags.rb', line 42 def enabled_flag_names sorted_flag_names = self.class.constants.sort_by { |name| self.class.const_get(name) } enabled_flag_names = sorted_flag_names.select { |flag| include?(self.class.const_get(flag)) } enabled_flag_names end |
#include?(flag) ⇒ Boolean
Returns whether the flag is present within the current KdcOptionFlags.
37 38 39 |
# File 'lib/rex/proto/kerberos/model/kerberos_flags.rb', line 37 def include?(flag) ((value >> (31 - flag)) & 1) == 1 end |
#to_i ⇒ Object
31 32 33 |
# File 'lib/rex/proto/kerberos/model/kerberos_flags.rb', line 31 def to_i @value end |