social_stream 0.21.4 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -5
- data/base/app/assets/stylesheets/cheesecake.css.scss +1 -0
- data/base/app/views/cheesecake/_cheesecake.html.erb +3 -0
- data/base/app/views/cheesecake/_index.html.erb +88 -41
- data/base/app/views/cheesecake/_sector_form.html.erb +12 -12
- data/base/lib/social_stream/base/version.rb +1 -1
- data/base/lib/social_stream/test_helpers/controllers.rb +19 -2
- data/base/lib/tasks/db/populate.rake +190 -165
- data/base/social_stream-base.gemspec +1 -1
- data/base/spec/controllers/posts_controller_spec.rb +19 -1
- data/lib/social_stream/version.rb +1 -1
- data/presence/app/assets/images/status/chat.png +0 -0
- data/presence/app/assets/javascripts/chat_interface_manager.js.erb +42 -45
- data/presence/app/assets/javascripts/chat_parser.js +5 -5
- data/presence/app/assets/javascripts/chat_persistence.js +25 -26
- data/presence/app/assets/javascripts/chat_utilities.js +15 -11
- data/presence/app/assets/javascripts/chat_window_manager.js +129 -26
- data/presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +22 -3
- data/presence/app/assets/javascripts/social_stream-presence.js +1 -0
- data/presence/app/assets/javascripts/videochat.js.erb +459 -0
- data/presence/app/assets/javascripts/xmpp_client_management.js.erb +303 -65
- data/presence/app/assets/stylesheets/chat.css.scss +42 -1
- data/presence/app/controllers/xmpp_controller.rb +20 -3
- data/presence/app/views/chat/_index.html.erb +7 -2
- data/presence/app/views/xmpp/getOpenTokSessionIDAndToken.xml.builder +6 -0
- data/presence/config/locales/en.yml +22 -1
- data/presence/config/locales/es.yml +23 -2
- data/presence/config/routes.rb +2 -0
- data/presence/ejabberd/conf/ssconfig_example.cfg +4 -3
- data/presence/ejabberd/ejabberd_files.zip +0 -0
- data/presence/ejabberd/ejabberd_scripts/authentication_script +22 -12
- data/presence/ejabberd/ejabberd_scripts/development_scripts/show_config.sh +9 -10
- data/presence/ejabberd/ejabberd_scripts/emanagement +275 -178
- data/presence/ejabberd/ejabberd_scripts/manageWebDomains +164 -0
- data/presence/ejabberd/ejabberd_scripts/rest_api_client_script +75 -32
- data/presence/ejabberd/ejabberd_scripts/synchronize_presence_script +81 -34
- data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
- data/presence/ejabberd/mod_sspresence/mod_sspresence.erl +27 -23
- data/presence/lib/OpenTok/Exceptions.rb +11 -0
- data/presence/lib/OpenTok/OpenTokSDK.rb +184 -0
- data/presence/lib/OpenTok/Session.rb +27 -0
- data/presence/lib/generators/social_stream/presence/templates/initializer.rb +8 -2
- data/presence/lib/open_tok.rb +31 -0
- data/presence/lib/opentok.rb +29 -0
- data/presence/lib/social_stream-presence.rb +4 -0
- data/presence/lib/social_stream/presence/models/buddy_manager.rb +1 -1
- data/presence/lib/social_stream/presence/version.rb +1 -1
- data/presence/lib/social_stream/presence/xmpp_server_order.rb +96 -76
- data/presence/lib/social_stream/presence/xmpp_ssclient.rb +54 -0
- data/presence/lib/tasks/presence/multidomain.rake +45 -0
- data/presence/lib/tasks/presence/synchronize.rake +18 -4
- data/presence/vendor/assets/javascripts/TB.min.js +4329 -0
- data/social_stream.gemspec +2 -2
- metadata +40 -30
- data/presence/ejabberd/ejabberd_scripts/reset_connection_script +0 -300
- data/presence/ejabberd/ejabberd_scripts/set_script_header.sh +0 -112
data/social_stream.gemspec
CHANGED
@@ -11,11 +11,11 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.files = `git ls-files`.split("\n")
|
12
12
|
|
13
13
|
# Gem dependencies
|
14
|
-
s.add_runtime_dependency('social_stream-base', '~> 0.16.
|
14
|
+
s.add_runtime_dependency('social_stream-base', '~> 0.16.3')
|
15
15
|
s.add_runtime_dependency('social_stream-documents', '~> 0.11.1')
|
16
16
|
s.add_runtime_dependency('social_stream-events', '~> 0.8.1')
|
17
17
|
s.add_runtime_dependency('social_stream-linkser', '~> 0.6.1')
|
18
|
-
s.add_runtime_dependency('social_stream-presence', '~> 0.
|
18
|
+
s.add_runtime_dependency('social_stream-presence', '~> 0.8.3')
|
19
19
|
|
20
20
|
# Development Gem dependencies
|
21
21
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,22 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-02-
|
13
|
+
date: 2012-02-28 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: social_stream-base
|
17
|
-
requirement: &
|
17
|
+
requirement: &80182220 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.16.
|
22
|
+
version: 0.16.3
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *80182220
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: social_stream-documents
|
28
|
-
requirement: &
|
28
|
+
requirement: &80181900 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.11.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *80181900
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: social_stream-events
|
39
|
-
requirement: &
|
39
|
+
requirement: &80181640 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 0.8.1
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *80181640
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: social_stream-linkser
|
50
|
-
requirement: &
|
50
|
+
requirement: &80181260 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,21 +55,21 @@ dependencies:
|
|
55
55
|
version: 0.6.1
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *80181260
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: social_stream-presence
|
61
|
-
requirement: &
|
61
|
+
requirement: &80180810 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.
|
66
|
+
version: 0.8.3
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *80180810
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: capybara
|
72
|
-
requirement: &
|
72
|
+
requirement: &80180510 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 0.3.9
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *80180510
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: sqlite3
|
83
|
-
requirement: &
|
83
|
+
requirement: &80180070 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *80180070
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: ruby-debug19
|
94
|
-
requirement: &
|
94
|
+
requirement: &80179570 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *80179570
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rspec-rails
|
105
|
-
requirement: &
|
105
|
+
requirement: &80179190 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: 2.8.0
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *80179190
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: factory_girl
|
116
|
-
requirement: &
|
116
|
+
requirement: &80178740 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ~>
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: 1.3.2
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *80178740
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: forgery
|
127
|
-
requirement: &
|
127
|
+
requirement: &80178210 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ~>
|
@@ -132,10 +132,10 @@ dependencies:
|
|
132
132
|
version: 0.4.2
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *80178210
|
136
136
|
- !ruby/object:Gem::Dependency
|
137
137
|
name: ci_reporter
|
138
|
-
requirement: &
|
138
|
+
requirement: &80177720 !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
140
140
|
requirements:
|
141
141
|
- - ~>
|
@@ -143,7 +143,7 @@ dependencies:
|
|
143
143
|
version: 1.6.4
|
144
144
|
type: :development
|
145
145
|
prerelease: false
|
146
|
-
version_requirements: *
|
146
|
+
version_requirements: *80177720
|
147
147
|
description: Social Stream is a Ruby on Rails engine for building social network websites.
|
148
148
|
It supports contacts, posts, file uploads, private messages and many more.
|
149
149
|
email:
|
@@ -1207,6 +1207,7 @@ files:
|
|
1207
1207
|
- presence/app/assets/images/emoticons/sun.png
|
1208
1208
|
- presence/app/assets/images/status/available.png
|
1209
1209
|
- presence/app/assets/images/status/away.png
|
1210
|
+
- presence/app/assets/images/status/chat.png
|
1210
1211
|
- presence/app/assets/images/status/dnd.png
|
1211
1212
|
- presence/app/assets/images/status/offline.png
|
1212
1213
|
- presence/app/assets/javascripts/chat_audio.js.erb
|
@@ -1219,6 +1220,7 @@ files:
|
|
1219
1220
|
- presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js
|
1220
1221
|
- presence/app/assets/javascripts/social_stream-presence.js
|
1221
1222
|
- presence/app/assets/javascripts/store.js
|
1223
|
+
- presence/app/assets/javascripts/videochat.js.erb
|
1222
1224
|
- presence/app/assets/javascripts/xmpp_client_management.js.erb
|
1223
1225
|
- presence/app/assets/stylesheets/chat.css.scss
|
1224
1226
|
- presence/app/assets/stylesheets/social_stream-presence.css
|
@@ -1228,6 +1230,7 @@ files:
|
|
1228
1230
|
- presence/app/views/chat/_index.html.erb
|
1229
1231
|
- presence/app/views/chat/_settings.html.erb
|
1230
1232
|
- presence/app/views/xmpp/active_users.html.erb
|
1233
|
+
- presence/app/views/xmpp/getOpenTokSessionIDAndToken.xml.builder
|
1231
1234
|
- presence/config/locales/en.yml
|
1232
1235
|
- presence/config/locales/es.yml
|
1233
1236
|
- presence/config/routes.rb
|
@@ -1246,25 +1249,31 @@ files:
|
|
1246
1249
|
- presence/ejabberd/ejabberd_scripts/development_scripts/start_ejabberd.sh
|
1247
1250
|
- presence/ejabberd/ejabberd_scripts/development_scripts/stop_ejabberd.sh
|
1248
1251
|
- presence/ejabberd/ejabberd_scripts/emanagement
|
1249
|
-
- presence/ejabberd/ejabberd_scripts/
|
1252
|
+
- presence/ejabberd/ejabberd_scripts/manageWebDomains
|
1250
1253
|
- presence/ejabberd/ejabberd_scripts/rest_api_client_script
|
1251
|
-
- presence/ejabberd/ejabberd_scripts/set_script_header.sh
|
1252
1254
|
- presence/ejabberd/ejabberd_scripts/synchronize_presence_script
|
1253
1255
|
- presence/ejabberd/installer.sh
|
1254
1256
|
- presence/ejabberd/mod_admin_extra/mod_admin_extra.beam
|
1255
1257
|
- presence/ejabberd/mod_admin_extra/mod_admin_extra.erl
|
1256
1258
|
- presence/ejabberd/mod_sspresence/mod_sspresence.beam
|
1257
1259
|
- presence/ejabberd/mod_sspresence/mod_sspresence.erl
|
1260
|
+
- presence/lib/OpenTok/Exceptions.rb
|
1261
|
+
- presence/lib/OpenTok/OpenTokSDK.rb
|
1262
|
+
- presence/lib/OpenTok/Session.rb
|
1258
1263
|
- presence/lib/generators/social_stream/presence/install_generator.rb
|
1259
1264
|
- presence/lib/generators/social_stream/presence/templates/initializer.rb
|
1265
|
+
- presence/lib/open_tok.rb
|
1266
|
+
- presence/lib/opentok.rb
|
1260
1267
|
- presence/lib/social_stream-presence.rb
|
1261
1268
|
- presence/lib/social_stream/migrations/presence.rb
|
1262
1269
|
- presence/lib/social_stream/presence/engine.rb
|
1263
1270
|
- presence/lib/social_stream/presence/models/buddy_manager.rb
|
1264
1271
|
- presence/lib/social_stream/presence/version.rb
|
1265
1272
|
- presence/lib/social_stream/presence/xmpp_server_order.rb
|
1273
|
+
- presence/lib/social_stream/presence/xmpp_ssclient.rb
|
1266
1274
|
- presence/lib/social_stream/views/settings/presence.rb
|
1267
1275
|
- presence/lib/tasks/presence/installer.rake
|
1276
|
+
- presence/lib/tasks/presence/multidomain.rake
|
1268
1277
|
- presence/lib/tasks/presence/synchronize.rake
|
1269
1278
|
- presence/social_stream-presence.gemspec
|
1270
1279
|
- presence/spec/demo/.gitignore
|
@@ -1318,6 +1327,7 @@ files:
|
|
1318
1327
|
- presence/spec/demo/vendor/plugins/.gitkeep
|
1319
1328
|
- presence/spec/discover.rb
|
1320
1329
|
- presence/spec/spec_helper.rb
|
1330
|
+
- presence/vendor/assets/javascripts/TB.min.js
|
1321
1331
|
- presence/vendor/assets/javascripts/jquery.tools.tooltip.js
|
1322
1332
|
- presence/vendor/assets/javascripts/liquidmetal.js
|
1323
1333
|
- presence/vendor/assets/javascripts/strophe.js
|
@@ -1,300 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#Rest Api Client Script
|
3
|
-
#Version: 13-12-2011
|
4
|
-
#@author Aldo
|
5
|
-
|
6
|
-
|
7
|
-
require 'logger'
|
8
|
-
require 'rest_client'
|
9
|
-
|
10
|
-
|
11
|
-
path = "/var/log/ejabberd/scripts.log"
|
12
|
-
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
|
13
|
-
file.sync = true
|
14
|
-
$logger = Logger.new(file)
|
15
|
-
$logger.level = Logger::DEBUG
|
16
|
-
|
17
|
-
def getOption(option)
|
18
|
-
File.open('/etc/ejabberd/ssconfig.cfg', 'r') do |f1|
|
19
|
-
while line = f1.gets
|
20
|
-
line = line.gsub(/\n/,'')
|
21
|
-
if line.match(/^#/)
|
22
|
-
#Comments
|
23
|
-
elsif line.match(/^#{option}/)
|
24
|
-
return line.gsub(/#{option}/,'')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
return "Undefined"
|
29
|
-
end
|
30
|
-
|
31
|
-
#Constants
|
32
|
-
$secure_rest_api = getOption("secure_rest_api=")
|
33
|
-
$pass = getOption("ejabberd_password=")
|
34
|
-
$scripts_path = getOption("scripts_path=")
|
35
|
-
$script_title = "Reset Connection Script"
|
36
|
-
|
37
|
-
|
38
|
-
def log(title,text)
|
39
|
-
$logger.info title + ": " + text
|
40
|
-
end
|
41
|
-
|
42
|
-
def getMethodName
|
43
|
-
caller[0] =~ /`(.*?)'/
|
44
|
-
$1
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
#####################
|
49
|
-
##### Example #####
|
50
|
-
#####################
|
51
|
-
#def myHook(param1,param2)
|
52
|
-
# log(getMethodName,"(My message: #{param1},#{param2})")
|
53
|
-
# url = "http://" + getOption("web_domain=") + "/xmpp/hookRoute"
|
54
|
-
|
55
|
-
# params = {}
|
56
|
-
# encrypted_params = {}
|
57
|
-
# #Add params to sent in clear
|
58
|
-
# params[:param1_in_server]=param1
|
59
|
-
# #Add params to sent cipher
|
60
|
-
# encrypted_params[:param2_in_server]=param2
|
61
|
-
|
62
|
-
# return [getMethodName,generic_api_call(url,params,encrypted_params)]
|
63
|
-
#end
|
64
|
-
|
65
|
-
def setConnection(username)
|
66
|
-
log($script_title,"#{getMethodName}(#{username})")
|
67
|
-
url = "http://" + getOption("web_domain=") + "/xmpp/setConnection"
|
68
|
-
|
69
|
-
params = {}
|
70
|
-
encrypted_params = {}
|
71
|
-
encrypted_params[:name]=username
|
72
|
-
|
73
|
-
return [getMethodName,generic_api_call(url,params,encrypted_params)]
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
def unsetConnection(username)
|
78
|
-
log($script_title,"#{getMethodName}(#{username})")
|
79
|
-
url = "http://" + getOption("web_domain=") + "/xmpp/unsetConnection"
|
80
|
-
|
81
|
-
params = {}
|
82
|
-
encrypted_params = {}
|
83
|
-
encrypted_params[:name]=username
|
84
|
-
|
85
|
-
return [getMethodName,generic_api_call(url,params,encrypted_params)]
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
def setPresence(username,status)
|
90
|
-
log($script_title,"#{getMethodName}(#{username},#{status})")
|
91
|
-
url = "http://" + getOption("web_domain=") + "/xmpp/setPresence"
|
92
|
-
|
93
|
-
params = {}
|
94
|
-
encrypted_params = {}
|
95
|
-
encrypted_params[:name]=username
|
96
|
-
encrypted_params[:status]=status
|
97
|
-
|
98
|
-
return [getMethodName,generic_api_call(url,params,encrypted_params)]
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
def unsetPresence(username)
|
103
|
-
log($script_title,"#{getMethodName}(#{username})")
|
104
|
-
url = "http://" + getOption("web_domain=") + "/xmpp/unsetPresence"
|
105
|
-
|
106
|
-
params = {}
|
107
|
-
encrypted_params = {}
|
108
|
-
encrypted_params[:name]=username
|
109
|
-
|
110
|
-
return [getMethodName,generic_api_call(url,params,encrypted_params)]
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
def resetConnection()
|
115
|
-
log($script_title,"Call #{getMethodName}()")
|
116
|
-
url = "http://" + getOption("web_domain=") + "/xmpp/resetConnection"
|
117
|
-
|
118
|
-
params = {}
|
119
|
-
encrypted_params = {}
|
120
|
-
|
121
|
-
return [getMethodName,generic_api_call(url,params,encrypted_params)]
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
def synchronize()
|
126
|
-
log($script_title,"Call #{getMethodName}()")
|
127
|
-
url = "http://" + getOption("web_domain=") + "/xmpp/synchronizePresence"
|
128
|
-
|
129
|
-
|
130
|
-
#Get connected users using Emanagement
|
131
|
-
users = []
|
132
|
-
command = $scripts_path + "/emanagement getConnectedUsers"
|
133
|
-
output = %x[#{command}]
|
134
|
-
sessions = output.split("\n")
|
135
|
-
|
136
|
-
sessions.each do |session|
|
137
|
-
users << session.split("@")[0]
|
138
|
-
end
|
139
|
-
#Finish
|
140
|
-
|
141
|
-
|
142
|
-
#In this cases users always will be sent in clear (not cipher)
|
143
|
-
#(Too much data to cipher)
|
144
|
-
#Anyway, we must to build the hash to pass the authentication
|
145
|
-
params = {}
|
146
|
-
encrypted_params = {}
|
147
|
-
params[:name]=users.join(",")
|
148
|
-
|
149
|
-
return [getMethodName,generic_api_call(url,params,encrypted_params)]
|
150
|
-
end
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
#Params must include the password and all the parameters to be sent in clear.
|
155
|
-
#Anyway, If "secure_rest_api" is disable, encrypted_params will be send in clear.
|
156
|
-
def generic_api_call(url,params,encrypted_params)
|
157
|
-
|
158
|
-
begin
|
159
|
-
unless params
|
160
|
-
params = {}
|
161
|
-
end
|
162
|
-
|
163
|
-
unless encrypted_params
|
164
|
-
encrypted_params = {}
|
165
|
-
end
|
166
|
-
|
167
|
-
params[:password]=$pass
|
168
|
-
|
169
|
-
response=sendHttpRequest(url,params,encrypted_params)
|
170
|
-
puts response.body
|
171
|
-
|
172
|
-
if response.body.include?("Ok")
|
173
|
-
return true
|
174
|
-
else
|
175
|
-
return false
|
176
|
-
end
|
177
|
-
|
178
|
-
rescue => e
|
179
|
-
log($script_title,"#{e.class.name}: #{e.message}")
|
180
|
-
puts("#{e.class.name}: #{e.message}")
|
181
|
-
return false
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
|
186
|
-
#Send HTTP Request to Social Stream Presence API
|
187
|
-
def sendHttpRequest(url,params,encrypted_params)
|
188
|
-
|
189
|
-
unless params[:password]
|
190
|
-
return "params[:password] required in sendHttpRequest";
|
191
|
-
end
|
192
|
-
|
193
|
-
|
194
|
-
if $secure_rest_api == "true"
|
195
|
-
#Require libraries
|
196
|
-
require 'openssl'
|
197
|
-
|
198
|
-
xmpp_private_key_path = $scripts_path + "/rsa_keys/xmpp_rsa_key_private.pem";
|
199
|
-
web_public_key_path = $scripts_path + "/rsa_keys/web_rsa_key_public.pem";
|
200
|
-
xmpp_private_key = OpenSSL::PKey::RSA.new(File.read(xmpp_private_key_path))
|
201
|
-
web_public_key = OpenSSL::PKey::RSA.new(File.read(web_public_key_path))
|
202
|
-
|
203
|
-
request_params = {};
|
204
|
-
|
205
|
-
#Copy non encypted params
|
206
|
-
params.each do |key,value|
|
207
|
-
unless key.to_s == "password"
|
208
|
-
request_params[key] = value
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
#Include encrypted params
|
213
|
-
if encrypted_params and encrypted_params.empty? == false
|
214
|
-
request_params[:encrypted_params] = web_public_key.public_encrypt(encrypted_params.to_s)
|
215
|
-
end
|
216
|
-
|
217
|
-
#Generating stamp
|
218
|
-
#1 Get constant password
|
219
|
-
password = params[:password];
|
220
|
-
#2 Generating timestamp
|
221
|
-
timestamp = Time.now.utc.to_s
|
222
|
-
#3 Calculating Hash
|
223
|
-
hash = calculateHash(request_params)
|
224
|
-
|
225
|
-
#Add cipher stamp to the request
|
226
|
-
request_params[:password] = xmpp_private_key.private_encrypt(password+"#####"+timestamp+"#####"+hash)
|
227
|
-
|
228
|
-
#Replace previous params
|
229
|
-
params = request_params
|
230
|
-
else
|
231
|
-
#Non secure mode: send encrypted params in clear
|
232
|
-
if encrypted_params
|
233
|
-
encrypted_params.each do |key,value|
|
234
|
-
params[key] = value
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
response = RestClient.get url, :params => params
|
240
|
-
return response
|
241
|
-
end
|
242
|
-
|
243
|
-
|
244
|
-
def calculateHash(request_params)
|
245
|
-
require 'digest/md5'
|
246
|
-
|
247
|
-
unless request_params
|
248
|
-
request_params = {};
|
249
|
-
end
|
250
|
-
|
251
|
-
hash = "";
|
252
|
-
request_params.each do |key,value|
|
253
|
-
hash = hash + key.to_s + value.to_s
|
254
|
-
end
|
255
|
-
return Digest::MD5.hexdigest(hash)
|
256
|
-
end
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
def invokeApiCall(method,args)
|
262
|
-
length = args.length;
|
263
|
-
case length
|
264
|
-
when 0
|
265
|
-
return send(method)
|
266
|
-
when 1
|
267
|
-
return send(method,args[0])
|
268
|
-
when 2
|
269
|
-
return send(method,args[0],args[1])
|
270
|
-
when 3
|
271
|
-
return send(method,args[0],args[1],args[2])
|
272
|
-
when 4
|
273
|
-
return send(method,args[0],args[1],args[2],args[3])
|
274
|
-
else
|
275
|
-
return send(method,args)
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
|
280
|
-
#Main Program
|
281
|
-
|
282
|
-
begin
|
283
|
-
|
284
|
-
args = []
|
285
|
-
method = "resetConnection";
|
286
|
-
|
287
|
-
if (response = invokeApiCall(method, args) and response[1])
|
288
|
-
puts $script_title + ": #{response[0]} [OK]"
|
289
|
-
log( $script_title , "#{response[0]} [OK]" )
|
290
|
-
else
|
291
|
-
puts $script_title + ": #{response[0]} [FAIL]"
|
292
|
-
log( $script_title , "#{response[0]} [FAIL]" )
|
293
|
-
end
|
294
|
-
|
295
|
-
rescue => e
|
296
|
-
log($script_title,"#{e.class.name}: #{e.message}")
|
297
|
-
puts("#{e.class.name}: #{e.message}")
|
298
|
-
exit 1
|
299
|
-
end
|
300
|
-
|