eventq_base 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c1b3f6785269f9bfa925441e6b0df5ccc7a397e
4
- data.tar.gz: f596b8f09b17d58ef4aa4174de42372af151f91f
3
+ metadata.gz: 55bfca8c289dc31fe34c656dd219688618f8bc9b
4
+ data.tar.gz: 5f5ba0d0cc0ba58d448156b4644f0cfbb31424c0
5
5
  SHA512:
6
- metadata.gz: 836b0ac42d91d6f49e2bd6fe4876a331e994ee54b44382a0380d7ba93b9e687d6dc59e89928a70f2aab839c0eb6da40a073ecc9684cbac044fc8088ca697b7ef
7
- data.tar.gz: 2db1a11ba4367132bd5b5fc1bc7d3fa613a97098129e7a29b895be5823b90a0d212a6eab56422494c170c4ef7f344a720c4bbca436238753722196fc2fe9dbbb
6
+ metadata.gz: cc507cd5ccfaa243784e918fa205b00a1f2f97bc3c6a82d4ee6d4ee16f3bf114f7ed72ede9a01bb314a37011181a0aa7bcfe3b97ef934c97bff06e98bf58f723
7
+ data.tar.gz: 5a1985feb73bddebe473e31cd31f905364a3378806cc603a29d472eb535133ffd6203bbb54e582e473dec7363713e9bd158d89f44f3ae1e3588b5aaf4241c4dc
data/lib/eventq_base.rb CHANGED
@@ -20,4 +20,5 @@ require_relative 'eventq_base/serialization_providers'
20
20
  require_relative 'eventq_base/worker_id'
21
21
  require_relative 'eventq_base/nonce_manager'
22
22
  require_relative 'eventq_base/signature_providers'
23
+ require_relative 'eventq_base/exceptions'
23
24
 
@@ -0,0 +1 @@
1
+ require_relative 'exceptions/invalid_signature_exception'
@@ -0,0 +1,9 @@
1
+ module EventQ
2
+ module Exceptions
3
+ class InvalidSignatureException < StandardError
4
+ def initialize(message = "Invalid message signature.")
5
+ super(message)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -10,8 +10,8 @@ module EventQ
10
10
  class Manager
11
11
  def initialize
12
12
  @providers = {}
13
- @providers[OJ_PROVIDER] = EventQ::SerializationProviders::OjSerializationProvider.new
14
- @providers[JSON_PROVIDER] = EventQ::SerializationProviders::JsonSerializationProvider.new
13
+ @providers[OJ_PROVIDER] = EventQ::SerializationProviders::OjSerializationProvider
14
+ @providers[JSON_PROVIDER] = EventQ::SerializationProviders::JsonSerializationProvider
15
15
  end
16
16
 
17
17
  def get_provider(provider_type)
@@ -19,7 +19,7 @@ module EventQ
19
19
  if provider == nil
20
20
  raise "Invalid provider type specified: #{provider_type}"
21
21
  end
22
- return provider
22
+ return provider.new
23
23
  end
24
24
  end
25
25
  end
@@ -11,6 +11,7 @@ module EventQ
11
11
  @providers[SHA256] = EventQ::SignatureProviders::Sha256SignatureProvider
12
12
  end
13
13
 
14
+ #This method is called to get a signature provider
14
15
  def get_provider(provider_type)
15
16
  provider = @providers[provider_type]
16
17
  if provider == nil
@@ -18,6 +19,26 @@ module EventQ
18
19
  end
19
20
  return provider.new
20
21
  end
22
+
23
+ #This method is called to validate a queue message's signature
24
+ def validate_signature(message:, queue:)
25
+ valid = true
26
+
27
+ if queue.require_signature == true && message.signature == nil
28
+ valid = false
29
+ elsif message.signature != nil
30
+ provider = get_provider(EventQ::Configuration.signature_provider)
31
+ valid = provider.valid?(message: message, secret: EventQ::Configuration.signature_secret)
32
+ end
33
+
34
+ if !valid
35
+ raise EventQ::Exceptions::InvalidSignatureException.new
36
+ end
37
+
38
+ true
39
+
40
+ end
41
+
21
42
  end
22
43
  end
23
44
  end
@@ -1,3 +1,3 @@
1
1
  module EventqBase
2
- VERSION = "1.10.0"
2
+ VERSION = "1.11.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventq_base
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
@@ -166,6 +166,8 @@ files:
166
166
  - lib/eventq_base/event_raised_queue.rb
167
167
  - lib/eventq_base/eventq_client_contract.rb
168
168
  - lib/eventq_base/eventq_logger.rb
169
+ - lib/eventq_base/exceptions.rb
170
+ - lib/eventq_base/exceptions/invalid_signature_exception.rb
169
171
  - lib/eventq_base/exchange.rb
170
172
  - lib/eventq_base/message_args.rb
171
173
  - lib/eventq_base/nonce_manager.rb