Sha256: 305a066c7194e61a24e2bcee815d0907ce4091b9a33b0495d55c17fb5ed911a7

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

module Net
  class SMTP
    class Authenticator
      def self.auth_classes
        @classes ||= {}
      end

      def self.auth_type(type)
        type = type.to_s.upcase.tr(?_, ?-).to_sym
        Authenticator.auth_classes[type] = self
      end

      def self.auth_class(type)
        type = type.to_s.upcase.tr(?_, ?-).to_sym
        Authenticator.auth_classes[type]
      end

      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

      attr_reader :smtp

      def initialize(smtp)
        @smtp = smtp
      end

      # @param arg [String] message to server
      # @return [String] message from server
      def continue(arg)
        res = smtp.get_response arg
        raise res.exception_class.new(res) unless res.continue?
        res.string.split[1]
      end

      # @param arg [String] message to server
      # @return [Net::SMTP::Response] response from server
      def finish(arg)
        res = smtp.get_response arg
        raise SMTPAuthenticationError.new(res) unless res.success?
        res
      end

      # @param str [String]
      # @return [String] Base64 encoded string
      def base64_encode(str)
        # expects "str" may not become too long
        [str].pack('m0')
      end
    end
  end
end

Version data entries

9 entries across 8 versions & 6 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/net-smtp-0.5.0/lib/net/smtp/authenticator.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.0/lib/net/smtp/authenticator.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/net-smtp-0.5.0/lib/net/smtp/authenticator.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/net-smtp-0.5.0/lib/net/smtp/authenticator.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.0/lib/net/smtp/authenticator.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.0/lib/net/smtp/authenticator.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.0/lib/net/smtp/authenticator.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.0/lib/net/smtp/authenticator.rb
net-smtp-0.5.0 lib/net/smtp/authenticator.rb