march_hare 2.7.0-java → 2.8.0-java

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: 8a417da5f5c33e7afac262924967c49e0910c6a8
4
- data.tar.gz: 8bfcf751a299b57a60bf6bcd87260626ebc3d983
3
+ metadata.gz: 10b9d00ad30cfe685795276ba8bd53d6cc5af312
4
+ data.tar.gz: acc9c65925a91800f6a68a1732e15d52eda372ac
5
5
  SHA512:
6
- metadata.gz: f3af5dfa114500351fbaeece4d3d34cec7d73e5b6465880870d46cdef3ac9e25a0166a2fb6c884ae7ca9d9b3ece0871c9d3f98b85f5070f01b9c3aa7ca39bd71
7
- data.tar.gz: ab7451d9f4621f5da10264af369558b94968a5772af9af282b0a5d0ce27123011822a00823d297ee419d3603ad4aa14da83c09ec1c4a4ce50127093e09f0a95e
6
+ metadata.gz: 7ae3150965e1d9081ea8ff628fbb4ce23848c88a0fd5c1e28b992d6db54f8eea920e8d7775db8689afc886c3e4a48a0632765d7ce891db327f4731ecfe2b3070
7
+ data.tar.gz: 4572abefa55fec760696be30d3bad7707da9120b3e91e7c4ba7816bdf94f40823da08319f03523315f144f56dbaf8075915a2db224bb36a1c61a383c6f8cd73a
Binary file
@@ -151,6 +151,11 @@ module MarchHare
151
151
  alias id channel_number
152
152
  alias number channel_number
153
153
 
154
+ # @return [Boolean] true if the channel is open
155
+ def open?
156
+ @delegate.open?
157
+ end
158
+
154
159
  # Closes the channel.
155
160
  #
156
161
  # Closed channels can no longer be used. Closed channel id is
@@ -100,7 +100,7 @@ module MarchHare
100
100
  end
101
101
 
102
102
  def deliver(headers, message)
103
- if @callback_arity == 2
103
+ if @callback_arity == 2 or @callback_arity < 0
104
104
  @callback.call(headers, message)
105
105
  else
106
106
  @callback.call(message)
@@ -7,6 +7,11 @@ module MarchHare
7
7
  java_import com.rabbitmq.client.ConnectionFactory
8
8
  java_import com.rabbitmq.client.Connection
9
9
  java_import com.rabbitmq.client.BlockedListener
10
+ java_import com.rabbitmq.client.NullTrustManager
11
+
12
+ java_import javax.net.ssl.SSLContext
13
+ java_import javax.net.ssl.KeyManagerFactory
14
+ java_import java.security.KeyStore
10
15
 
11
16
  # Connection to a RabbitMQ node.
12
17
  #
@@ -64,6 +69,32 @@ module MarchHare
64
69
  when String then
65
70
  if options[:trust_manager]
66
71
  cf.use_ssl_protocol(tls, options[:trust_manager])
72
+ elsif (key_cert = tls_key_certificate_path_from(options)) && (key_cert_password = tls_key_certificate_password_from(options))
73
+ sslContext = SSLContext.get_instance(tls)
74
+ certificate_password = key_cert_password.to_java.to_char_array
75
+ begin
76
+ input_stream = File.new(key_cert).to_inputstream
77
+ key_store = KeyStore.get_instance('PKCS12')
78
+ key_store.load(input_stream, certificate_password)
79
+
80
+ key_manager_factory = KeyManagerFactory.get_instance("SunX509")
81
+ key_manager_factory.init(key_store, certificate_password)
82
+
83
+ key_managers = key_manager_factory.get_key_managers
84
+
85
+ sslContext.init(key_managers, [NullTrustManager.new].to_java('javax.net.ssl.TrustManager'), nil)
86
+
87
+ cf.use_ssl_protocol(sslContext)
88
+ # catch all exceptions from java
89
+ rescue Java::JavaLang::Exception => e
90
+ message = e.message
91
+ message << "\n"
92
+ message << e.backtrace.join("\n")
93
+
94
+ raise SSLContextException.new(message)
95
+ ensure
96
+ input_stream.close if input_stream
97
+ end
67
98
  else
68
99
  cf.use_ssl_protocol(tls)
69
100
  end
@@ -73,6 +104,11 @@ module MarchHare
73
104
  new(cf, options)
74
105
  end
75
106
 
107
+
108
+ class SSLContextException < StandardError
109
+ end
110
+
111
+
76
112
  # @return [Array<MarchHare::Channel>] Channels opened on this connection
77
113
  attr_reader :channels
78
114
 
@@ -444,6 +480,16 @@ module MarchHare
444
480
  end
445
481
  end
446
482
 
483
+ # @private
484
+ def tls_key_certificate_path_from(opts)
485
+ opts[:tls_key_cert] || opts[:ssl_key_cert] || opts[:tls_key_cert_path] || opts[:ssl_key_cert_path] || opts[:tls_key_certificate_path] || opts[:ssl_key_certificate_path]
486
+ end
487
+
488
+ # @private
489
+ def tls_key_certificate_password_from(opts)
490
+ opts[:cert_password] || opts[:certificate_password]
491
+ end
492
+
447
493
  # Ruby blocks-based BlockedListener that handles
448
494
  # connection.blocked and connection.unblocked.
449
495
  # @private
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module MarchHare
4
- VERSION = "2.7.0"
4
+ VERSION = "2.8.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: march_hare
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: java
6
6
  authors:
7
7
  - Theo Hultberg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-04 00:00:00.000000000 Z
12
+ date: 2015-01-31 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: RabbitMQ client for JRuby built around the official RabbitMQ Java client
15
15
  email:
@@ -60,4 +60,3 @@ signing_key:
60
60
  specification_version: 4
61
61
  summary: RabbitMQ client for JRuby built around the official RabbitMQ Java client
62
62
  test_files: []
63
- has_rdoc: