authorizenet 1.9.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/app/helpers/authorize_net_helper.rb +23 -23
- data/lib/authorize_net.rb +62 -107
- data/lib/authorize_net/api/LogHelper.rb +97 -97
- data/lib/authorize_net/api/SensitiveDataFilter.rb +92 -92
- data/lib/authorize_net/api/api_transaction.rb +129 -129
- data/lib/authorize_net/api/constants.yml +1 -1
- data/lib/authorize_net/api/schema.rb +5421 -5421
- data/lib/authorize_net/api/transaction.rb +265 -265
- data/lib/authorize_net/authorize_net.rb +154 -154
- data/lib/authorize_net/response.rb +23 -25
- data/lib/authorize_net/transaction.rb +64 -66
- data/lib/authorize_net/xml_response.rb +154 -154
- data/lib/authorize_net/xml_transaction.rb +279 -279
- data/lib/authorizenet.rb +4 -4
- metadata +3 -61
- data/lib/authorize_net/addresses/address.rb +0 -25
- data/lib/authorize_net/addresses/shipping_address.rb +0 -22
- data/lib/authorize_net/aim/response.rb +0 -120
- data/lib/authorize_net/aim/transaction.rb +0 -171
- data/lib/authorize_net/arb/fields.rb +0 -24
- data/lib/authorize_net/arb/paging.rb +0 -29
- data/lib/authorize_net/arb/response.rb +0 -26
- data/lib/authorize_net/arb/sorting.rb +0 -39
- data/lib/authorize_net/arb/subscription.rb +0 -68
- data/lib/authorize_net/arb/subscription_detail.rb +0 -10
- data/lib/authorize_net/arb/subscription_list_response.rb +0 -36
- data/lib/authorize_net/arb/transaction.rb +0 -171
- data/lib/authorize_net/cim/customer_profile.rb +0 -15
- data/lib/authorize_net/cim/payment_profile.rb +0 -35
- data/lib/authorize_net/cim/response.rb +0 -111
- data/lib/authorize_net/cim/transaction.rb +0 -721
- data/lib/authorize_net/customer.rb +0 -24
- data/lib/authorize_net/email_receipt.rb +0 -20
- data/lib/authorize_net/fields.rb +0 -760
- data/lib/authorize_net/key_value_response.rb +0 -109
- data/lib/authorize_net/key_value_transaction.rb +0 -281
- data/lib/authorize_net/line_item.rb +0 -21
- data/lib/authorize_net/order.rb +0 -38
- data/lib/authorize_net/payment_methods/credit_card.rb +0 -61
- data/lib/authorize_net/payment_methods/echeck.rb +0 -70
- data/lib/authorize_net/reporting/batch.rb +0 -16
- data/lib/authorize_net/reporting/batch_statistics.rb +0 -15
- data/lib/authorize_net/reporting/fds_filter.rb +0 -8
- data/lib/authorize_net/reporting/response.rb +0 -157
- data/lib/authorize_net/reporting/returned_item.rb +0 -45
- data/lib/authorize_net/reporting/transaction.rb +0 -131
- data/lib/authorize_net/reporting/transaction_details.rb +0 -22
- data/lib/authorize_net/sim/hosted_payment_form.rb +0 -34
- data/lib/authorize_net/sim/hosted_receipt_page.rb +0 -32
- data/lib/authorize_net/sim/response.rb +0 -133
- data/lib/authorize_net/sim/transaction.rb +0 -128
- data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +0 -52
- data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +0 -49
- data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +0 -8
- data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +0 -8
- data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +0 -31
- data/lib/generators/authorize_net/direct_post/templates/initializer.rb +0 -4
- data/lib/generators/authorize_net/direct_post/templates/layout.erb +0 -18
- data/lib/generators/authorize_net/direct_post/templates/payment.erb +0 -10
- data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +0 -10
- data/lib/generators/authorize_net/direct_post/templates/receipt.erb +0 -1
- data/lib/generators/authorize_net/direct_post/templates/relay_response.erb +0 -1
- data/lib/generators/authorize_net/sim/sim_generator.rb +0 -46
- data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +0 -52
- data/lib/generators/authorize_net/sim/templates/config.yml.erb +0 -8
- data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +0 -8
- data/lib/generators/authorize_net/sim/templates/controller.rb.erb +0 -21
- data/lib/generators/authorize_net/sim/templates/initializer.rb +0 -4
- data/lib/generators/authorize_net/sim/templates/layout.erb +0 -18
- data/lib/generators/authorize_net/sim/templates/payment.erb +0 -6
- data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +0 -6
- data/lib/generators/authorize_net/sim/templates/thank_you.erb +0 -1
- data/lib/generators/generator_extensions.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1fd02e996bf869f3af383711557d3a89e5b64a8d
|
4
|
+
data.tar.gz: a6afe631df586bb1a58a97db794cf7b474d76728
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e194fce9b6ebfcf9e8d45f75fe1ce4dbbf8d656f01c321e5d7cb9a69f4117341b8124e81cb8e8cb04d16b92c91f797ccae23297c0116dded3a4520072ec5d9b
|
7
|
+
data.tar.gz: 96fcb8fadbf47257e06eeaac1de31d872445d73346e6d8cfa646089d7de6c36d9235e52ff07e4f13b56a308a4efb810cc1ff99a8ce774738385bce53ce8d6632
|
@@ -1,23 +1,23 @@
|
|
1
|
-
# The Authorize.Net Rails Helper module. Provides methods to assist with integrating the various APIs.
|
2
|
-
|
3
|
-
module AuthorizeNetHelper
|
4
|
-
# Generates a collection of hidden form fields (as a raw HTML string) for a AuthorizeNet::SIM::Transaction
|
5
|
-
# (sim_transaction). You can specify any html_options that hidden_field_tag accepts, and the
|
6
|
-
# hidden fields will be built with those options.
|
7
|
-
def sim_fields(sim_transaction, html_options = {})
|
8
|
-
fields = sim_transaction.form_fields.collect do |k, v|
|
9
|
-
if v.is_a? Array
|
10
|
-
v.collect { |val| hidden_field_tag(k, val, html_options) }
|
11
|
-
else
|
12
|
-
hidden_field_tag(k, v, html_options)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
fields.flatten!
|
16
|
-
field_str = fields.join("\n")
|
17
|
-
if field_str.respond_to?(:html_safe)
|
18
|
-
return field_str.html_safe
|
19
|
-
else
|
20
|
-
return field_str
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
# The Authorize.Net Rails Helper module. Provides methods to assist with integrating the various APIs.
|
2
|
+
|
3
|
+
module AuthorizeNetHelper
|
4
|
+
# Generates a collection of hidden form fields (as a raw HTML string) for a AuthorizeNet::SIM::Transaction
|
5
|
+
# (sim_transaction). You can specify any html_options that hidden_field_tag accepts, and the
|
6
|
+
# hidden fields will be built with those options.
|
7
|
+
def sim_fields(sim_transaction, html_options = {})
|
8
|
+
fields = sim_transaction.form_fields.collect do |k, v|
|
9
|
+
if v.is_a? Array
|
10
|
+
v.collect { |val| hidden_field_tag(k, val, html_options) }
|
11
|
+
else
|
12
|
+
hidden_field_tag(k, v, html_options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
fields.flatten!
|
16
|
+
field_str = fields.join("\n")
|
17
|
+
if field_str.respond_to?(:html_safe)
|
18
|
+
return field_str.html_safe
|
19
|
+
else
|
20
|
+
return field_str
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/authorize_net.rb
CHANGED
@@ -1,107 +1,62 @@
|
|
1
|
-
# The SDK initialization enters here. Loads all needed libraries and files. Inspects
|
2
|
-
# the current runtime to see if Rails is present. If it is, we inject our helper into
|
3
|
-
# ActiveSupport.
|
4
|
-
|
5
|
-
# coverall
|
6
|
-
# require 'coveralls'
|
7
|
-
# Coveralls.wear!
|
8
|
-
|
9
|
-
require "cgi"
|
10
|
-
require "net/https"
|
11
|
-
require "uri"
|
12
|
-
require "openssl"
|
13
|
-
require 'bigdecimal'
|
14
|
-
require 'nokogiri'
|
15
|
-
require 'date'
|
16
|
-
|
17
|
-
# TODO: Add local data validation where possible
|
18
|
-
|
19
|
-
$LOAD_PATH.unshift File.dirname(__FILE__)
|
20
|
-
|
21
|
-
require "authorize_net/authorize_net"
|
22
|
-
require "authorize_net/
|
23
|
-
require "authorize_net/
|
24
|
-
require "authorize_net/
|
25
|
-
require "authorize_net/
|
26
|
-
require "authorize_net/
|
27
|
-
require "authorize_net/
|
28
|
-
require "authorize_net/
|
29
|
-
require "authorize_net/
|
30
|
-
require "authorize_net/
|
31
|
-
require "authorize_net/
|
32
|
-
|
33
|
-
|
34
|
-
require "authorize_net/
|
35
|
-
require "authorize_net/
|
36
|
-
require "authorize_net/
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
require "authorize_net/arb/paging"
|
65
|
-
require "authorize_net/arb/sorting"
|
66
|
-
require "authorize_net/arb/subscription_list_response"
|
67
|
-
require "authorize_net/arb/subscription_detail"
|
68
|
-
require "authorize_net/arb/fields"
|
69
|
-
require "authorize_net/arb/subscription"
|
70
|
-
require "authorize_net/arb/response"
|
71
|
-
require "authorize_net/arb/transaction"
|
72
|
-
|
73
|
-
# CIM
|
74
|
-
|
75
|
-
require "authorize_net/cim/response"
|
76
|
-
require "authorize_net/cim/transaction"
|
77
|
-
|
78
|
-
# Reporting
|
79
|
-
|
80
|
-
require "authorize_net/reporting/response"
|
81
|
-
require "authorize_net/reporting/transaction"
|
82
|
-
|
83
|
-
# Load our Rails plugin
|
84
|
-
|
85
|
-
if defined?(Rails)
|
86
|
-
if defined?(Rails::Railtie)
|
87
|
-
module AuthorizeNet
|
88
|
-
class Railtie < Rails::Railtie
|
89
|
-
initializer "authorize_net.load_path_initialize" do |_app|
|
90
|
-
%w[models controllers helpers].each do |dir|
|
91
|
-
path = File.join(File.dirname(__FILE__), 'app', dir)
|
92
|
-
$LOAD_PATH << path
|
93
|
-
ActiveSupport::Dependencies.autoload_paths << path
|
94
|
-
ActiveSupport::Dependencies.autoload_once_paths.delete(path)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
else
|
100
|
-
%w[models controllers helpers].each do |dir|
|
101
|
-
path = File.join(File.dirname(__FILE__), 'app', dir)
|
102
|
-
$LOAD_PATH << path
|
103
|
-
ActiveSupport::Dependencies.load_paths << path
|
104
|
-
ActiveSupport::Dependencies.load_once_paths.delete(path)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
1
|
+
# The SDK initialization enters here. Loads all needed libraries and files. Inspects
|
2
|
+
# the current runtime to see if Rails is present. If it is, we inject our helper into
|
3
|
+
# ActiveSupport.
|
4
|
+
|
5
|
+
# coverall
|
6
|
+
# require 'coveralls'
|
7
|
+
# Coveralls.wear!
|
8
|
+
|
9
|
+
require "cgi"
|
10
|
+
require "net/https"
|
11
|
+
require "uri"
|
12
|
+
require "openssl"
|
13
|
+
require 'bigdecimal'
|
14
|
+
require 'nokogiri'
|
15
|
+
require 'date'
|
16
|
+
|
17
|
+
# TODO: Add local data validation where possible
|
18
|
+
|
19
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
20
|
+
|
21
|
+
require "authorize_net/authorize_net"
|
22
|
+
# require "authorize_net/customer"
|
23
|
+
# require "authorize_net/email_receipt"
|
24
|
+
# require "authorize_net/order"
|
25
|
+
# require "authorize_net/line_item"
|
26
|
+
require "authorize_net/response"
|
27
|
+
# require "authorize_net/key_value_response"
|
28
|
+
require "authorize_net/xml_response"
|
29
|
+
require "authorize_net/transaction"
|
30
|
+
# require "authorize_net/key_value_transaction"
|
31
|
+
require "authorize_net/xml_transaction"
|
32
|
+
|
33
|
+
# API
|
34
|
+
require "authorize_net/api/schema"
|
35
|
+
require "authorize_net/api/api_transaction"
|
36
|
+
require "authorize_net/api/transaction"
|
37
|
+
|
38
|
+
# Load our Rails plugin
|
39
|
+
|
40
|
+
if defined?(Rails)
|
41
|
+
if defined?(Rails::Railtie)
|
42
|
+
module AuthorizeNet
|
43
|
+
class Railtie < Rails::Railtie
|
44
|
+
initializer "authorize_net.load_path_initialize" do |_app|
|
45
|
+
%w[models controllers helpers].each do |dir|
|
46
|
+
path = File.join(File.dirname(__FILE__), 'app', dir)
|
47
|
+
$LOAD_PATH << path
|
48
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
49
|
+
ActiveSupport::Dependencies.autoload_once_paths.delete(path)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
else
|
55
|
+
%w[models controllers helpers].each do |dir|
|
56
|
+
path = File.join(File.dirname(__FILE__), 'app', dir)
|
57
|
+
$LOAD_PATH << path
|
58
|
+
ActiveSupport::Dependencies.load_paths << path
|
59
|
+
ActiveSupport::Dependencies.load_once_paths.delete(path)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,97 +1,97 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'yaml'
|
3
|
-
require File.join File.dirname(__FILE__), 'SensitiveDataFilter'
|
4
|
-
|
5
|
-
module AuthorizeNet::API
|
6
|
-
class Log
|
7
|
-
@@shouldLog = false
|
8
|
-
@@loglevels = ['debug','info','warn','error']
|
9
|
-
def initialize()
|
10
|
-
begin
|
11
|
-
filepath = './LogConfig.yml'
|
12
|
-
if(File.file?(filepath))
|
13
|
-
cnf = YAML::load(File.open(filepath))
|
14
|
-
if(@@loglevels.include? cnf['loglevel'].downcase)
|
15
|
-
@@shouldLog = true
|
16
|
-
@logger = Logger.new(cnf['filepath'])
|
17
|
-
@logger.level = LogLevelMapper(cnf['loglevel'].downcase)
|
18
|
-
if(cnf['maskSensitiveData'])
|
19
|
-
@logger.formatter = SensitiveDataFilter.new
|
20
|
-
else
|
21
|
-
constants = YAML.load_file(File.dirname(__FILE__) + "/constants.yml")
|
22
|
-
@logger.formatter = proc do |severity, datetime, progname, msg|
|
23
|
-
progname = constants['clientId']
|
24
|
-
date_format = datetime.strftime("%Y-%m-%d %H:%M:%S")
|
25
|
-
if severity == "INFO" or severity == "WARN"
|
26
|
-
"[#{date_format}] #{severity} (#{progname}): #{msg}\n"
|
27
|
-
else
|
28
|
-
"[#{date_format}] #{severity} (#{progname}): #{msg}\n"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
else
|
33
|
-
raise "Invalid log levels"
|
34
|
-
end
|
35
|
-
else
|
36
|
-
@@shouldLog = false
|
37
|
-
end
|
38
|
-
rescue
|
39
|
-
@@shouldLog = false
|
40
|
-
end
|
41
|
-
end
|
42
|
-
def debug(message)
|
43
|
-
if(@@shouldLog)
|
44
|
-
begin
|
45
|
-
@logger.debug message
|
46
|
-
rescue Exception => ex
|
47
|
-
ex
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
def info(message)
|
52
|
-
if(@@shouldLog)
|
53
|
-
begin
|
54
|
-
@logger.info message
|
55
|
-
rescue Exception => ex
|
56
|
-
ex
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
def warn(message)
|
61
|
-
if(@@shouldLog)
|
62
|
-
begin
|
63
|
-
@logger.warn message
|
64
|
-
rescue Exception => ex
|
65
|
-
ex
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
def error(message)
|
70
|
-
if(@@shouldLog)
|
71
|
-
begin
|
72
|
-
@logger.error message
|
73
|
-
rescue Exception => ex
|
74
|
-
ex
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
def LogLevelMapper(loglevel)
|
79
|
-
case loglevel
|
80
|
-
when 'debug'
|
81
|
-
Logger::DEBUG
|
82
|
-
when 'info'
|
83
|
-
Logger::INFO
|
84
|
-
when 'warn'
|
85
|
-
Logger::WARN
|
86
|
-
when 'error'
|
87
|
-
Logger::ERROR
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
class LogHelper
|
93
|
-
def self.log
|
94
|
-
Log.new
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
1
|
+
require 'logger'
|
2
|
+
require 'yaml'
|
3
|
+
require File.join File.dirname(__FILE__), 'SensitiveDataFilter'
|
4
|
+
|
5
|
+
module AuthorizeNet::API
|
6
|
+
class Log
|
7
|
+
@@shouldLog = false
|
8
|
+
@@loglevels = ['debug','info','warn','error']
|
9
|
+
def initialize()
|
10
|
+
begin
|
11
|
+
filepath = './LogConfig.yml'
|
12
|
+
if(File.file?(filepath))
|
13
|
+
cnf = YAML::load(File.open(filepath))
|
14
|
+
if(@@loglevels.include? cnf['loglevel'].downcase)
|
15
|
+
@@shouldLog = true
|
16
|
+
@logger = Logger.new(cnf['filepath'])
|
17
|
+
@logger.level = LogLevelMapper(cnf['loglevel'].downcase)
|
18
|
+
if(cnf['maskSensitiveData'])
|
19
|
+
@logger.formatter = SensitiveDataFilter.new
|
20
|
+
else
|
21
|
+
constants = YAML.load_file(File.dirname(__FILE__) + "/constants.yml")
|
22
|
+
@logger.formatter = proc do |severity, datetime, progname, msg|
|
23
|
+
progname = constants['clientId']
|
24
|
+
date_format = datetime.strftime("%Y-%m-%d %H:%M:%S")
|
25
|
+
if severity == "INFO" or severity == "WARN"
|
26
|
+
"[#{date_format}] #{severity} (#{progname}): #{msg}\n"
|
27
|
+
else
|
28
|
+
"[#{date_format}] #{severity} (#{progname}): #{msg}\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
raise "Invalid log levels"
|
34
|
+
end
|
35
|
+
else
|
36
|
+
@@shouldLog = false
|
37
|
+
end
|
38
|
+
rescue
|
39
|
+
@@shouldLog = false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
def debug(message)
|
43
|
+
if(@@shouldLog)
|
44
|
+
begin
|
45
|
+
@logger.debug message
|
46
|
+
rescue Exception => ex
|
47
|
+
ex
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
def info(message)
|
52
|
+
if(@@shouldLog)
|
53
|
+
begin
|
54
|
+
@logger.info message
|
55
|
+
rescue Exception => ex
|
56
|
+
ex
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
def warn(message)
|
61
|
+
if(@@shouldLog)
|
62
|
+
begin
|
63
|
+
@logger.warn message
|
64
|
+
rescue Exception => ex
|
65
|
+
ex
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
def error(message)
|
70
|
+
if(@@shouldLog)
|
71
|
+
begin
|
72
|
+
@logger.error message
|
73
|
+
rescue Exception => ex
|
74
|
+
ex
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
def LogLevelMapper(loglevel)
|
79
|
+
case loglevel
|
80
|
+
when 'debug'
|
81
|
+
Logger::DEBUG
|
82
|
+
when 'info'
|
83
|
+
Logger::INFO
|
84
|
+
when 'warn'
|
85
|
+
Logger::WARN
|
86
|
+
when 'error'
|
87
|
+
Logger::ERROR
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class LogHelper
|
93
|
+
def self.log
|
94
|
+
Log.new
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -1,92 +1,92 @@
|
|
1
|
-
require 'logger'
|
2
|
-
|
3
|
-
module AuthorizeNet::API
|
4
|
-
class SensitiveTag
|
5
|
-
attr_accessor :tagName, :pattern, :replacement, :disableMask
|
6
|
-
def initialize(tagName, pattern, replacement, disableMask)
|
7
|
-
@tagName = tagName
|
8
|
-
@pattern = pattern
|
9
|
-
@replacement = replacement
|
10
|
-
@disableMask = disableMask
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class SensitiveDataConfigType
|
15
|
-
attr_accessor :sensitiveTags, :sensitiveStringRegexes
|
16
|
-
def initialize
|
17
|
-
@sensitiveTags = Array.new([SensitiveTag.new("cardCode", "", "XXX", false),
|
18
|
-
SensitiveTag.new("cardNumber", "(\\p{N}+)(\\p{N}{4})", "XXXX-\\2", false),
|
19
|
-
SensitiveTag.new("expirationDate", "", "XXX", false),
|
20
|
-
SensitiveTag.new("accountNumber", "(\\p{N}+)(\\p{N}{4})", "XXXX-\\2", false),
|
21
|
-
SensitiveTag.new("nameOnAccount", "", "XXX", false),
|
22
|
-
SensitiveTag.new("transactionKey", "", "XXX", false)]).freeze
|
23
|
-
@sensitiveStringRegexes = ["4\\p{N}{3}([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
|
24
|
-
"4\\p{N}{3}([\\ \\-]?)(?:\\p{N}{4}\\1){2}\\p{N}(?:\\p{N}{3})?",
|
25
|
-
"5[1-5]\\p{N}{2}([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
|
26
|
-
"6(?:011|22(?:1(?=[\\ \\-]?(?:2[6-9]|[3-9]))|[2-8]|9(?=[\\ \\-]?(?:[01]|2[0-5])))|4[4-9]\\p{N}|5\\p{N}\\p{N})([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
|
27
|
-
"35(?:2[89]|[3-8]\\p{N})([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
|
28
|
-
"3[47]\\p{N}\\p{N}([\\ \\-]?)\\p{N}{6}\\1\\p{N}{5}"].freeze
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class SensitiveDataFilter < Logger::Formatter
|
33
|
-
@@sensitiveTagConfig = nil
|
34
|
-
@@tagPatterns = nil
|
35
|
-
@@tagReplacements = nil
|
36
|
-
@@cardPatterns = nil
|
37
|
-
|
38
|
-
def initialize
|
39
|
-
@@sensitiveTagConfig = SensitiveDataConfigType.new
|
40
|
-
@@cardPatterns = @@sensitiveTagConfig.sensitiveStringRegexes
|
41
|
-
@@tagPatterns = Array.new(@@sensitiveTagConfig.sensitiveStringRegexes.length)
|
42
|
-
@@tagReplacements = Array.new(@@sensitiveTagConfig.sensitiveTags.length)
|
43
|
-
|
44
|
-
@@sensitiveTagConfig.sensitiveTags.each_with_index do |sensitiveTag, index|
|
45
|
-
tagName = sensitiveTag.tagName
|
46
|
-
replacement = sensitiveTag.replacement
|
47
|
-
|
48
|
-
if sensitiveTag.pattern.nil? || sensitiveTag.pattern.empty?
|
49
|
-
pattern = "(.*)"
|
50
|
-
else
|
51
|
-
pattern = sensitiveTag.pattern
|
52
|
-
end
|
53
|
-
|
54
|
-
@@tagPatterns[index] = "<"+tagName+">"+pattern+"</"+tagName+">"
|
55
|
-
@@tagReplacements[index] = "<"+tagName+">"+replacement+"</"+tagName+">"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def call(severity, time, progname, msg)
|
60
|
-
xmlMaskedLog = maskSensitiveXmlString(msg)
|
61
|
-
ccMasked = maskCreditCards(xmlMaskedLog)
|
62
|
-
return formatLogEntry(severity, time, progname, ccMasked)
|
63
|
-
end
|
64
|
-
|
65
|
-
def maskCreditCards(input)
|
66
|
-
input = input.force_encoding("UTF-8")
|
67
|
-
@@cardPatterns.each {|cardNumberRegex|
|
68
|
-
input = input.gsub(/#{cardNumberRegex}/, "XXX")
|
69
|
-
}
|
70
|
-
return input
|
71
|
-
end
|
72
|
-
|
73
|
-
def maskSensitiveXmlString(input)
|
74
|
-
input = input.force_encoding("UTF-8")
|
75
|
-
@@tagPatterns.each_with_index do |item, index|
|
76
|
-
input = input.gsub(/#{item}/,@@tagReplacements[index])
|
77
|
-
end
|
78
|
-
return input
|
79
|
-
end
|
80
|
-
|
81
|
-
def formatLogEntry(severity, time, progname, msg)
|
82
|
-
constants = YAML.load_file(File.dirname(__FILE__) + "/constants.yml")
|
83
|
-
progname = constants['clientId']
|
84
|
-
date_format = time.strftime("%Y-%m-%d %H:%M:%S")
|
85
|
-
if severity == "INFO" or severity == "WARN"
|
86
|
-
"[#{date_format}] #{severity} (#{progname}): #{msg}\n"
|
87
|
-
else
|
88
|
-
"[#{date_format}] #{severity} (#{progname}): #{msg}\n"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module AuthorizeNet::API
|
4
|
+
class SensitiveTag
|
5
|
+
attr_accessor :tagName, :pattern, :replacement, :disableMask
|
6
|
+
def initialize(tagName, pattern, replacement, disableMask)
|
7
|
+
@tagName = tagName
|
8
|
+
@pattern = pattern
|
9
|
+
@replacement = replacement
|
10
|
+
@disableMask = disableMask
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class SensitiveDataConfigType
|
15
|
+
attr_accessor :sensitiveTags, :sensitiveStringRegexes
|
16
|
+
def initialize
|
17
|
+
@sensitiveTags = Array.new([SensitiveTag.new("cardCode", "", "XXX", false),
|
18
|
+
SensitiveTag.new("cardNumber", "(\\p{N}+)(\\p{N}{4})", "XXXX-\\2", false),
|
19
|
+
SensitiveTag.new("expirationDate", "", "XXX", false),
|
20
|
+
SensitiveTag.new("accountNumber", "(\\p{N}+)(\\p{N}{4})", "XXXX-\\2", false),
|
21
|
+
SensitiveTag.new("nameOnAccount", "", "XXX", false),
|
22
|
+
SensitiveTag.new("transactionKey", "", "XXX", false)]).freeze
|
23
|
+
@sensitiveStringRegexes = ["4\\p{N}{3}([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
|
24
|
+
"4\\p{N}{3}([\\ \\-]?)(?:\\p{N}{4}\\1){2}\\p{N}(?:\\p{N}{3})?",
|
25
|
+
"5[1-5]\\p{N}{2}([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
|
26
|
+
"6(?:011|22(?:1(?=[\\ \\-]?(?:2[6-9]|[3-9]))|[2-8]|9(?=[\\ \\-]?(?:[01]|2[0-5])))|4[4-9]\\p{N}|5\\p{N}\\p{N})([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
|
27
|
+
"35(?:2[89]|[3-8]\\p{N})([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
|
28
|
+
"3[47]\\p{N}\\p{N}([\\ \\-]?)\\p{N}{6}\\1\\p{N}{5}"].freeze
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class SensitiveDataFilter < Logger::Formatter
|
33
|
+
@@sensitiveTagConfig = nil
|
34
|
+
@@tagPatterns = nil
|
35
|
+
@@tagReplacements = nil
|
36
|
+
@@cardPatterns = nil
|
37
|
+
|
38
|
+
def initialize
|
39
|
+
@@sensitiveTagConfig = SensitiveDataConfigType.new
|
40
|
+
@@cardPatterns = @@sensitiveTagConfig.sensitiveStringRegexes
|
41
|
+
@@tagPatterns = Array.new(@@sensitiveTagConfig.sensitiveStringRegexes.length)
|
42
|
+
@@tagReplacements = Array.new(@@sensitiveTagConfig.sensitiveTags.length)
|
43
|
+
|
44
|
+
@@sensitiveTagConfig.sensitiveTags.each_with_index do |sensitiveTag, index|
|
45
|
+
tagName = sensitiveTag.tagName
|
46
|
+
replacement = sensitiveTag.replacement
|
47
|
+
|
48
|
+
if sensitiveTag.pattern.nil? || sensitiveTag.pattern.empty?
|
49
|
+
pattern = "(.*)"
|
50
|
+
else
|
51
|
+
pattern = sensitiveTag.pattern
|
52
|
+
end
|
53
|
+
|
54
|
+
@@tagPatterns[index] = "<"+tagName+">"+pattern+"</"+tagName+">"
|
55
|
+
@@tagReplacements[index] = "<"+tagName+">"+replacement+"</"+tagName+">"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def call(severity, time, progname, msg)
|
60
|
+
xmlMaskedLog = maskSensitiveXmlString(msg)
|
61
|
+
ccMasked = maskCreditCards(xmlMaskedLog)
|
62
|
+
return formatLogEntry(severity, time, progname, ccMasked)
|
63
|
+
end
|
64
|
+
|
65
|
+
def maskCreditCards(input)
|
66
|
+
input = input.force_encoding("UTF-8")
|
67
|
+
@@cardPatterns.each {|cardNumberRegex|
|
68
|
+
input = input.gsub(/#{cardNumberRegex}/, "XXX")
|
69
|
+
}
|
70
|
+
return input
|
71
|
+
end
|
72
|
+
|
73
|
+
def maskSensitiveXmlString(input)
|
74
|
+
input = input.force_encoding("UTF-8")
|
75
|
+
@@tagPatterns.each_with_index do |item, index|
|
76
|
+
input = input.gsub(/#{item}/,@@tagReplacements[index])
|
77
|
+
end
|
78
|
+
return input
|
79
|
+
end
|
80
|
+
|
81
|
+
def formatLogEntry(severity, time, progname, msg)
|
82
|
+
constants = YAML.load_file(File.dirname(__FILE__) + "/constants.yml")
|
83
|
+
progname = constants['clientId']
|
84
|
+
date_format = time.strftime("%Y-%m-%d %H:%M:%S")
|
85
|
+
if severity == "INFO" or severity == "WARN"
|
86
|
+
"[#{date_format}] #{severity} (#{progname}): #{msg}\n"
|
87
|
+
else
|
88
|
+
"[#{date_format}] #{severity} (#{progname}): #{msg}\n"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|