Class: IdrStaff::StaffIdr
- Inherits:
-
SoarIdm::IdmApi
- Object
- SoarIdm::IdmApi
- IdrStaff::StaffIdr
- Defined in:
- lib/idr_staff/staff_idr.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#translator ⇒ Object
readonly
Returns the value of attribute translator.
Instance Method Summary collapse
- #bootstrap(configuration) ⇒ Object
- #bootstrapped? ⇒ Boolean
- #calculate_all_attributes(identity) ⇒ Object
- #calculate_attributes(identity, role) ⇒ Object
- #calculate_identities(entity_identifier) ⇒ Object
- #calculate_roles(identity) ⇒ Object
-
#initialize(configuration) ⇒ StaffIdr
constructor
A new instance of StaffIdr.
- #initialize_providers(configuration) ⇒ Object
Constructor Details
#initialize(configuration) ⇒ StaffIdr
Returns a new instance of StaffIdr.
19 20 21 22 23 |
# File 'lib/idr_staff/staff_idr.rb', line 19 def initialize(configuration) @configuration = configuration bootstrap(configuration) initialize_providers(configuration) if bootstrapped? end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
8 9 10 |
# File 'lib/idr_staff/staff_idr.rb', line 8 def configuration @configuration end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
11 12 13 |
# File 'lib/idr_staff/staff_idr.rb', line 11 def directory @directory end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/idr_staff/staff_idr.rb', line 9 def status @status end |
#translator ⇒ Object (readonly)
Returns the value of attribute translator.
10 11 12 |
# File 'lib/idr_staff/staff_idr.rb', line 10 def translator @translator end |
Instance Method Details
#bootstrap(configuration) ⇒ Object
13 14 15 16 17 |
# File 'lib/idr_staff/staff_idr.rb', line 13 def bootstrap(configuration) validator = IdrStaff::ConfigurationValidator.new @status = validator.validate(configuration) @status end |
#bootstrapped? ⇒ Boolean
33 34 35 |
# File 'lib/idr_staff/staff_idr.rb', line 33 def bootstrapped? @status['status'] == 'success' end |
#calculate_all_attributes(identity) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/idr_staff/staff_idr.rb', line 48 def calculate_all_attributes(identity) attributes = {} roles = calculate_roles(identity) roles.each do |role| attributes.merge!(calculate_attributes(identity, role)) end attributes end |
#calculate_attributes(identity, role) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/idr_staff/staff_idr.rb', line 57 def calculate_attributes(identity, role) entry = @directory.get_entity(identity) return nil if not entry entity = translator.translate(entry) { role => entity['roles'][role] } end |
#calculate_identities(entity_identifier) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/idr_staff/staff_idr.rb', line 64 def calculate_identities(entity_identifier) entry = @directory.get_entity(entity_identifier) return nil if not entry entity = translator.translate(entry) [entity['uuid']] end |
#calculate_roles(identity) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/idr_staff/staff_idr.rb', line 37 def calculate_roles(identity) entry = @directory.get_entity(identity) return nil if not entry entity = translator.translate(entry) roles = [] entity['roles'].each do |role, attributes| roles << role end roles end |
#initialize_providers(configuration) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/idr_staff/staff_idr.rb', line 25 def initialize_providers(configuration) @translator = Object::const_get(@configuration['rule_set']['adaptor']).new provider = @configuration['provider'] @directory = Object::const_get(provider['adaptor']).new(provider) credentials = { 'username' => provider['username'], 'password' => provider['password'] } @directory.authenticate(credentials) end |