qpid_proton 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/core/message.rb CHANGED
@@ -129,13 +129,13 @@ module Qpid::Proton
129
129
  end
130
130
 
131
131
  # Creates a new +Message+ instance.
132
- def initialize
132
+ def initialize(body = nil)
133
133
  @impl = Cproton.pn_message
134
134
  ObjectSpace.define_finalizer(self, self.class.finalize!(@impl))
135
135
  @properties = {}
136
136
  @instructions = {}
137
137
  @annotations = {}
138
- @body = nil
138
+ self.body = body unless body.nil?
139
139
  end
140
140
 
141
141
  def to_s
@@ -224,7 +224,7 @@ module Qpid::Proton
224
224
  # * priority - the priority value
225
225
  #
226
226
  def priority=(priority)
227
- raise TypeError.new("invalid priority: #{priority}") if priority.nil? || !([Float, Fixnum].include?(priority.class))
227
+ raise TypeError.new("invalid priority: #{priority}") if not priority.is_a?(Numeric)
228
228
  raise RangeError.new("priority out of range: #{priority}") if ((priority > 255) || (priority < 0))
229
229
  Cproton.pn_message_set_priority(@impl, priority.floor)
230
230
  end
@@ -242,8 +242,8 @@ module Qpid::Proton
242
242
  # * time - the time in milliseconds
243
243
  #
244
244
  def ttl=(time)
245
- raise TypeError.new("invalid ttl: #{time}") if time.nil? || !([Float, Fixnum].include?(time.class))
246
- raise RangeError.new("time out of range: #{time}") if ((time < 0))
245
+ raise TypeError.new("invalid ttl: #{time}") if not time.is_a?(Numeric)
246
+ raise RangeError.new("ttl out of range: #{time}") if ((time.to_i < 0))
247
247
  Cproton.pn_message_set_ttl(@impl, time.floor)
248
248
  end
249
249
 
@@ -275,9 +275,8 @@ module Qpid::Proton
275
275
  # * count - the delivery count
276
276
  #
277
277
  def delivery_count=(count)
278
- raise ::ArgumentError.new("invalid count: #{count}") if count.nil? || !([Float, Fixnum].include?(count.class))
278
+ raise ::ArgumentError.new("invalid count: #{count}") if not count.is_a?(Numeric)
279
279
  raise RangeError.new("count out of range: #{count}") if count < 0
280
-
281
280
  Cproton.pn_message_set_delivery_count(@impl, count.floor)
282
281
  end
283
282
 
@@ -408,24 +407,12 @@ module Qpid::Proton
408
407
  Cproton.pn_message_get_content_type(@impl)
409
408
  end
410
409
 
411
- # Sets the message content.
412
- #
413
- # *WARNING:* This method has been deprecated. Please use #body= instead to
414
- # set the content of a message.
415
- #
416
- # ==== Options
417
- #
418
- # * content - the content
419
- #
410
+ # @deprecated use {#body=}
420
411
  def content=(content)
421
412
  Cproton.pn_message_load(@impl, content)
422
413
  end
423
414
 
424
- # Returns the message content.
425
- #
426
- # *WARNING:* This method has been deprecated. Please use #body instead to
427
- # retrieve the content of a message.
428
- #
415
+ # @deprecated use {#body}
429
416
  def content
430
417
  size = 16
431
418
  loop do
data/lib/core/receiver.rb CHANGED
@@ -58,7 +58,7 @@ module Qpid::Proton
58
58
 
59
59
  # Grants credit for incoming deliveries.
60
60
  #
61
- # @param n [Fixnum] The amount to increment the link credit.
61
+ # @param n [Integer] The amount to increment the link credit.
62
62
  #
63
63
  def flow(n)
64
64
  Cproton.pn_link_flow(@impl, n)
@@ -74,9 +74,9 @@ module Qpid::Proton
74
74
  # #receive until nil is returned, or verify that #partial? is false and
75
75
  # Delivery#pending is 0.
76
76
  #
77
- # @param limit [Fixnum] The maximum bytes to receive.
77
+ # @param limit [Integer] The maximum bytes to receive.
78
78
  #
79
- # @return [Fixnum, nil] The number of bytes received, or nil if the end of
79
+ # @return [Integer, nil] The number of bytes received, or nil if the end of
80
80
  # the stream was reached.t
