Class: Soar::Registry::Identity::Provider::Staff::Uuid

Inherits:
SoarIdm::IdmApi
  • Object
show all
Defined in:
lib/soar/registry/identity/provider/staff/uuid.rb

Overview

Work in progress. Do not use.

Instance Method Summary collapse

Constructor Details

#initialize(directories:, fetch_index: "entryuuid") ⇒ Uuid

Returns a new instance of Uuid.

Parameters:

  • directories (Hash)

Options Hash (directories:):

  • :identity (Object)
  • :role (Object)

Raises:



19
20
21
22
23
# File 'lib/soar/registry/identity/provider/staff/uuid.rb', line 19

def initialize(directories:, fetch_index: "entryuuid")
  raise Soar::Registry::Identity::Error::MissingRequiredDirectoryError, ':identity key is required' if not directories.key?(:identity)
  @identity_directory = directories[:identity]
  @roles_directory = directories.key?(:roles) ? directories[:roles] : directories[:identity]
end

Instance Method Details

#calculate_all_attributes(identity) ⇒ Hash

Returns Hash of attributes keyed by role.

Parameters:

  • identity (Hash)

Returns:

  • (Hash)

    Hash of attributes keyed by role



64
65
66
# File 'lib/soar/registry/identity/provider/staff/uuid.rb', line 64

def calculate_all_attributes(identity)
  @directory.fetch(identity[@roles_directory.index[0]])
end

#calculate_attributes(identity, role) ⇒ Hash

Returns A hash of attributes.

Parameters:

  • identity (Hash)
  • role (String)

Returns:

  • (Hash)

    A hash of attributes



55
56
57
58
59
# File 'lib/soar/registry/identity/provider/staff/uuid.rb', line 55

def calculate_attributes(identity, role)
  entry = @roles_directory.fetch(identity[@roles_directory.index[0]])
  return nil if not entry
  { role => entry['roles'][role] }
end

#calculate_identifiers(identity) ⇒ Array

Returns list of identifiers.

Parameters:

  • identity (Hash)

Returns:

  • (Array)

    list of identifiers



42
43
44
45
46
47
48
49
# File 'lib/soar/registry/identity/provider/staff/uuid.rb', line 42

def calculate_identifiers(identity)
  indexes = @identity_directory.index
  identifiers = []
  indexes.each { |index| 
    identifiers << identity[index]
  }
  identifiers
end

#calculate_identities(identifier) ⇒ Hash

Returns an identity.

Parameters:

  • identifier, (String)

    a primary key that uniquely identifies an identity

Returns:

  • (Hash)

    an identity



72
73
74
# File 'lib/soar/registry/identity/provider/staff/uuid.rb', line 72

def calculate_identities(identifier)
  return [@identity_directory.fetch(identifier)]
end

#calculate_roles(identity) ⇒ Array

Returns list of roles.

Parameters:

  • identity (Hash)

Returns:

  • (Array)

    list of roles



28
29
30
31
32
33
34
35
36
# File 'lib/soar/registry/identity/provider/staff/uuid.rb', line 28

def calculate_roles(identity)
  entry = @roles_directory.fetch(identity[@roles_directory.index[0]])
  return nil if not entry
  roles = []
  entry['roles'].each do |role, attributes|
    roles << role
  end
  roles
end