Class: Spid::IdentityProviderManager

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/spid/identity_provider_manager.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_entity(entity_id) ⇒ Object



22
23
24
25
26
# File 'lib/spid/identity_provider_manager.rb', line 22

def self.find_by_entity(entity_id)
  instance.identity_providers.find do |idp|
    idp.entity_id == entity_id
  end
end

.generate_identity_provider_from_file(metadata_filepath) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/spid/identity_provider_manager.rb', line 40

def self.generate_identity_provider_from_file()
  idp_name = File.basename(, "-metadata.xml")
   = File.read()
  parse_from_xml(
    metadata: ,
    name: idp_name
  )
end

.parse_from_xml(name:, metadata:) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/spid/identity_provider_manager.rb', line 28

def self.parse_from_xml(name:, metadata:)
   = ::Spid::Saml2::IdpMetadataParser.new
  idp_settings = .parse_to_hash()
  ::Spid::Saml2::IdentityProvider.new(
    name: name,
    entity_id: idp_settings[:idp_entity_id],
    sso_target_url: idp_settings[:idp_sso_target_url],
    slo_target_url: idp_settings[:idp_slo_target_url],
    certificate: idp_settings[:idp_cert]
  )
end

Instance Method Details

#identity_providersObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/spid/identity_provider_manager.rb', line 9

def identity_providers
  @identity_providers ||=
    begin
      Dir.chdir(Spid.configuration.) do
        Dir.glob("*.xml").map do ||
          self.class.generate_identity_provider_from_file(
            File.expand_path()
          )
        end
      end
    end
end