Skip to content

Commit

Permalink
[CS] Whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
bklang committed Dec 2, 2011
1 parent d7974d7 commit 46d056d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 50 deletions.
14 changes: 7 additions & 7 deletions lib/adhearsion/ldap/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class Plugin < Adhearsion::Plugin
# Configure an LDAP connection using ActiveLdap. See ActiveLdap::Base.establish_connect
# for further information about the appropriate settings here.
config :adhearsion_ldap do
host nil , :desc => "LDAP server host"
port 389 , :desc => "LDAP server port"
base "" , :desc => <<-__
host nil, :desc => "LDAP server host"
port 389, :desc => "LDAP server port"
base "", :desc => <<-__
LDAP tree that must be used in the connection
__
bind_dn "" , :desc => <<-__
bind_dn "", :desc => <<-__
Specific domain name that identifies the user
__
password "" , :desc => "Password credentials"
allow_anonymous false, :desc => "valid values: true | false (default)"
try_sasl false, :desc => "valid values: true | false (default)"
password "", :desc => "Password credentials"
allow_anonymous false, :desc => "valid values: true | false (default)"
try_sasl false, :desc => "valid values: true | false (default)"
models "app/ldap_models", :desc => "directory containing ActiveLdap models"
end

Expand Down
85 changes: 42 additions & 43 deletions lib/adhearsion/ldap/plugin/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ module LDAP
class Plugin
class Service

class << self
##
# Start LDAP connection
def start
raise "Must supply a host argument to the LDAP configuration" if (config.host.nil? || config.host.empty?)
raise "Must supply a valid port to the LDAP configuration" unless config.port.is_a? Integer

##
# Start LDAP connection
def start
raise "Must supply a host argument to the LDAP configuration" if (config.host.nil? || config.host.empty?)
raise "Must supply a valid port to the LDAP configuration" unless config.port.is_a? Integer
require_models
establish_connection config.host,
config.port,
config.base,
config.bind_dn,
config.password,
config.allow_anonymous,
config.try_sasl

require_models
establish_connection config.host,
config.port,
config.base,
config.bind_dn,
config.password,
config.allow_anonymous,
config.try_sasl
end
Events.register_callback(:shutdown) { stop }
end

# TODO: It appears that ActiveLdap does not have a connection validation
# or reconnection routine.
#def create_call_hook_for_connection_cleanup
# Events.register_callback([:asterisk, :before_call]) do
# ActiveLdap::Base.verify_active_connections!
# end
#end
# TODO: It appears that ActiveLdap does not have a connection validation
# or reconnection routine.
#def create_call_hook_for_connection_cleanup
# Events.register_callback([:asterisk, :before_call]) do
# ActiveLdap::Base.verify_active_connections!
# end
#end

##
# Release LDAP connection
def stop
ActiveLdap::Base.remove_connection
end
##
# Release LDAP connection
def stop
ActiveLdap::Base.remove_connection
end

private
private

def require_models
path = File.join(Adhearsion.config.platform.root, Adhearsion.config.adhearsion_ldap.models)
Expand All @@ -44,22 +44,21 @@ def require_models
end
end

##
# Open LDAP connection
def establish_connection host, port, base, bind_dn, password, allow_anonymous, try_sasl
ActiveLdap::Base.setup_connection :host => host,
:port => port,
:base => base,
:logger => logger,
:bind_dn => bind_dn,
:password => password,
:allow_anonymous => allow_anonymous,
:try_sasl => try_sasl
end
##
# Open LDAP connection
def establish_connection host, port, base, bind_dn, password, allow_anonymous, try_sasl
ActiveLdap::Base.setup_connection :host => host,
:port => port,
:base => base,
:logger => logger,
:bind_dn => bind_dn,
:password => password,
:allow_anonymous => allow_anonymous,
:try_sasl => try_sasl
end

def config
@config ||= Adhearsion.config[:adhearsion_ldap]
end
def config
@config ||= Adhearsion.config[:adhearsion_ldap]
end
end # Service
end # Plugin
Expand Down

0 comments on commit 46d056d

Please sign in to comment.