ruby-saml-mod 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -52,7 +52,15 @@ module Onelogin::Saml
52
52
 
53
53
  # The PEM-encoded private key
54
54
  attr_accessor :xmlsec_privatekey
55
-
55
+
56
+ # Additional private keys to attempt decryption with
57
+ # To be used for key rotation
58
+ attr_accessor :xmlsec_additional_privatekeys
59
+
60
+ def all_private_keys
61
+ Array(xmlsec_additional_privatekeys).unshift(xmlsec_privatekey).compact
62
+ end
63
+
56
64
  def encryption_configured?
57
65
  !!self.xmlsec_privatekey
58
66
  end
data/lib/xml_sec.rb CHANGED
@@ -355,6 +355,14 @@ module XMLSecurity
355
355
  end
356
356
 
357
357
  def decrypt_node(settings, xmlstr)
358
+ settings.all_private_keys.each do |key|
359
+ result = xmlsec_decrypt(xmlstr, key)
360
+ return result if result
361
+ end
362
+ nil
363
+ end
364
+
365
+ def xmlsec_decrypt(xmlstr, private_key)
358
366
  kmgr = nil
359
367
  ctx = nil
360
368
  doc = nil
@@ -363,7 +371,7 @@ module XMLSecurity
363
371
  kmgr = XMLSecurity.xmlSecKeysMngrCreate
364
372
  raise "Failed initializing key mgr" if XMLSecurity.xmlSecOpenSSLAppDefaultKeysMngrInit(kmgr) < 0
365
373
 
366
- key = XMLSecurity.xmlSecOpenSSLAppKeyLoad(settings.xmlsec_privatekey, :xmlSecKeyDataFormatPem, nil, nil, nil)
374
+ key = XMLSecurity.xmlSecOpenSSLAppKeyLoad(private_key, :xmlSecKeyDataFormatPem, nil, nil, nil)
367
375
  raise "Failed loading key" if key.null?
368
376
  raise "Failed adding key to mgr" if XMLSecurity.xmlSecOpenSSLAppDefaultKeysMngrAdoptKey(kmgr, key) < 0
369
377
 
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{ruby-saml-mod}
3
- s.version = "0.1.20"
3
+ s.version = "0.1.21"
4
4
 
5
5
  s.authors = ["OneLogin LLC", "Bracken", "Zach", "Cody", "Jeremy", "Paul"]
6
- s.date = %q{2013-02-15}
6
+ s.date = %q{2013-03-07}
7
7
  s.extra_rdoc_files = [
8
8
  "LICENSE"
9
9
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-saml-mod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2013-02-15 00:00:00.000000000 Z
17
+ date: 2013-03-07 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: libxml-ruby
@@ -90,9 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project:
93
- rubygems_version: 1.8.24
93
+ rubygems_version: 1.8.23
94
94
  signing_key:
95
95
  specification_version: 3
96
96
  summary: Ruby library for SAML service providers
97
97
  test_files: []
98
- has_rdoc: