Class: Net::NTLM::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ntlm/client.rb

Defined Under Namespace

Classes: Session

Constant Summary collapse

DEFAULT_FLAGS =
NTLM::FLAGS[:UNICODE] | NTLM::FLAGS[:OEM] |
NTLM::FLAGS[:SIGN]   | NTLM::FLAGS[:SEAL]         | NTLM::FLAGS[:REQUEST_TARGET] |
NTLM::FLAGS[:NTLM]   | NTLM::FLAGS[:ALWAYS_SIGN]  | NTLM::FLAGS[:NTLM2_KEY] |
NTLM::FLAGS[:KEY128] | NTLM::FLAGS[:KEY_EXCHANGE] | NTLM::FLAGS[:KEY56]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, opts = {}) ⇒ Client

Note:

All string parameters should be encoded in UTF-8. The proper final encoding for placing in the various messages will be chosen based on negotiation with the server.

Returns a new instance of Client.

Parameters:

  • username (String)
  • password (String)
  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :domain (String)

    where we’re authenticating to

  • :workstation (String)

    local workstation name

  • :flags (Fixnum) — default: DEFAULT_FLAGS

    see Net::NTLM::Message::Type1.flag



21
22
23
24
25
26
27
# File 'lib/net/ntlm/client.rb', line 21

def initialize(username, password, opts = {})
  @username     = username
  @password     = password
  @domain       = opts[:domain] || nil
  @workstation  = opts[:workstation] || nil
  @flags        = opts[:flags] || DEFAULT_FLAGS
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



10
11
12
# File 'lib/net/ntlm/client.rb', line 10

def domain
  @domain
end

#flagsObject (readonly)

Returns the value of attribute flags.



10
11
12
# File 'lib/net/ntlm/client.rb', line 10

def flags
  @flags
end

#passwordObject (readonly)

Returns the value of attribute password.



10
11
12
# File 'lib/net/ntlm/client.rb', line 10

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



10
11
12
# File 'lib/net/ntlm/client.rb', line 10

def username
  @username
end

#workstationObject (readonly)

Returns the value of attribute workstation.



10
11
12
# File 'lib/net/ntlm/client.rb', line 10

def workstation
  @workstation
end

Instance Method Details

#init_context(resp = nil, channel_binding = nil) ⇒ NTLM::Message

Returns:



30
31
32
33
34
35
36
37
38
# File 'lib/net/ntlm/client.rb', line 30

def init_context(resp = nil, channel_binding = nil)
  if resp.nil?
    @session = nil
    type1_message
  else
    @session = Client::Session.new(self, Net::NTLM::Message.decode64(resp), channel_binding)
    @session.authenticate!
  end
end

#sessionClient::Session

Returns:



41
42
43
# File 'lib/net/ntlm/client.rb', line 41

def session
  @session
end

#session_keyObject



45
46
47
# File 'lib/net/ntlm/client.rb', line 45

def session_key
  @session.exported_session_key
end