class RIMS::Protocol::InitialDecoder

Public Class Methods

new(drb_services, auth, logger, mail_delivery_user: Service::DEFAULT_CONFIG.mail_delivery_user, line_length_limit: Service::DEFAULT_CONFIG.protocol_line_length_limit, literal_size_limit: Service::DEFAULT_CONFIG.protocol_literal_size_limit, command_size_limit: Service::DEFAULT_CONFIG.protocol_command_size_limit) click to toggle source
Calls superclass method RIMS::Protocol::Decoder::new
# File lib/rims/protocol/decoder.rb, line 358
def initialize(drb_services, auth, logger,
               mail_delivery_user: Service::DEFAULT_CONFIG.mail_delivery_user,
               line_length_limit: Service::DEFAULT_CONFIG.protocol_line_length_limit,
               literal_size_limit: Service::DEFAULT_CONFIG.protocol_literal_size_limit,
               command_size_limit: Service::DEFAULT_CONFIG.protocol_command_size_limit)
  super(auth, logger)
  @drb_services = drb_services
  @mail_delivery_user = mail_delivery_user
  @line_length_limit = line_length_limit
  @literal_size_limit = literal_size_limit
  @command_size_limit = command_size_limit
  @logger.debug("RIMS::Protocol::InitialDecoder#initialize at #{self}") if @logger.debug?
end

Private Class Methods

imap_command(name) click to toggle source
# File lib/rims/protocol/decoder.rb, line 335
def imap_command(name)
  name = name.to_sym

  cmd = to_imap_command(name)
  Decoder::IMAP_CMDs[cmd] = name

  method = instance_method(name)
  if (kw_params(method).include? :uid) then
    Decoder::IMAP_CMDs['UID'] = :uid
    Decoder::UID_CMDs[cmd] = name
  end

  orig_name = "_#{name}".to_sym
  alias_method orig_name, name
  define_method name, lambda{|tag, *args, **kw_args, &block|
    guard_error(orig_name, tag, *args, **kw_args, &block)
  }

  name
end

Public Instance Methods

