Class: Soar::Registry::Staff::Identity
- Inherits:
-
SoarIdm::IdmApi
- Object
- SoarIdm::IdmApi
- Soar::Registry::Staff::Identity
- Defined in:
- lib/soar/registry/staff/identity.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#translator ⇒ Object
readonly
Returns the value of attribute translator.
Instance Method Summary collapse
-
#calculate_all_attributes(identity) ⇒ Hash
Hash of attributes keyed by role.
-
#calculate_attributes(identity, role) ⇒ Hash
A hash of attributes.
-
#calculate_identifiers(identity) ⇒ Array
List of identifiers.
- #calculate_identities(identifier) ⇒ Array
-
#calculate_roles(identity) ⇒ Array
List of roles.
-
#initialize(configuration) ⇒ Identity
constructor
A new instance of Identity.
Constructor Details
#initialize(configuration) ⇒ Identity
Returns a new instance of Identity.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/soar/registry/staff/identity.rb', line 19 def initialize(configuration) @translator = Object.const_get(configuration['rule_set']['adaptor']).new @directory = Object::const_get(configuration['provider']['adaptor']).new @directory.bootstrap(configuration['provider']['config']) @directory.authenticate(configuration['provider']['credentials']) @client = @directory.connect raise Soar::Registry::Staff::Directory::Error::BootstrapError if not @directory.bootstrapped? raise Soar::Registry::Staff::Directory::Error::ConnectionError if not @directory.connected? raise Soar::Registry::Staff::Directory::Error::NotReadyError if not @directory.ready? end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
13 14 15 |
# File 'lib/soar/registry/staff/identity.rb', line 13 def client @client end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
11 12 13 |
# File 'lib/soar/registry/staff/identity.rb', line 11 def directory @directory end |
#translator ⇒ Object (readonly)
Returns the value of attribute translator.
12 13 14 |
# File 'lib/soar/registry/staff/identity.rb', line 12 def translator @translator end |
Instance Method Details
#calculate_all_attributes(identity) ⇒ Hash
Returns Hash of attributes keyed by role.
73 74 75 76 |
# File 'lib/soar/registry/staff/identity.rb', line 73 def calculate_all_attributes(identity) entry = @directory.fetch_identity(identity['identity_id']) @translator.get_identity(entry) end |
#calculate_attributes(identity, role) ⇒ Hash
Returns A hash of attributes.
63 64 65 66 67 68 |
# File 'lib/soar/registry/staff/identity.rb', line 63 def calculate_attributes(identity, role) entry = @directory.fetch_identity(identity['identity_id']) return nil if not entry identity = @translator.get_identity(entry) { role => identity['roles'][role] } end |
#calculate_identifiers(identity) ⇒ Array
Returns list of identifiers.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/soar/registry/staff/identity.rb', line 48 def calculate_identifiers(identity) indexes = @directory.indexed_attributes entry = @directory.fetch_identity(identity['identity_id']) identity = @translator.get_identity(entry) identifiers = [] indexes.each { |index| identifiers << identity[index] } identifiers end |
#calculate_identities(identifier) ⇒ Array
81 82 83 84 85 86 87 88 |
# File 'lib/soar/registry/staff/identity.rb', line 81 def calculate_identities(identifier) if @translator.is_json?(identifier) identifier = @translator.get_identifier(identifier) entries = @directory.search_identities(identifier.keys[0], identifier[identifier.keys[0]] ) return [@translator.get_identity(entries)[0]] end return [@translator.get_identity(@directory.fetch_identity(identifier))] end |
#calculate_roles(identity) ⇒ Array
Returns list of roles.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/soar/registry/staff/identity.rb', line 33 def calculate_roles(identity) entry = @directory.fetch_identity(identity['identity_id']) return nil if not entry identity = @translator.get_identity(entry) roles = [] identity['roles'].each do |role, attributes| roles << role end roles end |