81
81
  #
82
82
  # @see Deliver#pending To see how much buffer space is needed.
data/lib/core/sasl.rb CHANGED
@@ -28,19 +28,7 @@ module Qpid::Proton
28
28
  # The peer acting as the SASL server must provide authentication against the
29
29
  # received credentials.
30
30
  #
31
- # @example
32
- # # SCENARIO: the remote endpoint has not initialized their connection
33
- # # then the local endpoint, acting as a SASL server, decides
34
- # # to allow an anonymous connection.
35
- # #
36
- # # The SASL layer locally assumes the role of server and then
37
- # # enables anonymous authentication for the remote endpoint.
38
- # #
39
- # sasl = @transport.sasl
40
- # sasl.server
41
- # sasl.mechanisms("ANONYMOUS")
42
- # sasl.done(Qpid::Proton::SASL::OK)
43
- #
31
+ # @note Do not instantiate directly, use {Transport#sasl} to create a SASL object.
44
32
  class SASL
45
33
 
46
34
  # Negotation has not completed.
@@ -50,45 +38,89 @@ module Qpid::Proton
50
38
  # Authentication failed due to bad credentials.
51
39
  AUTH = Cproton::PN_SASL_AUTH
52
40
 
53
- # Constructs a new instance for the given transport.
54
- #
55
- # @param transport [Transport] The transport.
56
- #
57
- # @private A SASL should be fetched only from its Transport
58
- #
41
+ private
42
+
43
+ include Util::SwigHelper
44
+ PROTON_METHOD_PREFIX = "pn_sasl"
45
+
46
+ public
47
+
48
+ # @private
49
+ # @note Do not instantiate directly, use {Transport#sasl} to create a SASL object.
59
50
  def initialize(transport)
60
51
  @impl = Cproton.pn_sasl(transport.impl)
61
52
  end
62
53
 
63
- # Sets the acceptable SASL mechanisms.
54
+ # @!attribute allow_insecure_mechs
55
+ # @return [Bool] true if clear text authentication is allowed on insecure connections.
56
+ proton_accessor :allow_insecure_mechs
57
+
58
+ # @!attribute user [r]
59
+ # @return [String] the authenticated user name
60
+ proton_reader :user
61
+
62
+ # Set the mechanisms allowed for SASL negotation
63
+ # @param mechanisms [String] space-delimited list of allowed mechanisms
64
+ def allowed_mechs=(mechanisms)
65
+ Cproton.pn_sasl_allowed_mechs(@impl, mechanisms)
66
+ end
67
+
68
+ # @deprecated use {#allowed_mechs=}
69
+ def mechanisms(m)
70
+ self.allowed_mechs = m
71
+ end
72
+
73
+ # True if extended SASL negotiation is supported
64
74
  #
65
- # @param mechanisms [String] The space-delimited set of mechanisms.
75
+ # All implementations of Proton support ANONYMOUS and EXTERNAL on both
76
+ # client and server sides and PLAIN on the client side.
66
77
  #
67
- # @example Use anonymous SASL authentication.
68
- # @sasl.mechanisms("GSSAPI CRAM-MD5 PLAIN")
78
+ # Extended SASL implememtations use an external library (Cyrus SASL)
79
+ # to support other mechanisms.
69
80
  #
70
- def mechanisms(mechanisms)
71
- Cproton.pn_sasl_mechanisms(@impl, mechanisms)
81
+ # @return [Bool] true if extended SASL negotiation is supported
82
+ def self.extended?()
83
+ Cproton.pn_sasl_extended()
72
84
  end
73
85
 
74
- # Returns the outcome of the SASL negotiation.
86
+ # Set the sasl configuration path
87
+ #
88
+ # This is used to tell SASL where to look for the configuration file.
89
+ # In the current implementation it can be a colon separated list of directories.
90
+ #
91
+ # The environment variable PN_SASL_CONFIG_PATH can also be used to set this path,
92
+ # but if both methods are used then this pn_sasl_config_path() will take precedence.
93
+ #
94
+ # If not set the underlying implementation default will be used.
75
95
  #
76
- # @return [Fixnum] The outcome.
96
+ # @param path the configuration path
77
97
  #
78
- def outcome
79
- outcome = Cprotn.pn_sasl_outcome(@impl)
80
- return nil if outcome == NONE
81
- outcome
98
+ def self.config_path=(path)
99
+ Cproton.pn_sasl_config_path(nil, path)
100
+ path
82
101
  end
83
102
 
84
- # Set the condition of the SASL negotiation.
103
+ # @deprecated use {config_path=}
104
+ def self.config_path(path)
105
+ self.config_path = path
106
+ end
107
+
108
+ # Set the configuration file name, without extension
109
+ #
110
+ # The name with an a ".conf" extension will be searched for in the
111
+ # configuration path. If not set, it defaults to "proton-server" or
112
+ # "proton-client" for a server (incoming) or client (outgoing) connection
113
+ # respectively.
85
114
  #
86
- # @param outcome [Fixnum] The outcome.
115
+ # @param name the configuration file name without extension
87
116
  #
88
- def done(outcome)
89
- Cproton.pn_sasl_done(@impl, outcome)
117
+ def self.config_name=(name)
118
+ Cproton.pn_sasl_config_name(nil, name)
90
119
  end
91
120
 
121
+ # @deprecated use {config_name=}
122
+ def self.config_name(name)
123
+ self.config_name = name
124
+ end
92
125
  end
93
-
94
126
  end
data/lib/core/sender.rb CHANGED
@@ -33,7 +33,7 @@ module Qpid::Proton
33
33
 
34
34
  # Signals the availability of deliveries.
35
35
  #
36
- # @param n [Fixnum] The number of deliveries potentially available.
36
+ # @param n [Integer] The number of deliveries potentially available.
37
37
  #
38
38
  def offered(n)
39
39
  Cproton.pn_link_offered(@impl, n)
@@ -44,7 +44,7 @@ module Qpid::Proton
44
44
  # @param object [Object] The content to send.
45
45
  # @param tag [Object] The tag
46
46
  #
47
- # @return [Fixnum] The number of bytes sent.
47
+ # @return [Integer] The number of bytes sent.
48
48
  #
49
49
  def send(object, tag = nil)
50
50
  if object.respond_to? :proton_send
@@ -58,7 +58,7 @@ module Qpid::Proton
58
58
  #
59
59
  # @param bytes [Array] The bytes to send.
60
60
  #
61
- # @return n [Fixnum] The number of bytes sent.
61
+ # @return [Integer] The number of bytes sent.
62
62
  #
63
63
  def stream(bytes)
64
64
  Cproton.pn_link_send(@impl, bytes)
data/lib/core/session.rb CHANGED
@@ -41,7 +41,7 @@ module Qpid::Proton
41
41
  # negotatied frame size of the transport, it will be rounded up to one full
42
42
  # frame.
43
43
  #
44
- # @return [Fixnum] The incoing capacity of the session, measured in bytes.
44
+ # @return [Integer] The incoing capacity of the session, measured in bytes.
45
45
  #
46
46
  proton_accessor :incoming_capacity
47
47
 
@@ -50,13 +50,13 @@ module Qpid::Proton
50
50
 
51
51
  # @!attribute [r] outgoing_bytes
52
52
  #
53
- # @return [Fixnum] The number of outgoing bytes currently being buffered.
53
+ # @return [Integer] The number of outgoing bytes currently being buffered.
54
54
  #
55
55
  proton_caller :outgoing_bytes
56
56
 
57
57
  # @!attribute [r] incoming_bytes
58
58
  #
59
- # @return [Fixnum] The number of incomign bytes currently being buffered.
59
+ # @return [Integer] The number of incomign bytes currently being buffered.
60
60
  #
61
61
  proton_caller :incoming_bytes
62
62
 
@@ -71,7 +71,7 @@ module Qpid::Proton
71
71
 
72
72
  # @!attribute [r] state
73
73
  #
74
- # @return [Fixnum] The endpoint state.
74
+ # @return [Integer] The endpoint state.
75
75
  #
76
76
  proton_caller :state
77
77
 
@@ -104,7 +104,7 @@ module Qpid::Proton
104
104
  # When uses with Connection#session_head an application can access all of
105
105
  # the session son the connection that match the given state.
106
106
  #
107
- # @param state_mask [Fixnum] The state mask to match.
107
+ # @param state_mask [Integer] The state mask to match.
108
108
  #
109
109
  # @return [Session, nil] The next session if one matches, or nil.
110
110
  #
