Class: Net::NNTP::Authinfo

Inherits:
Request
  • Object
show all
Defined in:
lib/net/nntp/request.rb

Overview

RFC 4643

Plain text AUTHINFO Request. Set user and pass with new.

Parameter:

  • keyword

    either ‘user’ or ‘pass’

  • data

    username if keyword is USER, password if keyword is PASS

Usage Example

nntp = Net::NNTP.new
nntp.server = 'localhost'
nntp.connect
request = Authinfo.new('user', 'test')
response = nntp.process(request)
if PasswordRequired === response
  request = Authinfo.new('pass', 'xxx')
  response = nntp.process(request)
  if OKResponse === response
    # authenticated, go ahead
  else
    raise StandardError, response.message
  end
end

Valid Responses: PasswordRequired, AuthenticationAccepted, AuthenticationFailed, AuthenticationOutOfSequence

Instance Method Summary collapse

Methods inherited from Request

#command, #dotstuff, #msgid_or_range, #range, #valid_response?

Constructor Details

#initialize(keyword, data) ⇒ Authinfo

user is the string used in AUTHINFO USER pass is the string used in AUTHINFO PASS

See: user_command, pass_command



135
136
137
# File 'lib/net/nntp/request.rb', line 135

def initialize(keyword, data)
  super 'AUTHINFO', [keyword.upcase, data].join(" ")
end

Instance Method Details

#capabilityObject



144
145
146
# File 'lib/net/nntp/request.rb', line 144

def capability 
  'authinfo'
end