active_merchant_ideal_multicert 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in active_merchant_ideal_multicert.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Voormedia B.V.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # ActiveMerchant iDEAL multi-certificate patch
2
+
3
+ The iDEAL certificates sometimes expire. To support both old and new certificates for a transition period, include this gem.
4
+
5
+ ## Example usage
6
+
7
+ In your Gemfile:
8
+
9
+ ```ruby
10
+ gem "activemerchant"
11
+ gem "active_merchant_ideal"
12
+ gem "active_merchant_ideal_multicert"
13
+ ```
14
+
15
+ (Order does matter)
16
+
17
+ In your ActiveMerchant initializer, configure multiple certificates like this:
18
+
19
+ ```ruby
20
+ ActiveMerchant::Billing::IdealGateway.ideal_certificate_files = [
21
+ "/path/to/certificate1",
22
+ "/path/to/certificate2"
23
+ ]
24
+ ```
25
+
26
+ Every time a transaction is verified, the message signature is verified
27
+ with the proper certificate identified by the message fingerprint.
28
+
29
+ ## LICENSE
30
+
31
+ active_merchant_ideal_multicert is Copyright (c) 2011 Voormedia B.V. and distributed under the MIT license. See the LICENSE file for more info.
32
+
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "active_merchant_ideal_multicert/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "active_merchant_ideal_multicert"
7
+ s.version = ActiveMerchantIdealMulticert::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Roel van Dijk"]
10
+ s.email = ["roelvandijk@voormedia.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{A patch for active_merchant_ideal to support multiple certificates.}
13
+ s.description = %q{A patch for active_merchant_ideal to support multiple certificates.}
14
+
15
+ s.rubyforge_project = "active_merchant_ideal_multicert"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,51 @@
1
+ require 'openssl'
2
+ require 'digest/sha1'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ class IdealGateway < Gateway
7
+ # Get certificate data by fingerprint.
8
+ def self.certificate_for_fingerprint(fingerprint)
9
+ @certificates_by_fingerprint[fingerprint]
10
+ end
11
+
12
+ # Save data of multiple certificates by certificate fingerprint.
13
+ def self.ideal_certificate_files=(certificate_files)
14
+ @certificates_by_fingerprint = certificate_files.inject({}) do |result, file|
15
+ data = File.read(file)
16
+ result[self.fingerprint(data)] = data
17
+ result
18
+ end
19
+ end
20
+
21
+ private
22
+ # Calculate fingerprint of a certificate data, which is defined as the
23
+ # SHA1-digest of the binary certificate data.
24
+ def self.fingerprint(certificate_data)
25
+ certificate = OpenSSL::X509::Certificate.new(certificate_data)
26
+ Digest::SHA1.hexdigest(certificate.to_der).upcase
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ module ActiveMerchant #:nodoc:
33
+ module Billing #:nodoc:
34
+ class IdealStatusResponse < IdealResponse
35
+ alias_method :old_verified?, :verified?
36
+
37
+ # Find the proper certificate and run the old verified code.
38
+ def verified?
39
+ certificate = IdealGateway.certificate_for_fingerprint(fingerprint)
40
+ return false unless certificate
41
+ IdealGateway.ideal_certificate = certificate
42
+ old_verified?
43
+ end
44
+
45
+ # Find the fingerprint in the XML.
46
+ def fingerprint
47
+ text('//fingerprint').upcase
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveMerchantIdealMulticert
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_merchant_ideal_multicert
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
+ platform: ruby
11
+ authors:
12
+ - Roel van Dijk
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-05-19 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: A patch for active_merchant_ideal to support multiple certificates.
22
+ email:
23
+ - roelvandijk@voormedia.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - LICENSE
34
+ - README.md
35
+ - Rakefile
36
+ - active_merchant_ideal_multicert.gemspec
37
+ - lib/active_merchant_ideal_multicert.rb
38
+ - lib/active_merchant_ideal_multicert/version.rb
39
+ has_rdoc: true
40
+ homepage: ""
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project: active_merchant_ideal_multicert
67
+ rubygems_version: 1.3.7
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: A patch for active_merchant_ideal to support multiple certificates.
71
+ test_files: []
72
+