Class: RubySMB::Server::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_smb/server/session.rb

Overview

The object representing a single anonymous, guest or authenticated session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, key: nil, state: :in_progress, user_id: nil) ⇒ Session

Returns a new instance of Session.

Parameters:

  • id (Integer)

    This session's unique identifier.

  • key (String) (defaults to: nil)

    This session's key.

  • state (Symbol) (defaults to: :in_progress)

    The state that this session is in.

  • user_id (defaults to: nil)

    The identity of the user associated with this session.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ruby_smb/server/session.rb', line 10

def initialize(id, key: nil, state: :in_progress, user_id: nil)
  @id = id
  @key = key
  @user_id = user_id
  @state = state
  @signing_required = false
  @metadata = {}
  # tree id => provider processor instance
  @tree_connect_table = {}
  @creation_time = Time.now
end

Instance Attribute Details

#creation_timeObject (readonly)

The time at which this session was created.



74
75
76
# File 'lib/ruby_smb/server/session.rb', line 74

def creation_time
  @creation_time
end

#idInteger

Returns:

  • (Integer)


40
41
42
# File 'lib/ruby_smb/server/session.rb', line 40

def id
  @id
end

#is_guestObject

Whether or not the authenticated user is a guest.



78
79
80
# File 'lib/ruby_smb/server/session.rb', line 78

def is_guest
  @is_guest
end

#keyString

Returns:

  • (String)


45
46
47
# File 'lib/ruby_smb/server/session.rb', line 45

def key
  @key
end

#metadataHash

Returns:

  • (Hash)


69
70
71
# File 'lib/ruby_smb/server/session.rb', line 69

def 
  @metadata
end

#signing_requiredBoolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/ruby_smb/server/session.rb', line 59

def signing_required
  @signing_required
end

#stateSymbol

Returns:

  • (Symbol)


54
55
56
# File 'lib/ruby_smb/server/session.rb', line 54

def state
  @state
end

#tree_connect_tableHash

Returns:

  • (Hash)


64
65
66
# File 'lib/ruby_smb/server/session.rb', line 64

def tree_connect_table
  @tree_connect_table
end

#user_idObject

The identity of the authenticated user.



49
50
51
# File 'lib/ruby_smb/server/session.rb', line 49

def user_id
  @user_id
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/ruby_smb/server/session.rb', line 22

def inspect
  "#<Session id: #{@id.inspect}, user_id: #{@user_id.inspect}, state: #{@state.inspect}>"
end

#is_anonymousBoolean

Whether or not this session is anonymous.

Returns:

  • (Boolean)


28
29
30
# File 'lib/ruby_smb/server/session.rb', line 28

def is_anonymous
  @user_id == Gss::Provider::IDENTITY_ANONYMOUS
end

#logoff!Object



32
33
34
35
# File 'lib/ruby_smb/server/session.rb', line 32

def logoff!
  @tree_connect_table.values.each { |share_processor| share_processor.disconnect! }
  @tree_connect_table.clear
end