Class: SoarLdap::LdapProvider
- Inherits:
-
SoarIdm::DirectoryProvider
- Object
- SoarIdm::DirectoryProvider
- SoarLdap::LdapProvider
- Defined in:
- lib/soar_ldap.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #authenticate(credentials) ⇒ Object
- #bootstrap(configuration) ⇒ Object
- #bootstrapped? ⇒ Boolean
- #connect ⇒ Object
- #connected? ⇒ Boolean
- #get_entity(identifier) ⇒ Object
-
#initialize(configuration) ⇒ LdapProvider
constructor
A new instance of LdapProvider.
- #ready? ⇒ Boolean
- #uri ⇒ Object
Constructor Details
#initialize(configuration) ⇒ LdapProvider
Returns a new instance of LdapProvider.
23 24 25 |
# File 'lib/soar_ldap.rb', line 23 def initialize(configuration) bootstrap(configuration) end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
21 22 23 |
# File 'lib/soar_ldap.rb', line 21 def cache @cache end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
13 14 15 |
# File 'lib/soar_ldap.rb', line 13 def configuration @configuration end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
20 21 22 |
# File 'lib/soar_ldap.rb', line 20 def connection @connection end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
17 18 19 |
# File 'lib/soar_ldap.rb', line 17 def credentials @credentials end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
19 20 21 |
# File 'lib/soar_ldap.rb', line 19 def password @password end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/soar_ldap.rb', line 14 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
16 17 18 |
# File 'lib/soar_ldap.rb', line 16 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
15 16 17 |
# File 'lib/soar_ldap.rb', line 15 def server @server end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
18 19 20 |
# File 'lib/soar_ldap.rb', line 18 def username @username end |
Instance Method Details
#authenticate(credentials) ⇒ Object
38 39 40 41 42 |
# File 'lib/soar_ldap.rb', line 38 def authenticate(credentials) @credentials = nil validate_credentials(credentials) remember_credentials(credentials) end |
#bootstrap(configuration) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/soar_ldap.rb', line 27 def bootstrap(configuration) @configuration = nil validate_configuration(configuration) remember_configuration(configuration) initialize_cache(configuration) end |
#bootstrapped? ⇒ Boolean
34 35 36 |
# File 'lib/soar_ldap.rb', line 34 def bootstrapped? not @configuration.nil? end |
#connect ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/soar_ldap.rb', line 44 def connect @connection = ::LDAP::Conn.new(@server, @port) @connection.set_option(::LDAP::LDAP_OPT_PROTOCOL_VERSION, 3) @connection.bind(@username, @password) @connection rescue => ex raise SoarLdapError.new("Connection error + #{ex}") end |
#connected? ⇒ Boolean
54 55 56 |
# File 'lib/soar_ldap.rb', line 54 def connected? not @connection.nil? end |
#get_entity(identifier) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/soar_ldap.rb', line 67 def get_entity(identifier) connect if not connected? cached = retrieve_from_cache(@connection, identifier) return cached if cached result = find_entity(@connection, identifier) cache_result(@connection, identifier, result) result rescue => ex raise SoarLdapError.new("Lookup error, #{ex}") end |
#ready? ⇒ Boolean
58 59 60 |
# File 'lib/soar_ldap.rb', line 58 def ready? bootstrapped? and connected? end |
#uri ⇒ Object
62 63 64 65 |
# File 'lib/soar_ldap.rb', line 62 def uri raise SoarLdapError.new('Not bootstrapped') if not bootstrapped? "ldap://#{server}:#{port}/#{@path}" end |