@@ -123,7 +123,7 @@ module Qpid::Proton
123
123
  # call returns. SSL instances created before invoking this method will use
124
124
  # the domain's previous setting.
125
125
  #
126
- # @param verify_mode [Fixnum] The level of validation to apply to the peer.
126
+ # @param verify_mode [Integer] The level of validation to apply to the peer.
127
127
  # @param trusted_CAs [String] The path to a database of trusted CAs that
128
128
  # the server will advertise to the peer client if the server has been
129
129
  # configured to verify its peer.
data/lib/core/terminus.rb CHANGED
@@ -73,7 +73,7 @@ module Qpid::Proton
73
73
 
74
74
  # @!attribute type
75
75
  #
76
- # @return [Fixnum] The terminus type.
76
+ # @return [Integer] The terminus type.
77
77
  #
78
78
  # @see SOURCE
79
79
  # @see TARGET
@@ -89,7 +89,7 @@ module Qpid::Proton
89
89
 
90
90
  # @!attribute durability
91
91
  #
92
- # @return [Fixnum] The durability mode of the terminus.
92
+ # @return [Integer] The durability mode of the terminus.
93
93
  #
94
94
  # @see NONDURABLE
95
95
  # @see CONFIGURATION
@@ -99,7 +99,7 @@ module Qpid::Proton
99
99
 
100
100
  # @!attribute expiry_policy
101
101
  #
102
- # @return [Fixnum] The expiry policy.
102
+ # @return [Integer] The expiry policy.
103
103
  #
104
104
  # @see EXPIRE_WITH_LINK
105
105
  # @see EXPIRE_WITH_SESSION
@@ -110,7 +110,7 @@ module Qpid::Proton
110
110
 
111
111
  # @!attribute timeout
112
112
  #
113
- # @return [Fixnum] The timeout period.
113
+ # @return [Integer] The timeout period.
114
114
  #
115
115
  proton_accessor :timeout
116
116
 
@@ -122,7 +122,7 @@ module Qpid::Proton
122
122
 
123
123
  # @!attribute distribution_mode
124
124
  #
125
- # @return [Fixnum] The distribution mode.
125
+ # @return [Integer] The distribution mode.
126
126
  #
127
127
  # @see DIST_MODE_UNSPECIFIED
128
128
  # @see DIST_MODE_COPY
@@ -89,37 +89,37 @@ module Qpid::Proton
89
89
 
90
90
  # @!attribute channel_max
91
91
  #
92
- # @return [Fixnum] The maximum allowed channel.
92
+ # @return [Integer] The maximum allowed channel.
93
93
  #
94
94
  proton_accessor :channel_max
95
95
 
96
96
  # @!attribute [r] remote_channel_max
97
97
  #
98
- # @return [Fixnum] The maximum allowed channel of a transport's remote peer.
98
+ # @return [Integer] The maximum allowed channel of a transport's remote peer.
99
99
  #
100
100
  proton_caller :remote_channel_max
101
101
 
102
102
  # @!attribute max_frame_size
103
103
  #
104
- # @return [Fixnum] The maximum frame size.
104
+ # @return [Integer] The maximum frame size.
105
105
  #
106
106
  proton_accessor :max_frame_size
107
107
 
108
108
  # @!attribute [r] remote_max_frame_size
109
109
  #
110
- # @return [Fixnum] The maximum frame size of the transport's remote peer.
110
+ # @return [Integer] The maximum frame size of the transport's remote peer.
111
111
  #
112
112
  proton_reader :remote_max_frame_size
113
113
 
114
114
  # @!attribute idle_timeout
115
115
  #
116
- # @return [Fixnum] The idle timeout.
116
+ # @return [Integer] The idle timeout.
117
117
  #
118
118
  proton_accessor :idle_timeout
119
119
 
120
120
  # @!attribute [r] remote_idle_timeout
121
121
  #
122
- # @return [Fixnum] The idle timeout for the transport's remote peer.
122
+ # @return [Integer] The idle timeout for the transport's remote peer.
123
123
  #
124
124
  proton_accessor :remote_idle_timeout
125
125
 
@@ -135,7 +135,7 @@ module Qpid::Proton
135
135
  # Calls to #process may alter the value of this value. See #process for
136
136
  # more details
137
137
  #
138
- # @return [Fixnum] The amount of free space for input following the
138
+ # @return [Integer] The amount of free space for input following the
139
139
  # transport's tail pointer.
