Class: Net::SMTP::Authenticator
- Inherits:
-
Object
- Object
- Net::SMTP::Authenticator
- Defined in:
- lib/net/smtp/authenticator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#smtp ⇒ Object
readonly
Returns the value of attribute smtp.
Class Method Summary collapse
- .auth_class(type) ⇒ Object
- .auth_classes ⇒ Object
- .auth_type(type) ⇒ Object
- .check_args(user_arg = nil, secret_arg = nil) ⇒ Object
Instance Method Summary collapse
-
#base64_encode(str) ⇒ String
Base64 encoded string.
-
#continue(arg) ⇒ String
Message from server.
-
#finish(arg) ⇒ Net::SMTP::Response
Response from server.
-
#initialize(smtp) ⇒ Authenticator
constructor
A new instance of Authenticator.
Constructor Details
#initialize(smtp) ⇒ Authenticator
Returns a new instance of Authenticator.
29 30 31 |
# File 'lib/net/smtp/authenticator.rb', line 29 def initialize(smtp) @smtp = smtp end |
Instance Attribute Details
#smtp ⇒ Object (readonly)
Returns the value of attribute smtp.
27 28 29 |
# File 'lib/net/smtp/authenticator.rb', line 27 def smtp @smtp end |
Class Method Details
.auth_class(type) ⇒ Object
13 14 15 16 |
# File 'lib/net/smtp/authenticator.rb', line 13 def self.auth_class(type) type = type.to_s.upcase.tr(?_, ?-).to_sym Authenticator.auth_classes[type] end |
.auth_classes ⇒ Object
4 5 6 |
# File 'lib/net/smtp/authenticator.rb', line 4 def self.auth_classes @classes ||= {} end |
.auth_type(type) ⇒ Object
8 9 10 11 |
# File 'lib/net/smtp/authenticator.rb', line 8 def self.auth_type(type) type = type.to_s.upcase.tr(?_, ?-).to_sym Authenticator.auth_classes[type] = self end |
.check_args(user_arg = nil, secret_arg = nil) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/net/smtp/authenticator.rb', line 18 def self.check_args(user_arg = nil, secret_arg = nil, *, **) unless user_arg raise ArgumentError, 'SMTP-AUTH requested but missing user name' end unless secret_arg raise ArgumentError, 'SMTP-AUTH requested but missing secret phrase' end end |
Instance Method Details
#base64_encode(str) ⇒ String
Returns Base64 encoded string.
51 52 53 54 |
# File 'lib/net/smtp/authenticator.rb', line 51 def base64_encode(str) # expects "str" may not become too long [str].pack('m0') end |
#continue(arg) ⇒ String
Returns message from server.
35 36 37 38 39 |
# File 'lib/net/smtp/authenticator.rb', line 35 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
Returns response from server.
43 44 45 46 47 |
# File 'lib/net/smtp/authenticator.rb', line 43 def finish(arg) res = smtp.get_response arg raise SMTPAuthenticationError.new(res) unless res.success? res end |