spid-es 0.0.44 → 0.0.45

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b464cb7b2a9e98c8965aa9fcb263f5f6a4e289a098aba93907a704762e02455d
4
- data.tar.gz: 4ae67e70ad85399fdea17797a8d1035f215aeec23fb655bbd9db0ea618dcb39a
3
+ metadata.gz: 7f385156ce2d9aec7b466ce0a726ad7cacf04d2cf57a5cb9701388e592a6590b
4
+ data.tar.gz: de3b335a2b11095447a997409a04f1514e95355e98ea7605ff5a5c9218982e36
5
5
  SHA512:
6
- metadata.gz: 2a852d4af040700c4a64a2d5c17dc40318609f30857e47b5d346dfb8fa6db305ff6fd1a41d0b7f737c687c5924d6b9fcdac5179b5679f0549577a3572f518453
7
- data.tar.gz: b39a301e8f145bcb593b8f46fa4e20e0c168b6ec3e96444c4c66ae4ac18f6082fbcfbd205d724ebd0c053ed933472fcd3c2428df2e99179f3be39b892963063b
6
+ metadata.gz: 60ed056da9f0df5176ab0ed91f58f6a7471f92b991f5b85068228b03020dfbda3ae88409936f47d66f5dc8b096d8bc77a499d485e46d09692f159d14b4585a03
7
+ data.tar.gz: 68713da76beff56ad90f0f6cb94f1ad79c29769918a873d027bc3a63c6fdc30356753c0f6bee0163cc56690775067c8eaa4ca0c0f949260ce9e0fba748ef7aa2
@@ -21,6 +21,8 @@ module Spid
21
21
 
22
22
  attr_accessor :uuid
23
23
 
24
+ @@cache = {}
25
+
24
26
  def initialize(settings=nil)
25
27
  if settings
26
28
  @settings = settings
@@ -392,7 +394,6 @@ module Spid
392
394
  end
393
395
 
394
396
  meta_doc = get_idp_metadata
395
-
396
397
  return nil unless meta_doc
397
398
  # first try GET (REDIRECT)
398
399
  sso_element = REXML::XPath.first(meta_doc, "/EntityDescriptor/IDPSSODescriptor/#{service}[@Binding='#{HTTP_GET}']")
@@ -449,20 +450,26 @@ module Spid
449
450
  # returns a REXML document of the metadata
450
451
  def get_idp_metadata
451
452
  return false if @settings.idp_metadata.nil?
452
-
453
453
  # Look up the metdata in cache first
454
454
  id = Digest::MD5.hexdigest(@settings.idp_metadata)
455
- response = fetch(@settings.idp_metadata)
456
- #meta_text = response.body
457
- #testo_response = meta_text.sub!(' xmlns:xml="http://www.w3.org/XML/1998/namespace"', '') da errori
458
- #uso nokogiri per cercare il certificato, uso la funzione che rimuove tutti i namespace
459
- doc_noko = Nokogiri::XML(response.body.gsub(/\n/, "").gsub(/\t/, "")) #modifica per poste
460
- doc_noko.remove_namespaces!
455
+ unless @@cache[id].blank?
456
+ Logging.debug "IdP metadata cache used for #{@settings.idp_metadata}"
457
+ doc_noko = @@cache[id]
458
+ else #save in cache
459
+ response = fetch(@settings.idp_metadata)
460
+ #meta_text = response.body
461
+ #testo_response = meta_text.sub!(' xmlns:xml="http://www.w3.org/XML/1998/namespace"', '') da errori
462
+ #uso nokogiri per cercare il certificato, uso la funzione che rimuove tutti i namespace
463
+ doc_noko = Nokogiri::XML(response.body.gsub(/\n/, "").gsub(/\t/, "")) #modifica per poste
464
+ doc_noko.remove_namespaces!
465
+ #save
466
+ @@cache[id] = doc_noko
467
+ end
461
468
  extract_certificate(doc_noko)
462
469
  doc_rexml = REXML::Document.new(doc_noko.to_xml)
463
-
464
470
  return doc_rexml
465
471
 
472
+
466
473
  # USE OF CACHE WITH CERTIFICATE
467
474
  # lookup = @cache.read(id)
468
475
  # if lookup != nil
@@ -2,7 +2,7 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'spid-es'
5
- s.version = '0.0.44'
5
+ s.version = '0.0.45'
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Fabiano Pavan"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spid-es
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.44
4
+ version: 0.0.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabiano Pavan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-11 00:00:00.000000000 Z
11
+ date: 2021-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: canonix