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.
22 23 24 |
# File 'lib/soar_ldap.rb', line 22 def initialize(configuration) bootstrap(configuration) end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
20 21 22 |
# File 'lib/soar_ldap.rb', line 20 def cache @cache end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
12 13 14 |
# File 'lib/soar_ldap.rb', line 12 def configuration @configuration end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
19 20 21 |
# File 'lib/soar_ldap.rb', line 19 def connection @connection end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
16 17 18 |
# File 'lib/soar_ldap.rb', line 16 def credentials @credentials end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
18 19 20 |
# File 'lib/soar_ldap.rb', line 18 def password @password end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/soar_ldap.rb', line 13 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
15 16 17 |
# File 'lib/soar_ldap.rb', line 15 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
14 15 16 |
# File 'lib/soar_ldap.rb', line 14 def server @server end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
17 18 19 |
# File 'lib/soar_ldap.rb', line 17 def username @username end |
Instance Method Details
#authenticate(credentials) ⇒ Object
37 38 39 40 41 |
# File 'lib/soar_ldap.rb', line 37 def authenticate(credentials) @credentials = nil validate_credentials(credentials) remember_credentials(credentials) end |
#bootstrap(configuration) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/soar_ldap.rb', line 26 def bootstrap(configuration) @configuration = nil validate_configuration(configuration) remember_configuration(configuration) initialize_cache(configuration) end |
#bootstrapped? ⇒ Boolean
33 34 35 |
# File 'lib/soar_ldap.rb', line 33 def bootstrapped? not @configuration.nil? end |
#connect ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/soar_ldap.rb', line 43 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
53 54 55 |
# File 'lib/soar_ldap.rb', line 53 def connected? not @connection.nil? end |
#get_entity(identifier) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/soar_ldap.rb', line 66 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
57 58 59 |
# File 'lib/soar_ldap.rb', line 57 def ready? bootstrapped? and connected? end |
#uri ⇒ Object
61 62 63 64 |
# File 'lib/soar_ldap.rb', line 61 def uri raise SoarLdapError.new('Not bootstrapped') if not bootstrapped? "ldap://#{server}:#{port}/#{@path}" end |