stomp 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +13 -0
- data/README.md +96 -100
- data/examples/EXAMPLES.md +251 -0
- data/examples/amqdurasub.rb +14 -17
- data/examples/artemis/cliwaiter_not_reliable.rb +12 -5
- data/examples/artemis/{cliwaiter_reliable.rb → cliwaiter_reliable_hb.rb} +24 -23
- data/examples/client_conndisc.rb +66 -0
- data/examples/client_putget.rb +94 -0
- data/examples/conn_conndisc.rb +102 -0
- data/examples/conn_putget.rb +124 -0
- data/examples/contrib.sh +2 -3
- data/examples/contributors.rb +26 -14
- data/examples/examplogger.rb +1 -1
- data/examples/{consumer.rb → historical/consumer.rb} +0 -0
- data/examples/{publisher.rb → historical/publisher.rb} +0 -0
- data/examples/{topic_consumer.rb → historical/topic_consumer.rb} +0 -0
- data/examples/{topic_publisher.rb → historical/topic_publisher.rb} +0 -0
- data/examples/logexamp.rb +23 -14
- data/examples/putget_file.rb +79 -0
- data/examples/{putget11_rh1.rb → putget_rephdrs.rb} +16 -15
- data/examples/ssl/SSL.md +189 -0
- data/examples/{ssl_ctxoptions.rb → ssl/misc/ssl_ctxoptions.rb} +23 -14
- data/examples/ssl/misc/ssl_newparm.rb +53 -0
- data/examples/ssl/misc/ssl_ucx_default_ciphers.rb +54 -0
- data/examples/ssl/ssl_common.rb +96 -0
- data/examples/ssl/sslexall.sh +17 -0
- data/examples/{ssl_uc1.rb → ssl/uc1/ssl_uc1.rb} +15 -11
- data/examples/ssl/uc1/ssl_uc1_ciphers.rb +60 -0
- data/examples/{ssl_uc2.rb → ssl/uc2/ssl_uc2.rb} +17 -10
- data/examples/ssl/uc2/ssl_uc2_ciphers.rb +67 -0
- data/examples/{ssl_uc3.rb → ssl/uc3/ssl_uc3.rb} +15 -16
- data/examples/ssl/uc3/ssl_uc3_ciphers.rb +65 -0
- data/examples/{ssl_uc4.rb → ssl/uc4/ssl_uc4.rb} +15 -15
- data/examples/ssl/uc4/ssl_uc4_ciphers.rb +66 -0
- data/examples/stomp_common.rb +97 -0
- data/lib/connection/netio.rb +83 -37
- data/lib/connection/utf8.rb +0 -7
- data/lib/connection/utils.rb +4 -1
- data/lib/stomp/client.rb +5 -1
- data/lib/stomp/connection.rb +25 -15
- data/lib/stomp/constants.rb +109 -0
- data/lib/stomp/errors.rb +11 -0
- data/lib/stomp/sslparams.rb +3 -4
- data/lib/stomp/version.rb +2 -2
- data/stomp.gemspec +31 -37
- data/test/test_anonymous.rb +4 -0
- data/test/test_client.rb +2 -0
- data/test/test_connection.rb +4 -0
- data/test/test_connection1p.rb +2 -4
- data/test/test_helper.rb +11 -0
- metadata +30 -36
- data/examples/artemis/artlogger.rb +0 -41
- data/examples/client11_ex1.rb +0 -89
- data/examples/client11_putget1.rb +0 -71
- data/examples/conn11_ex1.rb +0 -112
- data/examples/conn11_ex2.rb +0 -87
- data/examples/conn11_hb1.rb +0 -57
- data/examples/consume_file.rb +0 -63
- data/examples/get11conn_ex1.rb +0 -117
- data/examples/get11conn_ex2.rb +0 -77
- data/examples/lflogger.rb +0 -316
- data/examples/logexamp_ssl.rb +0 -81
- data/examples/publish_file.rb +0 -76
- data/examples/publish_file_conn.rb +0 -75
- data/examples/put11conn_ex1.rb +0 -56
- data/examples/ssl_common.rb +0 -73
- data/examples/ssl_newparm.rb +0 -43
- data/examples/ssl_uc1_ciphers.rb +0 -53
- data/examples/ssl_uc2_ciphers.rb +0 -60
- data/examples/ssl_uc3_ciphers.rb +0 -64
- data/examples/ssl_uc4_ciphers.rb +0 -65
- data/examples/ssl_ucx_default_ciphers.rb +0 -41
- data/examples/stomp11_common.rb +0 -54
data/examples/logexamp_ssl.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'stomp'
|
5
|
-
require 'logger' # for the 'local' logger
|
6
|
-
#
|
7
|
-
if Kernel.respond_to?(:require_relative)
|
8
|
-
require_relative("./examplogger")
|
9
|
-
else
|
10
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "examplogger"
|
12
|
-
end
|
13
|
-
#
|
14
|
-
# == A STOMP::Connection program which uses the callback logging facility.
|
15
|
-
#
|
16
|
-
class SSLLoggerExample
|
17
|
-
# Initialize.
|
18
|
-
def initialize
|
19
|
-
end
|
20
|
-
# Run example.
|
21
|
-
def run
|
22
|
-
llog = Logger::new(STDOUT)
|
23
|
-
llog.level = Logger::DEBUG
|
24
|
-
llog.debug "LESSL Starting"
|
25
|
-
|
26
|
-
# //////////////////////////////////////////////////////////////////////////////
|
27
|
-
mylog = Slogger::new # The client provided STOMP callback logger
|
28
|
-
|
29
|
-
# //////////////////////////////////////////////////////////////////////////////
|
30
|
-
user = ENV['STOMP_USER'] ? ENV['STOMP_USER'] : 'guest'
|
31
|
-
password = ENV['STOMP_PASSWORD'] ? ENV['STOMP_PASSWORD'] : 'guest'
|
32
|
-
host = ENV['STOMP_HOST'] ? ENV['STOMP_HOST'] : 'localhost'
|
33
|
-
port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61612
|
34
|
-
# //////////////////////////////////////////////////////////////////////////////
|
35
|
-
# A hash type connect *MUST* be used to enable callback logging.
|
36
|
-
# //////////////////////////////////////////////////////////////////////////////
|
37
|
-
hash = { :hosts => [
|
38
|
-
{:login => user, :passcode => password, :host => host, :port => port,
|
39
|
-
:ssl => true}, # Or provide your insance of SSLParams instead
|
40
|
-
],
|
41
|
-
:logger => mylog, # This enables callback logging!
|
42
|
-
:max_reconnect_attempts => 2,
|
43
|
-
}
|
44
|
-
|
45
|
-
# //////////////////////////////////////////////////////////////////////////////
|
46
|
-
# For a Connection:
|
47
|
-
llog.debug "LESSL Connection processing starts"
|
48
|
-
conn = Stomp::Connection.new(hash)
|
49
|
-
conn.disconnect
|
50
|
-
# //////////////////////////////////////////////////////////////////////////////
|
51
|
-
llog.debug "LESSL Connection processing complete"
|
52
|
-
|
53
|
-
# //////////////////////////////////////////////////////////////////////////////
|
54
|
-
# For a Client:
|
55
|
-
llog.debug "LESSL Client processing starts"
|
56
|
-
conn = Stomp::Client.new(hash)
|
57
|
-
conn.close
|
58
|
-
# //////////////////////////////////////////////////////////////////////////////
|
59
|
-
llog.debug "LESSL Client processing complete"
|
60
|
-
|
61
|
-
# //////////////////////////////////////////////////////////////////////////////
|
62
|
-
# For a Connection with other calls:
|
63
|
-
llog.debug "LESSL Connection Enhanced processing starts"
|
64
|
-
conn = Stomp::Connection.new(hash)
|
65
|
-
#
|
66
|
-
dest = "/queue/loggerq1"
|
67
|
-
conn.publish dest, "a logger message"
|
68
|
-
conn.subscribe dest
|
69
|
-
msg = conn.receive
|
70
|
-
conn.disconnect
|
71
|
-
# //////////////////////////////////////////////////////////////////////////////
|
72
|
-
llog.debug "LESSL Connection Enhanced processing complete"
|
73
|
-
|
74
|
-
# //////////////////////////////////////////////////////////////////////////////
|
75
|
-
llog.debug "LESSL Ending"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
#
|
79
|
-
e = SSLLoggerExample.new
|
80
|
-
e.run
|
81
|
-
|
data/examples/publish_file.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'stomp'
|
5
|
-
|
6
|
-
if Kernel.respond_to?(:require_relative)
|
7
|
-
require_relative("./stomp11_common")
|
8
|
-
require_relative("./lflogger")
|
9
|
-
else
|
10
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "stomp11_common"
|
12
|
-
require "./lflogger"
|
13
|
-
end
|
14
|
-
include Stomp11Common
|
15
|
-
#
|
16
|
-
# Used primarily for testing performance when sending "large" messages.
|
17
|
-
# "large" => YMMV
|
18
|
-
#
|
19
|
-
class FileSender
|
20
|
-
# Initialize.
|
21
|
-
def initialize
|
22
|
-
end
|
23
|
-
# Run example.
|
24
|
-
def run
|
25
|
-
p [ "pub001", Thread.current ]
|
26
|
-
publogger = Slogger::new
|
27
|
-
start_time = Time.now.to_f
|
28
|
-
fname = ARGV[0]
|
29
|
-
puts "PUBF: File Name: #{fname}"
|
30
|
-
file = open(fname, "r")
|
31
|
-
rs = Time.now.to_f
|
32
|
-
buff = file.read
|
33
|
-
re = Time.now.to_f
|
34
|
-
ppt = sprintf("%20.6f", re - rs)
|
35
|
-
puts "PUBF: File size: #{buff.respond_to?(:bytesize) ? buff.bytesize : buff.length}"
|
36
|
-
puts "PUBF: File read: #{ppt} seconds"
|
37
|
-
file.close
|
38
|
-
#
|
39
|
-
client_hdrs = {"accept-version" => "1.1",
|
40
|
-
"host" => virt_host(),
|
41
|
-
}
|
42
|
-
client_hash = { :hosts => [
|
43
|
-
{:login => login(), :passcode => passcode(),
|
44
|
-
:host => host(), :port => port()},
|
45
|
-
],
|
46
|
-
:connect_headers => client_hdrs,
|
47
|
-
:logger => publogger,
|
48
|
-
:reliable => false, ### *NOTE*
|
49
|
-
}
|
50
|
-
#
|
51
|
-
# p [ "ch", client_hash ]
|
52
|
-
client = Stomp::Client.new(client_hash)
|
53
|
-
qname = ENV['STOMP_DEST'] ? ENV['STOMP_DEST'] : "/queue/a.big.file"
|
54
|
-
puts "PUBF: Qname is: #{qname}"
|
55
|
-
# Try to gracefully handle files that exceed broker size limits.
|
56
|
-
ph = {:presistent => true}
|
57
|
-
ph['suppress_content_length'] = 'yes' if suppresscl()
|
58
|
-
puts "PUBF: Headers are: #{ph.inspect}"
|
59
|
-
begin
|
60
|
-
client.publish(qname, buff, ph)
|
61
|
-
rescue
|
62
|
-
puts "PUBF: exception on publish: #{$!}"
|
63
|
-
end
|
64
|
-
sleep 0.1
|
65
|
-
e = client.poll() # Check for unsolicited messages from broker
|
66
|
-
puts "PUBF: unexpected broker message: #{e}" if e
|
67
|
-
client.close
|
68
|
-
end_time = Time.now.to_f
|
69
|
-
ppt = sprintf("%20.6f", end_time - start_time)
|
70
|
-
puts "PUBF: File published: #{ppt} seconds"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
#
|
74
|
-
e = FileSender.new
|
75
|
-
e.run
|
76
|
-
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'stomp'
|
5
|
-
|
6
|
-
if Kernel.respond_to?(:require_relative)
|
7
|
-
require_relative("./stomp11_common")
|
8
|
-
require_relative("./lflogger")
|
9
|
-
else
|
10
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "stomp11_common"
|
12
|
-
require "./lflogger"
|
13
|
-
end
|
14
|
-
include Stomp11Common
|
15
|
-
#
|
16
|
-
# Used primarily for testing performance when sending "large" messages.
|
17
|
-
# "large" => YMMV
|
18
|
-
#
|
19
|
-
class FileSenderConn
|
20
|
-
# Initialize.
|
21
|
-
def initialize
|
22
|
-
end
|
23
|
-
# Run example.
|
24
|
-
def run
|
25
|
-
p [ "pubc001", Thread.current ]
|
26
|
-
publogger = Slogger::new
|
27
|
-
start_time = Time.now.to_f
|
28
|
-
fname = ARGV[0]
|
29
|
-
puts "PUBFC: File Name: #{fname}"
|
30
|
-
file = open(fname, "r")
|
31
|
-
rs = Time.now.to_f
|
32
|
-
buff = file.read
|
33
|
-
re = Time.now.to_f
|
34
|
-
ppt = sprintf("%20.6f", re - rs)
|
35
|
-
puts "PUBFC: File size: #{buff.respond_to?(:bytesize) ? buff.bytesize : buff.length}"
|
36
|
-
puts "PUBFC: File read: #{ppt} seconds"
|
37
|
-
file.close
|
38
|
-
#
|
39
|
-
connection_hdrs = {"accept-version" => "1.1",
|
40
|
-
"host" => virt_host(),
|
41
|
-
}
|
42
|
-
connection_hash = { :hosts => [
|
43
|
-
{:login => login(), :passcode => passcode(),
|
44
|
-
:host => host(), :port => port()},
|
45
|
-
],
|
46
|
-
:connect_headers => connection_hdrs,
|
47
|
-
:logger => publogger,
|
48
|
-
:reliable => false, ### *NOTE*
|
49
|
-
}
|
50
|
-
#
|
51
|
-
# p [ "ch", connection_hash ]
|
52
|
-
connection = Stomp::Connection.new(connection_hash)
|
53
|
-
qname = ENV['STOMP_DEST'] ? ENV['STOMP_DEST'] : "/queue/a.big.file"
|
54
|
-
puts "PUBFC: Qname is: #{qname}"
|
55
|
-
ph = {:presistent => true}
|
56
|
-
ph['suppress_content_length'] = 'yes' if suppresscl()
|
57
|
-
puts "PUBF: Headers are: #{ph.inspect}"
|
58
|
-
# Try to gracefully handle files that exceed broker size limits.
|
59
|
-
begin
|
60
|
-
connection.publish(qname, buff, ph)
|
61
|
-
rescue
|
62
|
-
puts "PUBFC: exception on publish: #{$!}"
|
63
|
-
end
|
64
|
-
e = connection.poll() # Check for unsolicited messages from broker
|
65
|
-
puts "PUBFC: unexpected broker message: #{e}" if e
|
66
|
-
connection.disconnect
|
67
|
-
end_time = Time.now.to_f
|
68
|
-
ppt = sprintf("%20.6f", end_time - start_time)
|
69
|
-
puts "PUBFC: File published: #{ppt} seconds"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
#
|
73
|
-
e = FileSenderConn.new
|
74
|
-
e.run
|
75
|
-
|
data/examples/put11conn_ex1.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
#
|
4
|
-
# The current require dance for different Ruby versions.
|
5
|
-
# Change this to suit your requirements.
|
6
|
-
#
|
7
|
-
if Kernel.respond_to?(:require_relative)
|
8
|
-
require_relative("./stomp11_common")
|
9
|
-
else
|
10
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "stomp11_common"
|
12
|
-
end
|
13
|
-
include Stomp11Common
|
14
|
-
|
15
|
-
#
|
16
|
-
# == Stomp 1.1 Publish Example
|
17
|
-
#
|
18
|
-
# Purpose: to demonstrate sending messages using Stomp 1.1.
|
19
|
-
#
|
20
|
-
class Publish11Example1
|
21
|
-
# Initialize.
|
22
|
-
def initialize
|
23
|
-
end
|
24
|
-
# Run example.
|
25
|
-
def run
|
26
|
-
conn = get_connection() # Use helper method to obtain a Stomp#connection
|
27
|
-
raise "Unexpected protocol level" if conn.protocol != Stomp::SPL_11
|
28
|
-
#
|
29
|
-
# Publishing simple data is as it was with Stomp 1.0.
|
30
|
-
#
|
31
|
-
# Note: Stomp 1.1 brokers seem to prefer using '.' as delimiters in queue
|
32
|
-
# name spaces. Hence, the queue name used here.
|
33
|
-
#
|
34
|
-
qname = "/queue/nodea.nodeb.nodec"
|
35
|
-
data = "message payload"
|
36
|
-
headers = {}
|
37
|
-
#
|
38
|
-
# The 'data' and 'headers' may be omitted, as with Stomp 1.0
|
39
|
-
#
|
40
|
-
puts "Writing #{nmsgs()} messages."
|
41
|
-
1.upto(nmsgs()) do |i|
|
42
|
-
msg = "#{data}: #{i}"
|
43
|
-
conn.publish qname, msg , headers
|
44
|
-
puts "Sent data: #{msg}"
|
45
|
-
end
|
46
|
-
#
|
47
|
-
# And finally, disconnect.
|
48
|
-
#
|
49
|
-
conn.disconnect
|
50
|
-
end
|
51
|
-
end
|
52
|
-
#
|
53
|
-
e = Publish11Example1.new
|
54
|
-
e.run
|
55
|
-
|
56
|
-
|
data/examples/ssl_common.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
#
|
4
|
-
# Common Stomp 1.1 code.
|
5
|
-
#
|
6
|
-
require "rubygems" if RUBY_VERSION < "1.9"
|
7
|
-
require "stomp"
|
8
|
-
#
|
9
|
-
module SSLCommon
|
10
|
-
|
11
|
-
# CA Data.
|
12
|
-
|
13
|
-
# CA file location/directory. Change or specify.
|
14
|
-
# This is the author's default.
|
15
|
-
def ca_loc()
|
16
|
-
ENV['CA_FLOC'] || "/ad3/gma/sslwork/2013-extended-02" # The CA cert location
|
17
|
-
end
|
18
|
-
# CA file. Change or specify.
|
19
|
-
# This is the author's default.
|
20
|
-
def ca_cert()
|
21
|
-
ENV['CA_FILE'] || "TestCA.crt" # The CA cert File
|
22
|
-
end
|
23
|
-
# CA private key file. Change or specify.
|
24
|
-
# This is the author's default.
|
25
|
-
# This file should not be exposed to the outside world.
|
26
|
-
# Not currently used in stomp examples.
|
27
|
-
def ca_key()
|
28
|
-
ENV['CA_KEY'] || nil # The CA private key File
|
29
|
-
end
|
30
|
-
|
31
|
-
# Client Data.
|
32
|
-
|
33
|
-
# Client file location/directory. Change or specify.
|
34
|
-
# This is the author's default.
|
35
|
-
def cli_loc()
|
36
|
-
ENV['CLI_FLOC'] || "/ad3/gma/sslwork/2013-extended-02" # The client cert location
|
37
|
-
end
|
38
|
-
# Client cert file. Change or specify.
|
39
|
-
# This is the author's default.
|
40
|
-
def cli_cert()
|
41
|
-
ENV['CLI_FILE'] || "client.crt" # The client cert File
|
42
|
-
end
|
43
|
-
# Client private keyfile. Change or specify.
|
44
|
-
# This is the author's default.
|
45
|
-
# This file should not be exposed to the outside world.
|
46
|
-
def cli_key()
|
47
|
-
ENV['CLI_KEY'] || nil # The client private key File
|
48
|
-
end
|
49
|
-
|
50
|
-
# Server Data.
|
51
|
-
|
52
|
-
# Server file location/directory. Change or specify.
|
53
|
-
# This is the author's default.
|
54
|
-
# Not currently used in stomp examples.
|
55
|
-
def svr_loc()
|
56
|
-
ENV['SVR_FLOC'] || "/ad3/gma/sslwork/2013-extended-02" # The server cert location
|
57
|
-
end
|
58
|
-
# Server cert file. Change or specify.
|
59
|
-
# This is the author's default.
|
60
|
-
# Not currently used in stomp examples.
|
61
|
-
def svr_cert()
|
62
|
-
ENV['SVR_FILE'] || "server.crt" # The server cert File
|
63
|
-
end
|
64
|
-
# Server private keyfile. Change or specify.
|
65
|
-
# This is the author's default.
|
66
|
-
# This file should not be exposed to the outside world.
|
67
|
-
# Not currently used in stomp examples.
|
68
|
-
def svr_key()
|
69
|
-
ENV['SVR_KEY'] || nil # The server private key File
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
data/examples/ssl_newparm.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
#
|
4
|
-
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
|
5
|
-
#
|
6
|
-
require "rubygems"
|
7
|
-
require "stomp"
|
8
|
-
#
|
9
|
-
# == Demo override of SSLContext.new parameters.
|
10
|
-
#
|
11
|
-
# Based roughly on example ssl_uc1.rb.
|
12
|
-
#
|
13
|
-
#
|
14
|
-
class ExampleSSLNewParm
|
15
|
-
# Initialize.
|
16
|
-
def initialize
|
17
|
-
end
|
18
|
-
# Run example.
|
19
|
-
def run
|
20
|
-
ssl_opts = Stomp::SSLParams.new
|
21
|
-
hash = { :hosts => [
|
22
|
-
{:login => 'guest', :passcode => 'guest', :host => 'localhost', :port => 61612, :ssl => ssl_opts},
|
23
|
-
],
|
24
|
-
:reliable => false, # YMMV, to test this in a sane manner
|
25
|
-
:sslctx_newparm => :SSLv2, # An example should you:
|
26
|
-
# a) Actually want SSLv2 *AND*
|
27
|
-
# b) Your Ruby version supports SSLv2 *AND*
|
28
|
-
# c) Your broker supports and allows SSLv2
|
29
|
-
}
|
30
|
-
#
|
31
|
-
puts "Connect starts, SSL Use Case 1"
|
32
|
-
c = Stomp::Connection.new(hash)
|
33
|
-
puts "Connect completed"
|
34
|
-
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
35
|
-
# puts "SSL Peer Certificate:\n#{ssl_opts.peer_cert}"
|
36
|
-
#
|
37
|
-
c.disconnect
|
38
|
-
end
|
39
|
-
end
|
40
|
-
#
|
41
|
-
e = ExampleSSLNewParm.new
|
42
|
-
e.run
|
43
|
-
|
data/examples/ssl_uc1_ciphers.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
#
|
4
|
-
# Reference: https://github.com/stompgem/stomp/wiki/extended-ssl-overview
|
5
|
-
#
|
6
|
-
if Kernel.respond_to?(:require_relative)
|
7
|
-
require_relative("./ssl_common")
|
8
|
-
else
|
9
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
10
|
-
require "ssl_common"
|
11
|
-
end
|
12
|
-
include SSLCommon
|
13
|
-
#
|
14
|
-
# == SSL Use Case 1 - User Supplied Ciphers
|
15
|
-
#
|
16
|
-
# If you need your own ciphers list, this is how.
|
17
|
-
# Stomp's default list will work in many cases. If you need to use this, you
|
18
|
-
# will know it because SSL connect will fail. In that case, determining
|
19
|
-
# _what_ should be in the list is your responsibility.
|
20
|
-
#
|
21
|
-
class ExampleSSL1C
|
22
|
-
# Initialize.
|
23
|
-
def initialize # Change the following as needed.
|
24
|
-
@host = ENV['STOMP_HOST'] ? ENV['STOMP_HOST'] : "localhost"
|
25
|
-
@port = ENV['STOMP_PORT'] ? ENV['STOMP_PORT'].to_i : 61612
|
26
|
-
end
|
27
|
-
# Run example.
|
28
|
-
def run
|
29
|
-
ciphers_list = [["DHE-RSA-AES256-SHA", "TLSv1/SSLv3", 256, 256], ["DHE-DSS-AES256-SHA", "TLSv1/SSLv3", 256, 256], ["AES256-SHA", "TLSv1/SSLv3", 256, 256], ["EDH-RSA-DES-CBC3-SHA", "TLSv1/SSLv3", 168, 168], ["EDH-DSS-DES-CBC3-SHA", "TLSv1/SSLv3", 168, 168], ["DES-CBC3-SHA", "TLSv1/SSLv3", 168, 168], ["DHE-RSA-AES128-SHA", "TLSv1/SSLv3", 128, 128], ["DHE-DSS-AES128-SHA", "TLSv1/SSLv3", 128, 128], ["AES128-SHA", "TLSv1/SSLv3", 128, 128], ["RC4-SHA", "TLSv1/SSLv3", 128, 128], ["RC4-MD5", "TLSv1/SSLv3", 128, 128], ["EDH-RSA-DES-CBC-SHA", "TLSv1/SSLv3", 56, 56], ["EDH-DSS-DES-CBC-SHA", "TLSv1/SSLv3", 56, 56], ["DES-CBC-SHA", "TLSv1/SSLv3", 56, 56], ["EXP-EDH-RSA-DES-CBC-SHA", "TLSv1/SSLv3", 40, 56], ["EXP-EDH-DSS-DES-CBC-SHA", "TLSv1/SSLv3", 40, 56], ["EXP-DES-CBC-SHA", "TLSv1/SSLv3", 40, 56], ["EXP-RC2-CBC-MD5", "TLSv1/SSLv3", 40, 128], ["EXP-RC4-MD5", "TLSv1/SSLv3", 40, 128]]
|
30
|
-
|
31
|
-
ssl_opts = Stomp::SSLParams.new(:ciphers => ciphers_list)
|
32
|
-
|
33
|
-
#
|
34
|
-
# SSL Use Case 1
|
35
|
-
#
|
36
|
-
hash = { :hosts => [
|
37
|
-
{:login => 'guest', :passcode => 'guest', :host => @host, :port => @port, :ssl => ssl_opts},
|
38
|
-
],
|
39
|
-
:reliable => false, # YMMV, to test this in a sane manner
|
40
|
-
}
|
41
|
-
#
|
42
|
-
puts "Connect starts, SSL Use Case 1"
|
43
|
-
c = Stomp::Connection.new(hash)
|
44
|
-
puts "Connect completed"
|
45
|
-
puts "SSL Verify Result: #{ssl_opts.verify_result}"
|
46
|
-
#
|
47
|
-
c.disconnect
|
48
|
-
end
|
49
|
-
end
|
50
|
-
#
|
51
|
-
e = ExampleSSL1C.new
|
52
|
-
e.run
|
53
|
-
|