append(tag, mbox_name, *opt_args, msg_text, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 505
def append(tag, mbox_name, *opt_args, msg_text, &block)
  make_not_authenticated_response(tag, &block)
end
auth?() click to toggle source
# File lib/rims/protocol/decoder.rb, line 379
def auth?
  false
end
authenticate(tag, client_response_input_gets, server_challenge_output_write, auth_type, inline_client_response_data_base64=nil) { |untagged_response| ... } click to toggle source
# File lib/rims/protocol/decoder.rb, line 420
def authenticate(tag, client_response_input_gets, server_challenge_output_write,
                 auth_type, inline_client_response_data_base64=nil)
  auth_reader = AuthenticationReader.new(@auth, client_response_input_gets, server_challenge_output_write, @logger)
  if (username = auth_reader.authenticate_client(auth_type, inline_client_response_data_base64)) then
    if (username != :*) then
      @logger.info("authentication OK: #{username}")
      @next_decoder = accept_authentication(username) {|untagged_response|
        yield(untagged_response)
        yield(:flush)
      }
      yield("#{tag} OK AUTHENTICATE #{auth_type} success\r\n")
    else
      @logger.info('bad authentication.')
      yield("#{tag} BAD AUTHENTICATE failed\r\n")
    end
  else
    yield("#{tag} NO authentication failed\r\n")
  end
end
check(tag, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 510
def check(tag, &block)
  make_not_authenticated_response(tag, &block)
end
cleanup() click to toggle source
# File lib/rims/protocol/decoder.rb, line 387
def cleanup
  @logger.debug("RIMS::Protocol::InitialDecoder#cleanup at #{self}") if @logger.debug?
  nil
end
close(tag, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 515
def close(tag, &block)
  make_not_authenticated_response(tag, &block)
end
copy(tag, msg_set, mbox_name, uid: false, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 540
def copy(tag, msg_set, mbox_name, uid: false, &block)
  make_not_authenticated_response(tag, &block)
end
create(tag, mbox_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 465
def create(tag, mbox_name, &block)
  make_not_authenticated_response(tag, &block)
end
delete(tag, mbox_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 470
def delete(tag, mbox_name, &block)
  make_not_authenticated_response(tag, &block)
end
examine(tag, mbox_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 460
def examine(tag, mbox_name, &block)
  make_not_authenticated_response(tag, &block)
end
expunge(tag, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 520
def expunge(tag, &block)
  make_not_authenticated_response(tag, &block)
end
fetch(tag, msg_set, data_item_group, uid: false, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 530
def fetch(tag, msg_set, data_item_group, uid: false, &block)
  make_not_authenticated_response(tag, &block)
end
idle(tag, client_input_gets, server_output_write, connection_timer, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 545
def idle(tag, client_input_gets, server_output_write, connection_timer, &block)
  make_not_authenticated_response(tag, &block)
end
list(tag, ref_name, mbox_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 490
def list(tag, ref_name, mbox_name, &block)
  make_not_authenticated_response(tag, &block)
end
login(tag, username, password) { |untagged_response| ... } click to toggle source
# File lib/rims/protocol/decoder.rb, line 441
def login(tag, username, password)
  if (@auth.authenticate_login(username, password)) then
    @logger.info("login authentication OK: #{username}")
    @next_decoder = accept_authentication(username) {|untagged_response|
      yield(untagged_response)
      yield(:flush)
    }
    yield("#{tag} OK LOGIN completed\r\n")
  else
    yield("#{tag} NO failed to login\r\n")
  end
end
logout(tag, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 402
def logout(tag, &block)
  @next_decoder = LogoutDecoder.new(self, @logger)
  make_logout_response(tag, &block)
end
lsub(tag, ref_name, mbox_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 495
def lsub(tag, ref_name, mbox_name, &block)
  make_not_authenticated_response(tag, &block)
end
make_requrest_reader(input, output) click to toggle source
# File lib/rims/protocol/decoder.rb, line 372
def make_requrest_reader(input, output)
  RequestReader.new(input, output, @logger,
                    line_length_limit: @line_length_limit,
                    literal_size_limit: @literal_size_limit,
                    command_size_limit: @command_size_limit)
end
noop(tag) { |"#{tag} OK NOOP completed\r\n"| ... } click to toggle source
# File lib/rims/protocol/decoder.rb, line 397
def noop(tag)
  yield("#{tag} OK NOOP completed\r\n")
end
rename(tag, src_name, dst_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 475
def rename(tag, src_name, dst_name, &block)
  make_not_authenticated_response(tag, &block)
end
select(tag, mbox_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 455
def select(tag, mbox_name, &block)
  make_not_authenticated_response(tag, &block)
end
selected?() click to toggle source
# File lib/rims/protocol/decoder.rb, line 383
def selected?
  false
end
status(tag, mbox_name, data_item_group, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 500
def status(tag, mbox_name, data_item_group, &block)
  make_not_authenticated_response(tag, &block)
end
store(tag, msg_set, data_item_name, data_item_value, uid: false, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 535
def store(tag, msg_set, data_item_name, data_item_value, uid: false, &block)
  make_not_authenticated_response(tag, &block)
end
subscribe(tag, mbox_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 480
def subscribe(tag, mbox_name, &block)
  make_not_authenticated_response(tag, &block)
end
unsubscribe(tag, mbox_name, &block) click to toggle source
# File lib/rims/protocol/decoder.rb, line 485
def unsubscribe(tag, mbox_name, &block)
  make_not_authenticated_response(tag, &block)
end

Private Instance Methods

accept_authentication(username) { |untagged_response| ... } click to toggle source
# File lib/rims/protocol/decoder.rb, line 408
def accept_authentication(username)
  case (username)
  when @mail_delivery_user
    @logger.info("mail delivery user: #{username}")
    MailDeliveryDecoder.new(self, @drb_services, @auth, @logger)
  else
    engine = self.class.make_engine_and_recovery_if_needed(@drb_services, username, logger: @logger) {|untagged_response| yield(untagged_response) }
    UserMailboxDecoder.new(self, engine, @auth, @logger)
  end
end
make_not_authenticated_response(tag) { |"#{tag} NO not authenticated\r\n"| ... } click to toggle source
# File lib/rims/protocol/decoder.rb, line 392
def make_not_authenticated_response(tag)
  yield("#{tag} NO not authenticated\r\n")
end