Class: Net::NTLM::Message
- Inherits:
-
FieldSet
show all
- Defined in:
- lib/net/ntlm/message.rb,
lib/net/ntlm/message/type0.rb,
lib/net/ntlm/message/type1.rb,
lib/net/ntlm/message/type2.rb,
lib/net/ntlm/message/type3.rb
Defined Under Namespace
Classes: Type0, Type1, Type2, Type3
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from FieldSet
#[], #[]=, #disable, #enable, #has_disabled_fields?, #initialize, int16LE, int32LE, int64LE, names, opts, prototypes, security_buffer, string, types
Class Method Details
.decode64(str) ⇒ Object
65
66
67
|
# File 'lib/net/ntlm/message.rb', line 65
def decode64(str)
parse(Base64.decode64(str))
end
|
.parse(str) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/net/ntlm/message.rb', line 49
def parse(str)
m = Type0.new
m.parse(str)
case 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
|
Instance Method Details
#data_edge ⇒ Object
131
132
133
|
# File 'lib/net/ntlm/message.rb', line 131
def data_edge
security_buffers.map{ |n, f| f.active ? f.offset : size}.min
end
|
#data_size ⇒ Object
110
111
112
|
# File 'lib/net/ntlm/message.rb', line 110
def data_size
security_buffers.inject(0){|sum, a| sum += a[1].data_size}
end
|
#decode64(str) ⇒ Object
104
105
106
|
# File 'lib/net/ntlm/message.rb', line 104
def decode64(str)
parse(Base64.decode64(str))
end
|
#deflag ⇒ Object
123
124
125
126
127
128
129
|
# File 'lib/net/ntlm/message.rb', line 123
def deflag
security_buffers.inject(head_size){|cur, a|
a[1].offset = cur
cur += a[1].data_size
has_flag?(:UNICODE) ? cur + cur % 2 : cur
}
end
|
#dump_flags ⇒ Object
91
92
93
|
# File 'lib/net/ntlm/message.rb', line 91
def dump_flags
FLAG_KEYS.each{ |k| print(k, "=", has_flag?(k), "\n") }
end
|
#encode64 ⇒ Object
100
101
102
|
# File 'lib/net/ntlm/message.rb', line 100
def encode64
Base64.encode64(serialize).gsub(/\n/, '')
end
|
#has_flag?(flag) ⇒ Boolean
83
84
85
|
# File 'lib/net/ntlm/message.rb', line 83
def has_flag?(flag)
(self[:flag].value & FLAGS[flag]) == FLAGS[flag]
end
|
#head_size ⇒ Object
108
|
# File 'lib/net/ntlm/message.rb', line 108
alias head_size size
|
#parse(str) ⇒ self
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/net/ntlm/message.rb', line 71
def parse(str)
super
while has_disabled_fields? && serialize.size < str.size
self.class.names.find { |name| !self[name].active && enable(name) }
super
end
self
end
|
#security_buffers ⇒ Object
119
120
121
|
# File 'lib/net/ntlm/message.rb', line 119
def security_buffers
@alist.find_all{|n, f| f.instance_of?(SecurityBuffer)}
end
|
#serialize ⇒ Object
95
96
97
98
|
# File 'lib/net/ntlm/message.rb', line 95
def serialize
deflag
super + security_buffers.map{|n, f| f.value + (has_flag?(:UNICODE) ? "\x00".b * (f.value.length % 2) : '')}.join
end
|
#set_flag(flag) ⇒ Object
87
88
89
|
# File 'lib/net/ntlm/message.rb', line 87
def set_flag(flag)
self[:flag].value |= FLAGS[flag]
end
|
#size ⇒ Object
114
115
116
|
# File 'lib/net/ntlm/message.rb', line 114
def size
head_size + data_size
end
|