lib/net/ntlm/message.rb in rubyntlm-0.4.0 vs lib/net/ntlm/message.rb in rubyntlm-0.5.0

- old
+ new

@@ -18,13 +18,14 @@ :DOMAIN_SUPPLIED => 0x00001000, :WORKSTATION_SUPPLIED => 0x00002000, :LOCAL_CALL => 0x00004000, :ALWAYS_SIGN => 0x00008000, :TARGET_TYPE_DOMAIN => 0x00010000, - :TARGET_INFO => 0x00800000, :NTLM2_KEY => 0x00080000, + :TARGET_INFO => 0x00800000, :KEY128 => 0x20000000, + :KEY_EXCHANGE => 0x40000000, :KEY56 => 0x80000000 }.freeze FLAG_KEYS = FLAGS.keys.sort{|a, b| FLAGS[a] <=> FLAGS[b] } @@ -40,24 +41,37 @@ class << Message 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}" + when 1 + t = Type1.new.parse(str) + when 2 + t = Type2.new.parse(str) + when 3 + t = Type3.new.parse(str) + else + raise ArgumentError, "unknown type: #{m.type}" end t end def decode64(str) parse(Base64.decode64(str)) end + end + + # @return [self] + def parse(str) + super + + while has_disabled_fields? && serialize.size < str.size + # enable the next disabled field + self.class.names.find { |name| !self[name].active && enable(name) } + super + end + + self end def has_flag?(flag) (self[:flag].value & FLAGS[flag]) == FLAGS[flag] end