Class: Another::Ldap::Proxy::Server
- Inherits:
-
Object
- Object
- Another::Ldap::Proxy::Server
- Defined in:
- lib/another/ldap/proxy/server.rb
Constant Summary collapse
- SERVER_OPTIONS =
%i[port nodelay listen].freeze
Instance Attribute Summary collapse
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(conf:, logger: nil) ⇒ Server
constructor
A new instance of Server.
- #logger ⇒ Object
- #logger_params ⇒ Object
- #operation_class ⇒ Object
- #operation_class_params ⇒ Object
- #run ⇒ Object
- #server_params ⇒ Object
Constructor Details
#initialize(conf:, logger: nil) ⇒ Server
Returns a new instance of Server.
14 15 16 17 |
# File 'lib/another/ldap/proxy/server.rb', line 14 def initialize(conf:, logger: nil) @conf = conf @logger = logger end |
Instance Attribute Details
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
12 13 14 |
# File 'lib/another/ldap/proxy/server.rb', line 12 def conf @conf end |
Class Method Details
.run(conf:) ⇒ Object
68 69 70 |
# File 'lib/another/ldap/proxy/server.rb', line 68 def self.run(conf:) new(conf: conf).run end |
Instance Method Details
#logger ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/another/ldap/proxy/server.rb', line 59 def logger return @logger if @logger $stdout.sync = true @logger ||= Logger.new($stdout) @logger.level = conf.debug ? Logger::DEBUG : Logger::INFO @logger end |
#logger_params ⇒ Object
46 47 48 |
# File 'lib/another/ldap/proxy/server.rb', line 46 def logger_params { logger: logger } end |
#operation_class ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/another/ldap/proxy/server.rb', line 25 def operation_class backend_mode = conf[:backend_mode] backends_conf = conf[:backends] root_username = conf[:root_username] root_password = conf[:root_password] logger = self.logger Another::Ldap::Proxy::Operation.new_operation do set_logger(logger) set_root_credentials(root_username, root_password) set_backend_mode(backend_mode) backends_conf.each do |backend_conf| add_backend(Another::Ldap::Proxy::Backend.new_backend(backend_conf, logger: logger)) end end end |
#operation_class_params ⇒ Object
42 43 44 |
# File 'lib/another/ldap/proxy/server.rb', line 42 def operation_class_params { operation_class: operation_class } end |
#run ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/another/ldap/proxy/server.rb', line 50 def run @s ||= LDAP::Server.new( **server_params ) @s.run_tcpserver @s.join end |
#server_params ⇒ Object
19 20 21 22 23 |
# File 'lib/another/ldap/proxy/server.rb', line 19 def server_params conf.slice(*SERVER_OPTIONS) .update(operation_class_params) .update(logger_params) end |