deepsecurity 0.0.13hf1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +25 -0
  2. data/.yardopts +4 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +2 -0
  7. data/bin/dsc +186 -0
  8. data/deepsecurity.gemspec +30 -0
  9. data/lib/deepsecurity/ds_object.rb +37 -0
  10. data/lib/deepsecurity/enums.rb +539 -0
  11. data/lib/deepsecurity/exceptions/authentication_failed_exception.rb +7 -0
  12. data/lib/deepsecurity/exceptions/authentication_required_exception.rb +6 -0
  13. data/lib/deepsecurity/manager.rb +223 -0
  14. data/lib/deepsecurity/screenscraping.rb +149 -0
  15. data/lib/deepsecurity/transport_object.rb +21 -0
  16. data/lib/deepsecurity/transport_objects/anti_malware_event.rb +106 -0
  17. data/lib/deepsecurity/transport_objects/anti_malware_spyware_item.rb +32 -0
  18. data/lib/deepsecurity/transport_objects/application_type.rb +58 -0
  19. data/lib/deepsecurity/transport_objects/dpi_rule.rb +113 -0
  20. data/lib/deepsecurity/transport_objects/host.rb +171 -0
  21. data/lib/deepsecurity/transport_objects/host_detail.rb +167 -0
  22. data/lib/deepsecurity/transport_objects/host_filter.rb +62 -0
  23. data/lib/deepsecurity/transport_objects/host_group.rb +41 -0
  24. data/lib/deepsecurity/transport_objects/host_interface.rb +42 -0
  25. data/lib/deepsecurity/transport_objects/id_filter.rb +37 -0
  26. data/lib/deepsecurity/transport_objects/private/vulnerability.rb +52 -0
  27. data/lib/deepsecurity/transport_objects/protocol_icmp.rb +13 -0
  28. data/lib/deepsecurity/transport_objects/protocol_port_based.rb +11 -0
  29. data/lib/deepsecurity/transport_objects/security_profile.rb +90 -0
  30. data/lib/deepsecurity/transport_objects/system_event.rb +45 -0
  31. data/lib/deepsecurity/transport_objects/time_filter.rb +55 -0
  32. data/lib/deepsecurity/version.rb +3 -0
  33. data/lib/deepsecurity.rb +58 -0
  34. data/lib/dsc/anti_malware_event.rb +101 -0
  35. data/lib/dsc/dsc_object.rb +41 -0
  36. data/lib/dsc/helper.rb +48 -0
  37. data/lib/dsc/host_detail.rb +62 -0
  38. data/lib/dsc.rb +6 -0
  39. data/lib/dsc_version.rb +3 -0
  40. data/lib/savon_helper/caching_object.rb +48 -0
  41. data/lib/savon_helper/mapping_object.rb +421 -0
  42. data/lib/savon_helper/missing_type_mapping_exception.rb +11 -0
  43. data/lib/savon_helper/soap_exception.rb +7 -0
  44. data/lib/savon_helper/type_mappings.rb +218 -0
  45. data/lib/savon_helper.rb +7 -0
  46. metadata +188 -0
