Class: Win32::SSPI::SecurityBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/win32/sspi.rb

Overview

Creates binary representaiton of a SecBufferDesc structure, including the SecBuffer contained inside.

Constant Summary collapse

SECBUFFER_TOKEN =

Security token

2
TOKENBUFSIZE =
12288
SECBUFFER_VERSION =
0

Instance Method Summary collapse

Constructor Details

#initialize(buffer = nil) ⇒ SecurityBuffer

Returns a new instance of SecurityBuffer.



85
86
87
88
89
# File 'lib/win32/sspi.rb', line 85

def initialize(buffer = nil)
	@buffer = buffer || "\0" * TOKENBUFSIZE
	@bufferSize = @buffer.length
	@type = SECBUFFER_TOKEN
end

Instance Method Details

#bufferSizeObject



91
92
93
94
# File 'lib/win32/sspi.rb', line 91

def bufferSize
	unpack
	@bufferSize
end

#bufferTypeObject



96
97
98
99
# File 'lib/win32/sspi.rb', line 96

def bufferType
	unpack
	@type
end

#to_pObject



106
107
108
109
110
111
112
113
114
115
# File 'lib/win32/sspi.rb', line 106

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

#tokenObject



101
102
103
104
# File 'lib/win32/sspi.rb', line 101

def token
	unpack
	@buffer
end