Class: Win32::SSPI::SecurityBuffer
Relationships & Source Files | |
Inherits: | Object |
Defined in: | ext/win32/lib/win32/sspi.rb |
Overview
Creates binary representaiton of a SecBufferDesc structure, including the SecBuffer contained inside.
Constant Summary
-
SECBUFFER_TOKEN =
Security token
2
-
SECBUFFER_VERSION =
# File 'ext/win32/lib/win32/sspi.rb', line 820
-
TOKENBUFSIZE =
# File 'ext/win32/lib/win32/sspi.rb', line 8112288
Class Method Summary
- .new(buffer = nil) ⇒ SecurityBuffer constructor
Instance Method Summary
- #bufferSize
- #bufferType
- #to_p
- #token
-
#unpack
private
Unpacks the SecurityBufferDesc structure into member variables.
Constructor Details
.new(buffer = nil) ⇒ SecurityBuffer
# File 'ext/win32/lib/win32/sspi.rb', line 84
def initialize(buffer = nil) @buffer = buffer || "\0" * TOKENBUFSIZE @bufferSize = @buffer.length @type = SECBUFFER_TOKEN end
Instance Method Details
#bufferSize
[ GitHub ]# File 'ext/win32/lib/win32/sspi.rb', line 90
def bufferSize unpack @bufferSize end
#bufferType
[ GitHub ]# File 'ext/win32/lib/win32/sspi.rb', line 95
def bufferType unpack @type end
#to_p
[ GitHub ]# File 'ext/win32/lib/win32/sspi.rb', line 105
def to_p # Assumption is that when to_p is called we are going to get a packed structure. Therefore, # set @unpacked back to nil so we know to unpack when accessors are next accessed. @unpacked = nil # Assignment of inner structure to variable is very important here. Without it, # will not be able to unpack changes to the structure. Alternative, nested unpacks, # does not work (i.e. @struct.unpack("LLP12")[2].unpack("LLP12") results in "no associated pointer") @sec_buffer ||= [@bufferSize, @type, @buffer].pack("LLP") @struct ||= [SECBUFFER_VERSION, 1, @sec_buffer].pack("LLP") end
#token
[ GitHub ]# File 'ext/win32/lib/win32/sspi.rb', line 100
def token unpack @buffer end
#unpack (private)
Unpacks the SecurityBufferDesc structure into member variables. We only want to do this once per struct, so the struct is deleted after unpacking.
# File 'ext/win32/lib/win32/sspi.rb', line 121
def unpack if ! @unpacked && @sec_buffer && @struct @bufferSize, @type = @sec_buffer.unpack("LL") @buffer = @sec_buffer.unpack("LLP#{@bufferSize}")[2] @struct = nil @sec_buffer = nil @unpacked = true end end