@@ -0,0 +1,421 @@
1
+ # @author Udo Schneider <Udo.Schneider@homeaddress.de>
2
+
3
+ module SavonHelper
4
+
5
+ class MappingObject
6
+ @@mappings = Hash.new()
7
+
8
+ # @!group Request Helper
9
+
10
+ # Send a Request to the SOAP API for method +method_name+ with the data in +soap_body+ and unwrap the response
11
+ def send_soap(method, message = {})
12
+ retryable(:tries => 5, :on => Errno::ECONNRESET) do
13
+ logger.debug { "#{self.class}\##{__method__}(#{method.inspect}, #{message.inspect})" }
14
+ response = @client.call method, :message => message
15
+ return response.to_hash[(method.to_s+"_response").to_sym][(method.to_s+"_return").to_sym]
16
+ end
17
+ end
18
+
19
+ # Helper Method deserializing the SOAP response into an object
20
+ def request_object(method_name, object_class, soap_body={})
21
+ object_class.from_savon_data(self, send_soap(method_name, soap_body))
22
+ end
23
+
24
+ # Helper Method deserializing the SOAP response into an object
25
+ def request_array(method_name, object_class, collection_name = nil, soap_body={})
26
+ data = send_soap(method_name, soap_body)
27
+ data = data[collection_name] unless collection_name.blank?
28
+ SavonHelper::ArrayMapping.new(SavonHelper::ObjectMapping.new(object_class)).from_savon_data(data)
29
+ end
30
+
31
+ # @!endgroup
32
+
33
+ # @group Mapping
34
+
35
+ # Return an initialized instance with the values from the (type-converted) hash. Store the instance in cache
36
+ # if cacheable.
37
+ # @see #store_in_cache
38
+ #
39
+ # @param data [Hash] A hash of simple types as provided by Savon
40
+ # @return [MappingObject] The initialized instance.
41
+ def self.from_savon_data(data)
42
+ instance = self.new()
43
+ instance.fill_from_savon_data(data)
44
+ instance.store_in_cache if instance.cachable?
45
+ instance
46
+ end
47
+
48
+ # Return the instance as a hash of simple (type-converted) values suitable for Savon.
49
+ #
50
+ # @return [Hash] A Hash of simple types.
51
+ def to_savon_data
52
+ hash = Hash.new()
53
+ mappings.keys.each do |ivar_name|
54
+ value = ivar_to_savon_data(ivar_name, instance_variable_get("@#{ivar_name}"))
55
+ hash[ivar_name.to_sym] = value unless value.nil?
56
+ end
57
+ hash
58
+ end
59
+
60
+ # Set instance variables according to (type-converted) hash values
61
+ # @param data [Hash] A hash of simple types as provided by Savon
62
+ # @return [self]
63
+ def fill_from_savon_data(data)
64
+ data.each do |key, value|
65
+ instance_variable_set("@#{key}", ivar_from_savon_data(key, value))
66
+ end
67
+ end
68
+
69
+ # Return TypeMappings specific to the instance's class
70
+ # @return [Hash{Symbol => TypeMapping}]
71
+ def mappings
72
+ self.class.mappings
73
+ end
74
+
75
+ # Return TypeMappingschroch specific to the class
76
+ # @return [Hash{Symbol => TypeMapping}]
77
+ def self.mappings
78
+ mappings = @@mappings[self]
79
+ return mappings if !mappings.nil?
80
+ @@mappings[self] = Hash.new()
81
+ @@mappings[self]
82
+ end
83
+
84
+ def self.has_attribute_chain(field)
85
+ return true if self.method_defined?(field)
86
+ current_class = self
87
+ field.split('.').map(&:to_sym).all? do |each|
88
+ # puts "Current Class: #{current_class.inspect}, Field: #{each}"
89
+ if current_class.method_defined?(each)
90
+ if current_class.respond_to?(:mappings)
91
+ current_mapping = current_class.mappings[each]
92
+ # puts "Mapping: #{current_mapping}"
93
+ if !current_mapping.nil?
94
+ current_class = current_mapping.object_klass
95
+ else
96
+ current_class = NilClass
97
+ end
98
+ else
99
+ current_class = NilClass
100
+ end
101
+ true
102
+ else
103
+ false
104
+ end
105
+ end
106
+ end
107
+
108
+ def self.defined_attributes()
109
+ self.mappings.keys
110
+ end
111
+
112
+ def to_json(*a)
113
+ result = {}
114
+ self.mappings.keys.each { |key| result[key] = self.send(key).to_json }
115
+ {
116
+ 'json_class' => self.class.name,
117
+ 'data' => result
118
+ }.to_json(*a)
119
+ end
120
+
121
+ # @raise [MissingTypeMappingException] if no mapping for ivar_name can be found
122
+ def ivar_from_savon_data(ivar_name, value)
123
+ mapping = mappings[ivar_name]
124
+ mapping = SavonHelper.define_missing_type_mapping(self.class, ivar_name, value, mappings) if mapping.nil?
125
+ return nil if value.nil?
126
+ mapping.from_savon_data(value)
127
+ end
128
+
129
+ def ivar_to_savon_data(ivar_name, value)
130
+ mapping = mappings[ivar_name]
131
+ mapping = SavonHelper.define_missing_type_mapping(self.class, ivar_name, value, mappings) if mapping.nil?
132
+ return nil if value.nil?
133
+ return mapping.to_savon_data(value)
134
+ end
135
+
136
+ # @group DSL to define attributes mapping
137
+
138
+ # @macro [attach] attr_boolean_accessor
139
+ # @!attribute [rw] $3
140
+ # $2
141
+ # @return [Boolean]
142
+ # Define a new Boolean accessor
143
+ # @param accessor [Symbol] The accessor to be created
144
+ # @param description [String] The description for this accessor
145
+ # @param alias_accessor [Symbol] An Alias for the accessor
146
+ # @return [void]
147
+ def self.attr_boolean_accessor(accessor, description='', alias_accessor=accessor)
148
+ create_accessor(accessor, alias_accessor, BooleanMapping.new(description))
149
+ end
150
+
151
+ # @macro [attach] array_boolean_accessor
152
+ # @!attribute [rw] $3
153
+ # $2
154
+ # @return [Array<Boolean>]
155
+ # Define a new Boolean Array accessor
156
+ # @param accessor [Symbol] The accessor to be created
157
+ # @param description [String] The description for this accessor
158
+ # @param alias_accessor [Symbol] An Alias for the accessor
159
+ # @return [void]
160
+ def self.array_boolean_accessor(accessor, description='', alias_accessor=accessor)
161
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(BooleanMapping.new, description))
162
+ end
163
+
164
+ # @macro [attach] attr_datetime_accessor
165
+ # @!attribute [rw] $3
166
+ # $2
167
+ # @return [DateTime]
168
+ # Define a new DateTime accessor
169
+ # @param accessor [Symbol] The accessor to be created
170
+ # @param description [String] The description for this accessor
171
+ # @param alias_accessor [Symbol] An Alias for the accessor
172
+ # @return [void]
173
+ def self.attr_datetime_accessor(accessor, description='', alias_accessor=accessor)
174
+ create_accessor(accessor, alias_accessor, DatetimeMapping.new(description))
175
+ end
176
+
177
+ # @macro [attach] array_datetime_accessor
178
+ # @!attribute [rw] $3
179
+ # $2
180
+ # @return [Array<DateTime>]
181
+ # Define a new DateTime Array accessor
182
+ # @param accessor [Symbol] The accessor to be created
183
+ # @param description [String] The description for this accessor
184
+ # @param alias_accessor [Symbol] An Alias for the accessor
185
+ # @return [void]
186
+ def self.array_datetime_accessor(accessor, description='', alias_accessor=accessor)
187
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(DatetimeMapping.new, description))
188
+ end
189
+
190
+ # @macro [attach] attr_double_accessor
191
+ # @!attribute [rw] $3
192
+ # $2
193
+ # @return [float]
194
+ # Define a new Float accessor
195
+ # @param accessor [Symbol] The accessor to be created
196
+ # @param description [String] The description for this accessor
197
+ # @param alias_accessor [Symbol] An Alias for the accessor
198
+ # @return [void]
199
+ def self.attr_double_accessor(accessor, description='', alias_accessor=accessor)
200
+ create_accessor(accessor, alias_accessor, FloatMapping.new(description))
201
+ end
202
+
203
+ # @macro [attach] array_double__accessor
204
+ # @!attribute [rw] $3
205
+ # $2
206
+ # @return [Array<float>]
207
+ # Define a new Float Array accessor
208
+ # @param accessor [Symbol] The accessor to be created
209
+ # @param description [String] The description for this accessor
210
+ # @param alias_accessor [Symbol] An Alias for the accessor
211
+ # @return [void]
212
+ def self.array_double_accessor(accessor, description='', alias_accessor=accessor)
213
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(FloatMapping.new, description))
214
+ end
215
+
216
+ # @macro [attach] attr_enum_accessor
217
+ # @!attribute [rw] $4
218
+ # $3
219
+ # @return [$2]
220
+ # Define a new Enum accessor
221
+ # @param accessor [Symbol] The accessor to be created
222
+ # @param enum [Enum] An hash of Enum to Symbol mappings
223
+ # @param description [String] The description for this accessor
224
+ # @param alias_accessor [Symbol] An Alias for the accessor
225
+ # @return [void]
226
+ def self.attr_enum_accessor(accessor, enum, description='', alias_accessor=accessor)
227
+ create_accessor(accessor, alias_accessor, EnumMapping.new(enum, description))
228
+ end
229
+
230
+ # @macro [attach] array_enum_accessor
231
+ # @!attribute [rw] $4
232
+ # $3
233
+ # @return [Array<$2>]
234
+ # Define a new Enum Array accessor
235
+ # @param accessor [Symbol] The accessor to be created
236
+ # @param enum [Enum] An hash of Enum to Symbol mappings
237
+ # @param description [String] The description for this accessor
238
+ # @param alias_accessor [Symbol] An Alias for the accessor
239
+ # @return [void]
240
+ def self.array_enum_accessor(accessor, enum, description='', alias_accessor=accessor)
241
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(EnumMapping.new(enum), description))
242
+ end
243
+
244
+ # @macro [attach] attr_float_accessor
245
+ # @!attribute [rw] $3
246
+ # $2
247
+ # @return [float]
248
+ # Define a new Float accessor
249
+ # @param accessor [Symbol] The accessor to be created
250
+ # @param description [String] The description for this accessor
251
+ # @param alias_accessor [Symbol] An Alias for the accessor
252
+ # @return [void]
253
+ def self.attr_float_accessor(accessor, description='', alias_accessor=accessor)
254
+ create_accessor(accessor, alias_accessor, FloatMapping.new(description))
255
+ end
256
+
257
+ # @macro [attach] array_float__accessor
258
+ # @!attribute [rw] $3
259
+ # $2
260
+ # @return [Array<float>]
261
+ # Define a new Float array accessor
262
+ # @param accessor [Symbol] The accessor to be created
263
+ # @param description [String] The description for this accessor
264
+ # @param alias_accessor [Symbol] An Alias for the accessor
265
+ # @return [void]
266
+ def self.array_float__accessor(accessor, description='', alias_accessor=accessor)
267
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(FloatMapping.new, description))
268
+ end
269
+
270
+ # @macro [attach] attr_integer_accessor
271
+ # @!attribute [rw] $3
272
+ # $2
273
+ # @return [int]
274
+ # Define a new Integer accessor
275
+ # @param accessor [Symbol] The accessor to be created
276
+ # @param description [String] The description for this accessor
277
+ # @param alias_accessor [Symbol] An Alias for the accessor
278
+ # @return [void]
279
+ def self.attr_integer_accessor(accessor, description='', alias_accessor=accessor)
280
+ create_accessor(accessor, alias_accessor, IntegerMapping.new(description))
281
+ end
282
+
283
+ # @macro [attach] array_integer_accessor
284
+ # @!attribute [rw] $3
285
+ # $2
286
+ # @return [Array<int>]
287
+ # Define a new Integer Array accessor
288
+ # @param accessor [Symbol] The accessor to be created
289
+ # @param description [String] The description for this accessor
290
+ # @param alias_accessor [Symbol] An Alias for the accessor
291
+ # @return [void]
292
+ def self.array_integer_accessor(accessor, description='', alias_accessor=accessor)
293
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(IntegerMapping.new, description))
294
+ end
295
+
296
+ # @macro [attach] attr_ip_address_accessor
297
+ # @!attribute [rw] $3
298
+ # $2
299
+ # @return [int]
300
+ # Define a new IP Address accessor
301
+ # @param accessor [Symbol] The accessor to be created
302
+ # @param description [String] The description for this accessor
303
+ # @param alias_accessor [Symbol] An Alias for the accessor
304
+ # @return [void]
305
+ def self.attr_ip_address_accessor(accessor, description='', alias_accessor=accessor)
306
+ create_accessor(accessor, alias_accessor, IPAddressMapping.new(description))
307
+ end
308
+
309
+ # @macro [attach] array_ip_address_accessor
310
+ # @!attribute [rw] $3
311
+ # $2
312
+ # @return [Array<int>]
313
+ # Define a new IP Address Array accessor
314
+ # @param accessor [Symbol] The accessor to be created
315
+ # @param description [String] The description for this accessor
316
+ # @param alias_accessor [Symbol] An Alias for the accessor
317
+ # @return [void]
318
+ def self.array_ip_address_accessor(accessor, description='', alias_accessor=accessor)
319
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(IPAddressMapping.new, description))
320
+ end
321
+
322
+ # @macro [attach] attr_object_accessor
323
+ # @!attribute [rw] $4
324
+ # $3
325
+ # @return [$2]
326
+ # Define a new Object accessor
327
+ # @param accessor [Symbol] The accessor to be created
328
+ # @param klass [Class] The class of the accessed object
329
+ # @param description [String] The description for this accessor
330
+ # @param alias_accessor [Symbol] An Alias for the accessor
331
+ # @return [void]
332
+ def self.attr_object_accessor(accessor, klass, description='', alias_accessor=accessor)
333
+ create_accessor(accessor, alias_accessor, ObjectMapping.new(klass, description))
334
+ end
335
+
336
+ # @macro [attach] array_object_accessor
337
+ # @!attribute [rw] $4
338
+ # $3
339
+ # @return [Array<$2>]
340
+ # Define a new Object Array accessor
341
+ # @param accessor [Symbol] The accessor to be created
342
+ # @param klass [Class] The class of the accessed object
343
+ # @param description [String] The description for this accessor
344
+ # @param alias_accessor [Symbol] An Alias for the accessor
345
+ # @return [void]
346
+ def self.array_object_accessor(accessor, klass, description='', alias_accessor=accessor)
347
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(ObjectMapping.new(klass, description)))
348
+ end
349
+
350
+ # @macro [attach] attr_string_accessor
351
+ # @!attribute [rw] $3
352
+ # $2
353
+ # @return [String]
354
+ # Define a new String accessor
355
+ # @param accessor [Symbol] The accessor to be created
356
+ # @param description [String] The description for this accessor
357
+ # @param alias_accessor [Symbol] An Alias for the accessor
358
+ # @return [void]
359
+ def self.attr_string_accessor(accessor, description='', alias_accessor=accessor)
360
+ create_accessor(accessor, alias_accessor, StringMapping.new(description))
361
+ end
362
+
363
+ # @macro [attach] array_string_accessor
364
+ # @!attribute [rw] $3
365
+ # $2
366
+ # @return [Array<String>]
367
+ # Define a new String Array accessor
368
+ # @param accessor [Symbol] The accessor to be created
369
+ # @param description [String] The description for this accessor
370
+ # @param alias_accessor [Symbol] An Alias for the accessor
371
+ # @return [void]
372
+ def self.array_string_accessor(accessor, description='', alias_accessor=accessor)
373
+ create_accessor(accessor, alias_accessor, ArrayMapping.new(StringMapping.new, description))
374
+ end
375
+
376
+ # @macro [attach] hint_object_accessor
377
+ # @!attribute [rw] $3
378
+ # $2
379
+ # @return [String]
380
+ # Define a new "hint" for documentation purposes. Please note, that the method has to be define elsewhere!
381
+ # @param accessor [Symbol] The accessor to be created
382
+ # @param description [String] The description for this accessor
383
+ # @param alias_accessor [Symbol] An Alias for the accessor
384
+ # @return [void]
385
+ def self.hint_object_accessor(accessor, klass, description='', alias_accessor=accessor)
386
+ create_accessor(accessor, alias_accessor, HintMapping.new(klass, description))
387
+ end
388
+
389
+ # Create the specified accessor and it's alias
390
+ # @param accessor [Symbol] The accessor
391
+ # @param alias_accessor [Symbol] The accessor alias
392
+ # @return [void]
393
+ def self.create_accessor(accessor, alias_accessor, mapping)
394
+ mappings[accessor] = mapping
395
+ attr_accessor accessor
396
+ create_alias(accessor, alias_accessor)
397
+ end
398
+
399
+ # Create the specified alias
400
+ # @param accessor [Symbol] The accessor
401
+ # @param alias_accessor [Symbol] The accessor alias
402
+ # @return [void]
403
+ def self.create_alias(accessor, alias_accessor)
404
+ if alias_accessor != accessor
405
+ alias_method alias_accessor, accessor
406
+ alias_method alias_accessor.to_s + "=", accessor.to_s + "="
407
+ end
408
+ end
409
+
410
+ # @endgroup
411
+
412
+ end
413
+
414
+ end
415
+
416
+ class Object
417
+ def to_savon_data
418
+ self
419
+ end
420
+ end
421
+
@@ -0,0 +1,11 @@
1
+ module SavonHelper
2
+
3
+ # This class encapsulates a missing TypeMapping
4
+ class MissingTypeMappingException < Exception
5
+
6
+ def self.origin(klass, ivar_name, value)
7
+ self.new("No type mapping for #{klass}@#{ivar_name} = #{value}!")
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,7 @@
1
+ module SavonHelper
2
+ # This class encapsulates Exceptions from the underlying SOAP Backend.
3
+ # The intention is to prevent implementation details (the SOAP lib used in this case)
4
+ # from leaking out to module users
5
+ class SOAPException < Exception
6
+ end
7
+ end
@@ -0,0 +1,218 @@
1
+ # @author Udo Schneider <Udo.Schneider@homeaddress.de>
2
+
3
+ module SavonHelper
4
+
5
+ class TypeMapping
6
+
7
+ def logger
8
+ DeepSecurity::logger
9
+ end
10
+
11
+ def initialize(description='')
12
+ @description = description
13
+ end
14
+
15
+ def from_savon_data(data)
16
+ logger.error { "#{self.class}##{__method__}(#{data.inspect}) not implemented!" }
17
+ end
18
+
19
+ def to_savon_data(value)
20
+ logger.error { "#{self.class}##{__method__}(#{value.inspect}) not implemented!" }
21
+ end
22
+
23
+ def description
24
+ @description
25
+ end
26
+
27
+ def object_klass
28
+ logger.error { "#{self.class}##{__method__}() not implemented!" }
29
+ end
30
+
31
+ end
32
+
33
+ class ArrayMapping < TypeMapping
34
+
35
+ def self.from_savon_data(klass, data)
36
+ return [] if data.blank?
37
+ result = []
38
+ if data.is_a?(Array)
39
+ data.each do |element|
40
+ result << klass.from_savon_data(element)
41
+ end
42
+ elsif data.is_a?(Hash)
43
+ item = data[:item]
44
+ if item.nil?
45
+ result << klass.from_savon_data(data)
46
+ else
47
+ result = from_savon_data(klass, item)
48
+ end
49
+ else
50
+ raise "Unknown Array mapping"
51
+ end
52
+ result
53
+ end
54
+
55
+ def initialize(element_mapping, description='')
56
+ super(description)
57
+ @element_mapping = element_mapping
58
+ end
59
+
60
+ def from_savon_data(data)
61
+ self.class.from_savon_data(@element_mapping, data)
62
+ end
63
+
64
+ def _from_savon_data(data)
65
+ return @element_mapping.from_savon_data(data[:item]) if data[:item].is_a?(Hash)
66
+ data[:item].map do |each|
67
+ @element_mapping.from_savon_data(each)
68
+ end
69
+ end
70
+
71
+ def object_klass
72
+ @element_mapping.object_klass
73
+ end
74
+
75
+ end
76
+
77
+ class BooleanMapping < TypeMapping
78
+
79
+ def from_savon_data(data)
80
+ data.to_s == "true"
81
+ end
82
+
83
+ def to_savon_data(value)
84
+ value.to_s
85
+ end
86
+
87
+ end
88
+
89
+ class DatetimeMapping < TypeMapping
90
+
91
+ def from_savon_data(data)
92
+ DateTime.parse(data.to_s)
93
+ end
94
+
95
+ def to_savon_data(value)
96
+ value.to_datetime.to_s
97
+ end
98
+
99
+ end
100
+
101
+ class EnumMapping < TypeMapping
102
+
103
+ def initialize(enum, description='')
104
+ super(description)
105
+ @enum = enum
106
+ end
107
+
108
+ def from_savon_data(data)
109
+ @enum[data]
110
+ end
111
+
112
+ def to_savon_data(value)
113
+ @enum.key(value)
114
+ end
115
+
116
+ end
117
+
118
+ class FloatMapping < TypeMapping
119
+
120
+ def from_savon_data(data)
121
+ data.to_f
122
+ end
123
+
124
+ def to_savon_data(value)
125
+ value.to_s
126
+ end
127
+
128
+ end
129
+
130
+ class IntegerMapping < TypeMapping
131
+
132
+ def from_savon_data(data)
133
+ Integer(data.to_s)
134
+ end
135
+
136
+ def to_savon_data(value)
137
+ value.to_s
138
+ end
139
+
140
+ end
141
+
142
+ class IPAddressMapping < TypeMapping
143
+
144
+ def from_savon_data(data)
145
+ data.to_s
146
+ end
147
+
148
+ def to_savon_data(value)
149
+ value.to_s
150
+ end
151
+
152
+ end
153
+
154
+ class ObjectMapping < TypeMapping
155
+
156
+ def initialize(klass, description='')
157
+ super(description)
158
+ @klass = klass
159
+ end
160
+
161
+ def from_savon_data(data)
162
+ @klass.from_savon_data(data)
163
+ end
164
+
165
+ def object_klass
166
+ @klass
167
+ end
168
+
169
+ end
170
+
171
+ class StringMapping < TypeMapping
172
+
173
+ def from_savon_data(data)
174
+ data.to_s
175
+ end
176
+
177
+ def to_savon_data(value)
178
+ value.to_s
179
+ end
180
+
181
+ def object_klass
182
+ String
183
+ end
184
+
185
+ end
186
+
187
+ class MissingMapping < TypeMapping
188
+
189
+ def from_savon_data(data)
190
+ data
191
+ end
192
+
193
+ def to_savon_data(value)
194
+ value
195
+ end
196
+
197
+ end
198
+
199
+ class HintMapping < TypeMapping
200
+
201
+ def initialize(klass, description='')
202
+ super(description)
203
+ @klass = klass
204
+ end
205
+
206
+ def object_klass
207
+ @klass
208
+ end
209
+
210
+ end
211
+
212
+ def self.define_missing_type_mapping(klass, ivar_name, value, mappings)
213
+ message = "No type mapping for #{klass}@#{ivar_name} = #{value}!"
214
+ DeepSecurity::Manager.current.logger.warn(message)
215
+ mappings[ivar_name] = MissingMapping.new(message)
216
+ end
217
+
218
+ end
@@ -0,0 +1,7 @@
1
+ # @author Udo Schneider <Udo.Schneider@homeaddress.de>
2
+
3
+ require "savon_helper/missing_type_mapping_exception"
4
+ # require "savon_helper/soap_exception"
5
+ require "savon_helper/type_mappings"
6
+ require "savon_helper/mapping_object"
7
+ require "savon_helper/caching_object"