Class: Ingenico::Connect::SDK::Logging::ValueObfuscator Deprecated
- Inherits:
-
Object
- Object
- Ingenico::Connect::SDK::Logging::ValueObfuscator
- Defined in:
- lib/ingenico/connect/sdk/logging/logging_util.rb
Overview
This class shouldn’t have been exposed
Class responsible for obfuscating sensitive data in a message body.
Class Method Summary collapse
- .ALL ⇒ Object
-
.fixed_length(fixed_length) ⇒ Object
Creates a new ValueObfuscator that replaces any sensitive data with a fixed_length line of asterisks.
-
.keep_end_count(count) ⇒ Object
Creates a new ValueObfuscator that retains only the last count characters of any value to obfuscate and replaces the rest with asterisks.
-
.keep_start_count(count) ⇒ Object
Creates a new ValueObfuscator that retains only the first count characters of any value to obfuscate and replaces the rest with asterisks.
- .new(*args) ⇒ Object
- .private_new ⇒ Object
Instance Method Summary collapse
-
#initialize(fixed_length, keep_start_count, keep_end_count) ⇒ ValueObfuscator
constructor
Creates a new ValueObfuscator.
-
#obfuscate_value(value) ⇒ Object
Obfuscates the parameter value.
Constructor Details
#initialize(fixed_length, keep_start_count, keep_end_count) ⇒ ValueObfuscator
Creates a new ValueObfuscator.
30 31 32 33 34 35 |
# File 'lib/ingenico/connect/sdk/logging/logging_util.rb', line 30 def initialize(fixed_length, keep_start_count, keep_end_count) @mask_character = '*' @fixed_length = fixed_length @keep_start_count = keep_start_count @keep_end_count = keep_end_count end |
Class Method Details
.ALL ⇒ Object
39 40 41 42 |
# File 'lib/ingenico/connect/sdk/logging/logging_util.rb', line 39 def self.ALL # use lazy instantiation @@ALL ||= ValueObfuscator.send(:private_new, 0, 0, 0) end |
.fixed_length(fixed_length) ⇒ Object
Creates a new ValueObfuscator that replaces any sensitive data with a fixed_length line of asterisks.
45 46 47 |
# File 'lib/ingenico/connect/sdk/logging/logging_util.rb', line 45 def self.fixed_length(fixed_length) ValueObfuscator.send(:private_new, fixed_length, 0, 0) end |
.keep_end_count(count) ⇒ Object
Creates a new ValueObfuscator that retains only the last count characters of any value to obfuscate and replaces the rest with asterisks.
57 58 59 |
# File 'lib/ingenico/connect/sdk/logging/logging_util.rb', line 57 def self.keep_end_count(count) ValueObfuscator.send(:private_new, 0, 0, count) end |
.keep_start_count(count) ⇒ Object
Creates a new ValueObfuscator that retains only the first count characters of any value to obfuscate and replaces the rest with asterisks.
51 52 53 |
# File 'lib/ingenico/connect/sdk/logging/logging_util.rb', line 51 def self.keep_start_count(count) ValueObfuscator.send(:private_new, 0, count, 0) end |
.new(*args) ⇒ Object
16 17 18 |
# File 'lib/ingenico/connect/sdk/logging/logging_util.rb', line 16 def new(*args) raise NoMethodError.new('ValueObfuscator should not explicitly instantiated!') end |
.private_new ⇒ Object
14 |
# File 'lib/ingenico/connect/sdk/logging/logging_util.rb', line 14 alias_method :private_new, :new |
Instance Method Details
#obfuscate_value(value) ⇒ Object
Obfuscates the parameter value.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ingenico/connect/sdk/logging/logging_util.rb', line 62 def obfuscate_value(value) return value if value.nil? or value.empty? return repeat_mask(@fixed_length) if @fixed_length > 0 return repeat_mask(value.length) if @keep_start_count == 0 and @keep_end_count == 0 return value if value.length < (@keep_start_count + @keep_end_count) # range describes the range of characters to replace with asterisks range = @keep_start_count...(value.length - @keep_end_count) value[range] = @mask_character * range.size value end |