123456789_123456789_123456789_123456789_123456789_

Class: Net::SMTP::Authenticator

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: lib/net/smtp/authenticator.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(smtp) ⇒ Authenticator

[ GitHub ]

  
# File 'lib/net/smtp/authenticator.rb', line 18

def initialize(smtp)
  @smtp = smtp
end

Class Method Details

.auth_class(type)

[ GitHub ]

  
# File 'lib/net/smtp/authenticator.rb', line 12

def self.auth_class(type)
  Authenticator.auth_classes[type.intern]
end

.auth_classes

[ GitHub ]

  
# File 'lib/net/smtp/authenticator.rb', line 4

def self.auth_classes
  @classes ||= {}
end

.auth_type(type)

[ GitHub ]

  
# File 'lib/net/smtp/authenticator.rb', line 8

def self.auth_type(type)
  Authenticator.auth_classes[type] = self
end

Instance Attribute Details

#smtp (readonly)

[ GitHub ]

  
# File 'lib/net/smtp/authenticator.rb', line 16

attr_reader :smtp

Instance Method Details

#base64_encode(str) ⇒ String

Parameters:

  • str (String)

Returns:

  • (String)

    Base64 encoded string

[ GitHub ]

  
# File 'lib/net/smtp/authenticator.rb', line 40

def base64_encode(str)
  # expects "str" may not become too long
  [str].pack('m0')
end

#continue(arg) ⇒ String

Parameters:

  • arg (String)

    message to server

Returns:

  • (String)

    message from server

Raises:

  • (res.exception_class)
[ GitHub ]

  
# File 'lib/net/smtp/authenticator.rb', line 24

def continue(arg)
  res = smtp.get_response arg
  raise res.exception_class.new(res) unless res.continue?
  res.string.split[1]
end

#finish(arg) ⇒ Net::SMTP::Response

Parameters:

  • arg (String)

    message to server

Returns:

Raises:

[ GitHub ]

  
# File 'lib/net/smtp/authenticator.rb', line 32

def finish(arg)
  res = smtp.get_response arg
  raise SMTPAuthenticationError.new(res) unless res.success?
  res
end