140
140
  #
141
141
  proton_caller :capacity
@@ -170,7 +170,7 @@ module Qpid::Proton
170
170
  #
171
171
  # Calls to #pop may alter the value of this pointer as well.
172
172
  #
173
- # @return [Fixnum] The number of pending output bytes following the header
173
+ # @return [Integer] The number of pending output bytes following the header
174
174
  # pointer.
175
175
  #
176
176
  # @raise [TransportError] If any error other than an end of stream occurs.
@@ -188,13 +188,13 @@ module Qpid::Proton
188
188
 
189
189
  # @!attribute [r] frames_output
190
190
  #
191
- # @return [Fixnum] The number of frames output by a transport.
191
+ # @return [Integer] The number of frames output by a transport.
192
192
  #
193
193
  proton_reader :frames_output
194
194
 
195
195
  # @!attribute [r] frames_input
196
196
  #
197
- # @return [Fixnum] The number of frames input by a transport.
197
+ # @return [Integer] The number of frames input by a transport.
198
198
  #
199
199
  proton_reader :frames_input
200
200
 
@@ -218,7 +218,7 @@ module Qpid::Proton
218
218
 
219
219
  # Creates a new transport instance.
220
220
  #
221
- # @param mode [Fixnum] The transport mode, either CLIENT or SERVER
221
+ # @param mode [Integer] The transport mode, either CLIENT or SERVER
222
222
  # @param impl [pn_transport_t] Should not be used.
223
223
  #
224
224
  # @raise [TransportError] If the mode is invalid.
@@ -268,7 +268,7 @@ module Qpid::Proton
268
268
 
269
269
  # Updates the transports trace flags.
270
270
  #
271
- # @param level [Fixnum] The trace level.
271
+ # @param level [Integer] The trace level.
272
272
  #
273
273
  # @see TRACE_OFF
274
274
  # @see TRACE_RAW
@@ -302,7 +302,7 @@ module Qpid::Proton
302
302
  #
303
303
  # @param data [String] The bytes to be pushed.
304
304
  #
305
- # @return [Fixnum] The number of bytes pushed.
305
+ # @return [Integer] The number of bytes pushed.
306
306
  #
307
307
  def push(data)
308
308
  Cproton.pn_transport_push(@impl, data, data.length)
@@ -315,7 +315,7 @@ module Qpid::Proton
315
315
  # pointer. It may also change the value for #tail, as well as the amount of
316
316
  # free space reported by #capacity.
317
317
  #
318
- # @param size [Fixnum] The number of bytes to process.
318
+ # @param size [Integer] The number of bytes to process.
319
319
  #
320
320
  # @raise [TransportError] If an error occurs.
321
321
  #
@@ -335,7 +335,7 @@ module Qpid::Proton
335
335
 
336
336
  # Returns the specified number of bytes from the transport's buffers.
337
337
  #
338
- # @param size [Fixnum] The number of bytes to return.
338
+ # @param size [Integer] The number of bytes to return.
339
339
  #
340
340
  # @return [String] The data peeked.
341
341
  #
@@ -351,7 +351,7 @@ module Qpid::Proton
351
351
  # Removes the specified number of bytes from the pending output queue
352
352
  # following the transport's head pointer.
353
353
  #
354
- # @param size [Fixnum] The number of bytes to remove.
354
+ # @param size [Integer] The number of bytes to remove.
355
355
  #
356
356
  def pop(size)
357
357
  Cproton.pn_transport_pop(@impl, size)
@@ -378,7 +378,7 @@ module Qpid::Proton
378
378
  #
379
379
  # @param now [Time] The timestamp.
380
380
  #
381
- # @return [Fixnum] If non-zero, the expiration time of the next pending
381
+ # @return [Integer] If non-zero, the expiration time of the next pending
382
382
  # timer event for the transport. The caller must invoke #tick again at
383
383
  # least once at or before this deadline occurs.
384
384
  #
@@ -386,6 +386,8 @@ module Qpid::Proton
386
386
  Cproton.pn_transport_tick(@impl, now)
387
387
  end
388
388
 
389
+ # Create, or return existing, SSL object for the transport.
390
+ # @return [SASL] the SASL object
389
391
  def sasl
390
392
  SASL.new(self)
391
393
  end