Class: Watobo::NTLM::SecurityBuffer

Inherits:
FieldSet
  • Object
show all
Defined in:
lib/watobo/utils/ntlm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FieldSet

#[], #[]=, #disable, #enable, int16LE, int32LE, int64LE, names, opts, prototypes, security_buffer, #size, string, types

Constructor Details

#initialize(opts) ⇒ SecurityBuffer

Returns a new instance of SecurityBuffer.



550
551
552
553
554
555
# File 'lib/watobo/utils/ntlm.rb', line 550

def initialize(opts)
  super()
  @value  = opts[:value]
  @active = opts[:active].nil? ? true : opts[:active]
  @size = 8
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



549
550
551
# File 'lib/watobo/utils/ntlm.rb', line 549

def active
  @active
end

Instance Method Details

#allocatedInt16LE

Returns:



546
# File 'lib/watobo/utils/ntlm.rb', line 546

int16LE   :allocated,     {:value => 0}

#allocated=Int16LE

Returns:



546
# File 'lib/watobo/utils/ntlm.rb', line 546

int16LE   :allocated,     {:value => 0}

#data_sizeObject



580
581
582
# File 'lib/watobo/utils/ntlm.rb', line 580

def data_size
  @active ? @value.size : 0
end

#lengthInt16LE

Returns:



545
# File 'lib/watobo/utils/ntlm.rb', line 545

int16LE   :length,        {:value => 0}

#length=Int16LE

Returns:



545
# File 'lib/watobo/utils/ntlm.rb', line 545

int16LE   :length,        {:value => 0}

#offsetInt32LE

Returns:



547
# File 'lib/watobo/utils/ntlm.rb', line 547

int32LE   :offset,        {:value => 0}

#offset=Int32LE

Returns:



547
# File 'lib/watobo/utils/ntlm.rb', line 547

int32LE   :offset,        {:value => 0}

#parse(str, offset = 0) ⇒ Object



557
558
559
560
561
562
563
564
565
# File 'lib/watobo/utils/ntlm.rb', line 557

def parse(str, offset=0)
  if @active and str.size >= offset + @size
    super(str, offset)
    @value = str[self.offset, self.length]
    @size
  else
    0
  end
end

#serializeObject



567
568
569
# File 'lib/watobo/utils/ntlm.rb', line 567

def serialize
  super if @active
end

#valueObject



571
572
573
# File 'lib/watobo/utils/ntlm.rb', line 571

def value
  @value
end

#value=(val) ⇒ Object



575
576
577
578
# File 'lib/watobo/utils/ntlm.rb', line 575

def value=(val)
  @value = val
  self.length = self.allocated = val.size
end