Sha256: 7b5f715ef047e14b33a1ec1c0f85cd7f05dccd17637d242892adaeabf89763ca

Contents?: true

Size: 1.97 KB

Versions: 40

Compression:

Stored size: 1.97 KB

Contents

module Net
  module NTLM
    class Client

      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]

      attr_reader :username, :password, :domain, :workstation, :flags

      # @note All string parameters should be encoded in UTF-8. The proper
      #   final encoding for placing in the various {Message messages} will be
      #   chosen based on negotiation with the server.
      #
      # @param username [String]
      # @param password [String]
      # @option opts [String] :domain where we're authenticating to
      # @option opts [String] :workstation local workstation name
      # @option opts [Fixnum] :flags (DEFAULT_FLAGS) see Net::NTLM::Message::Type1.flag
      def initialize(username, password, opts = {})
        @username     = username
        @password     = password
        @domain       = opts[:domain] || nil
        @workstation  = opts[:workstation] || nil
        @flags        = opts[:flags] || DEFAULT_FLAGS
      end

      # @return [NTLM::Message]
      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

      # @return [Client::Session]
      def session
        @session
      end

      def session_key
        @session.exported_session_key
      end

      private

      # @return [Message::Type1]
      def type1_message
        type1 = Message::Type1.new
        type1[:flag].value = flags
        type1.domain = domain if domain
        type1.workstation = workstation if workstation

        type1
      end

    end
  end
end

require "net/ntlm/client/session"

Version data entries

40 entries across 32 versions & 3 rubygems

Version Path
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb
rubyntlm-0.6.2 lib/net/ntlm/client.rb