Class: Net::NTLM::Message

Inherits:
FieldSet show all
Defined in:
lib/watobo/external/ntlm/ntlm.rb

Defined Under Namespace

Classes: Type1, Type2, Type3

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FieldSet

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

Constructor Details

This class inherits a constructor from Net::NTLM::FieldSet

Class Method Details

.decode64(str) ⇒ Object


562
563
564
# File 'lib/watobo/external/ntlm/ntlm.rb', line 562

def decode64(str)
  parse(Base64.decode64(str))
end

.parse(str) ⇒ Object


546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/watobo/external/ntlm/ntlm.rb', line 546

def parse(str)
  m = Type0.new
  m.parse(str)
  case m.type
  when 1
    t = Type1.parse(str)
  when 2
    t = Type2.parse(str)
  when 3
    t = Type3.parse(str)
  else
    raise ArgumentError, "unknown type: #{m.type}"
  end
  t
end

Instance Method Details

#data_sizeObject


594
595
596
# File 'lib/watobo/external/ntlm/ntlm.rb', line 594

def data_size
  security_buffers.inject(0){|sum, a| sum += a[1].data_size}
end

#decode64(str) ⇒ Object


588
589
590
# File 'lib/watobo/external/ntlm/ntlm.rb', line 588

def decode64(str)
  parse(Base64.decode64(str))
end

#dump_flagsObject


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

def dump_flags
  FLAG_KEYS.each{ |k| print(k, "=", flag?(k), "\n") }
end

#encode64Object


584
585
586
# File 'lib/watobo/external/ntlm/ntlm.rb', line 584

def encode64
  Base64.encode64(serialize).gsub(/\n/, '')
end

#has_flag?(flag) ⇒ Boolean

Returns:

  • (Boolean)

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

def has_flag?(flag)
  (self[:flag].value & FLAGS[flag]) == FLAGS[flag]
end

#head_sizeObject


592
# File 'lib/watobo/external/ntlm/ntlm.rb', line 592

alias head_size size

#serializeObject


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

def serialize
  deflag
  super + security_buffers.map{|n, f| f.value}.join
end

#set_flag(flag) ⇒ Object


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

def set_flag(flag)
  self[:flag].value  |= FLAGS[flag]
end

#sizeObject


598
599
600
# File 'lib/watobo/external/ntlm/ntlm.rb', line 598

def size
  head_size + data_size
end