rsence 2.0.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL.rdoc +295 -0
- data/LICENSE +622 -0
- data/README.rdoc +24 -0
- data/VERSION +1 -0
- data/bin/build_client.rb +254 -0
- data/bin/help +6 -0
- data/bin/launch.rb +120 -0
- data/bin/rdoc.sh +2 -0
- data/bin/restart +6 -0
- data/bin/rsence +120 -0
- data/bin/run +6 -0
- data/bin/run.rb +6 -0
- data/bin/save +6 -0
- data/bin/start +6 -0
- data/bin/status +6 -0
- data/bin/stop +6 -0
- data/conf/config.ru +5 -0
- data/conf/default_conf.yaml +337 -0
- data/conf/default_strings.yaml +77 -0
- data/conf/local_conf.yaml +14 -0
- data/conf/unicorn.conf +78 -0
- data/js/comm/comm/autosync/autosync.js +18 -0
- data/js/comm/comm/autosync/js.inc +0 -0
- data/js/comm/comm/comm.js +195 -0
- data/js/comm/comm/js.inc +0 -0
- data/js/comm/comm/queue/js.inc +0 -0
- data/js/comm/comm/queue/queue.js +183 -0
- data/js/comm/comm/session/js.inc +0 -0
- data/js/comm/comm/session/session.js +51 -0
- data/js/comm/comm/sessionwatcher/js.inc +0 -0
- data/js/comm/comm/sessionwatcher/sessionwatcher.js +43 -0
- data/js/comm/comm/transporter/js.inc +0 -0
- data/js/comm/comm/transporter/transporter.js +257 -0
- data/js/comm/comm/urlresponder/js.inc +0 -0
- data/js/comm/comm/urlresponder/urlresponder.js +148 -0
- data/js/comm/comm/values/js.inc +0 -0
- data/js/comm/comm/values/values.js +432 -0
- data/js/comm/jsloader/js.inc +0 -0
- data/js/comm/jsloader/jsloader.js +114 -0
- data/js/comm/reloadapp/js.inc +0 -0
- data/js/comm/reloadapp/reloadapp.js +150 -0
- data/js/comm/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
- data/js/comm/reloadapp/themes/default/reloadapp_warning.png +0 -0
- data/js/comm/sha/js.inc +0 -0
- data/js/comm/sha/sha.js +432 -0
- data/js/comm/values/value/js.inc +0 -0
- data/js/comm/values/value/value.js +182 -0
- data/js/comm/values/valuematrix/js.inc +0 -0
- data/js/comm/values/valuematrix/valuematrix.js +138 -0
- data/js/controls/button/button.js +57 -0
- data/js/controls/button/js.inc +0 -0
- data/js/controls/button/themes/bright/button.css +89 -0
- data/js/controls/button/themes/bright/button.html +7 -0
- data/js/controls/button/themes/bright/button_parts1-ie6.gif +0 -0
- data/js/controls/button/themes/bright/button_parts1.png +0 -0
- data/js/controls/button/themes/default/button.css +89 -0
- data/js/controls/button/themes/default/button.html +7 -0
- data/js/controls/button/themes/default/button_parts1-ie6.gif +0 -0
- data/js/controls/button/themes/default/button_parts1.png +0 -0
- data/js/controls/checkbox/checkbox.js +47 -0
- data/js/controls/checkbox/js.inc +0 -0
- data/js/controls/checkbox/themes/default/checkbox.css +69 -0
- data/js/controls/checkbox/themes/default/checkbox.html +5 -0
- data/js/controls/checkbox/themes/default/checkbox_parts1-ie6.gif +0 -0
- data/js/controls/checkbox/themes/default/checkbox_parts1.png +0 -0
- data/js/controls/datetime/calendar/calendar.js +197 -0
- data/js/controls/datetime/calendar/js.inc +0 -0
- data/js/controls/datetime/calendar/themes/default/calendar.css +108 -0
- data/js/controls/datetime/calendar/themes/default/calendar.html +9 -0
- data/js/controls/datetime/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
- data/js/controls/datetime/calendar/themes/default/calendar_arrows.png +0 -0
- data/js/controls/datetime/datetimevalue/datetimevalue.js +246 -0
- data/js/controls/datetime/datetimevalue/js.inc +0 -0
- data/js/controls/datetime/timesheet/js.inc +0 -0
- data/js/controls/datetime/timesheet/themes/default/timesheet.css +30 -0
- data/js/controls/datetime/timesheet/themes/default/timesheet.html +2 -0
- data/js/controls/datetime/timesheet/timesheet.js +182 -0
- data/js/controls/datetime/timesheet_item/js.inc +0 -0
- data/js/controls/datetime/timesheet_item/themes/default/timesheet_item.css +42 -0
- data/js/controls/datetime/timesheet_item/themes/default/timesheet_item.html +8 -0
- data/js/controls/datetime/timesheet_item/timesheet_item.js +247 -0
- data/js/controls/datetime/timesheet_item_edit/js.inc +0 -0
- data/js/controls/datetime/timesheet_item_edit/timesheet_item_edit.js +274 -0
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +62 -0
- data/js/controls/dialogs/alert_sheet/js.inc +0 -0
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +36 -0
- data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
- data/js/controls/dialogs/sheet/js.inc +0 -0
- data/js/controls/dialogs/sheet/sheet.js +83 -0
- data/js/controls/dialogs/sheet/themes/default/sheet.css +64 -0
- data/js/controls/dialogs/sheet/themes/default/sheet.html +14 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_bg-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_bg.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_dim-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_dim.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts1-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts1.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts2-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts2.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_warning-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_warning.png +0 -0
- data/js/controls/imageview/imageview.js +108 -0
- data/js/controls/imageview/js.inc +0 -0
- data/js/controls/imageview/themes/default/blank.gif +0 -0
- data/js/controls/lists/checkboxlist/checkboxlist.js +170 -0
- data/js/controls/lists/checkboxlist/js.inc +0 -0
- data/js/controls/lists/listitems/js.inc +0 -0
- data/js/controls/lists/listitems/listitems.js +65 -0
- data/js/controls/lists/radiobuttonlist/js.inc +0 -0
- data/js/controls/lists/radiobuttonlist/radiobuttonlist.js +126 -0
- data/js/controls/passwordcontrol/js.inc +0 -0
- data/js/controls/passwordcontrol/passwordcontrol.js +22 -0
- data/js/controls/passwordcontrol/themes/default/passwordcontrol.css +0 -0
- data/js/controls/passwordcontrol/themes/default/passwordcontrol.html +18 -0
- data/js/controls/progress/progressbar/js.inc +0 -0
- data/js/controls/progress/progressbar/progressbar.js +36 -0
- data/js/controls/progress/progressbar/themes/default/progressbar.css +16 -0
- data/js/controls/progress/progressbar/themes/default/progressbar.html +2 -0
- data/js/controls/progress/progressindicator/js.inc +0 -0
- data/js/controls/progress/progressindicator/progressindicator.js +43 -0
- data/js/controls/radiobutton/js.inc +0 -0
- data/js/controls/radiobutton/radiobutton.js +41 -0
- data/js/controls/radiobutton/themes/default/radiobutton.css +69 -0
- data/js/controls/radiobutton/themes/default/radiobutton.html +5 -0
- data/js/controls/radiobutton/themes/default/radiobutton_parts1-ie6.gif +0 -0
- data/js/controls/radiobutton/themes/default/radiobutton_parts1.png +0 -0
- data/js/controls/sliders/slider/js.inc +0 -0
- data/js/controls/sliders/slider/slider.js +356 -0
- data/js/controls/sliders/slider/themes/default/hslider_tracks-ie6.gif +0 -0
- data/js/controls/sliders/slider/themes/default/hslider_tracks.png +0 -0
- data/js/controls/sliders/slider/themes/default/slider.css +108 -0
- data/js/controls/sliders/slider/themes/default/slider.html +5 -0
- data/js/controls/sliders/slider/themes/default/slider_thumbs-ie6.gif +0 -0
- data/js/controls/sliders/slider/themes/default/slider_thumbs.png +0 -0
- data/js/controls/sliders/vslider/js.inc +0 -0
- data/js/controls/sliders/vslider/themes/default/vslider.css +52 -0
- data/js/controls/sliders/vslider/themes/default/vslider.html +5 -0
- data/js/controls/sliders/vslider/themes/default/vslider_tracks-ie6.gif +0 -0
- data/js/controls/sliders/vslider/themes/default/vslider_tracks.png +0 -0
- data/js/controls/sliders/vslider/vslider.js +40 -0
- data/js/controls/stepper/js.inc +0 -0
- data/js/controls/stepper/stepper.js +212 -0
- data/js/controls/stepper/themes/default/stepper-ie6.gif +0 -0
- data/js/controls/stepper/themes/default/stepper.css +14 -0
- data/js/controls/stepper/themes/default/stepper.html +2 -0
- data/js/controls/stepper/themes/default/stepper.png +0 -0
- data/js/controls/stringview/js.inc +0 -0
- data/js/controls/stringview/stringview.js +49 -0
- data/js/controls/stringview/themes/default/stringview.css +8 -0
- data/js/controls/stringview/themes/default/stringview.html +1 -0
- data/js/controls/tab/js.inc +0 -0
- data/js/controls/tab/tab.js +276 -0
- data/js/controls/tab/themes/bright/tab.css +76 -0
- data/js/controls/tab/themes/bright/tab.html +6 -0
- data/js/controls/tab/themes/bright/tab_bg_color-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_bg_color.png +0 -0
- data/js/controls/tab/themes/bright/tab_border_pattern-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_border_pattern.png +0 -0
- data/js/controls/tab/themes/bright/tab_parts1-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_parts1.png +0 -0
- data/js/controls/tab/themes/default/tab.css +77 -0
- data/js/controls/tab/themes/default/tab.html +6 -0
- data/js/controls/tab/themes/default/tab_bg_color-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_bg_color.png +0 -0
- data/js/controls/tab/themes/default/tab_border_pattern-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_border_pattern.png +0 -0
- data/js/controls/tab/themes/default/tab_parts1-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_parts1.png +0 -0
- data/js/controls/textarea/js.inc +0 -0
- data/js/controls/textarea/textarea.js +23 -0
- data/js/controls/textarea/themes/default/textarea.css +21 -0
- data/js/controls/textarea/themes/default/textarea.html +18 -0
- data/js/controls/textcontrol/js.inc +0 -0
- data/js/controls/textcontrol/textcontrol.js +372 -0
- data/js/controls/textcontrol/themes/default/textcontrol.css +107 -0
- data/js/controls/textcontrol/themes/default/textcontrol.html +18 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts1-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts1.png +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts2-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts2.png +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts3-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts3.png +0 -0
- data/js/controls/uploader/js.inc +0 -0
- data/js/controls/uploader/themes/default/upload_progress.gif +0 -0
- data/js/controls/uploader/themes/default/uploader.css +108 -0
- data/js/controls/uploader/themes/default/uploader.html +27 -0
- data/js/controls/uploader/uploader.js +153 -0
- data/js/controls/validatorview/js.inc +0 -0
- data/js/controls/validatorview/themes/default/validator-ie6.gif +0 -0
- data/js/controls/validatorview/themes/default/validator.png +0 -0
- data/js/controls/validatorview/themes/default/validatorview.css +0 -0
- data/js/controls/validatorview/themes/default/validatorview.html +0 -0
- data/js/controls/validatorview/validatorview.js +55 -0
- data/js/controls/window/js.inc +0 -0
- data/js/controls/window/themes/default/window.css +219 -0
- data/js/controls/window/themes/default/window.html +17 -0
- data/js/controls/window/themes/default/window_bg_active-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_bg_active.png +0 -0
- data/js/controls/window/themes/default/window_bg_inactive-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_bg_inactive.png +0 -0
- data/js/controls/window/themes/default/window_buttons-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_buttons.png +0 -0
- data/js/controls/window/themes/default/window_parts1-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_parts1.png +0 -0
- data/js/controls/window/themes/default/window_parts2-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_parts2.png +0 -0
- data/js/controls/window/window.js +284 -0
- data/js/core/class/class.js +317 -0
- data/js/core/class/js.inc +0 -0
- data/js/core/elem/elem.js +1376 -0
- data/js/core/elem/js.inc +0 -0
- data/js/core/event/event.js +1021 -0
- data/js/core/event/js.inc +0 -0
- data/js/core/iefix/ie_css_element.htc +5 -0
- data/js/core/iefix/ie_css_style.htc +5 -0
- data/js/core/iefix/iefix.js +359 -0
- data/js/core/iefix/js.inc +0 -0
- data/js/debugg/debugg.js +43 -0
- data/js/debugg/js.inc +0 -0
- data/js/foundation/application/application.js +209 -0
- data/js/foundation/application/js.inc +0 -0
- data/js/foundation/control/control.js +342 -0
- data/js/foundation/control/controldefaults/controldefaults.js +59 -0
- data/js/foundation/control/controldefaults/js.inc +0 -0
- data/js/foundation/control/dummyvalue/dummyvalue.js +50 -0
- data/js/foundation/control/dummyvalue/js.inc +0 -0
- data/js/foundation/control/dyncontrol/dyncontrol.js +494 -0
- data/js/foundation/control/dyncontrol/js.inc +0 -0
- data/js/foundation/control/dyncontrol/themes/default/dyncontrol.css +0 -0
- data/js/foundation/control/dyncontrol/themes/default/dyncontrol.html +0 -0
- data/js/foundation/control/eventresponder/eventresponder.js +713 -0
- data/js/foundation/control/eventresponder/js.inc +0 -0
- data/js/foundation/control/js.inc +0 -0
- data/js/foundation/control/valueresponder/js.inc +0 -0
- data/js/foundation/control/valueresponder/valueresponder.js +77 -0
- data/js/foundation/geom/point/js.inc +0 -0
- data/js/foundation/geom/point/point.js +202 -0
- data/js/foundation/geom/rect/js.inc +0 -0
- data/js/foundation/geom/rect/rect.js +610 -0
- data/js/foundation/json_renderer/js.inc +0 -0
- data/js/foundation/json_renderer/json_renderer.js +231 -0
- data/js/foundation/system/js.inc +0 -0
- data/js/foundation/system/system.js +369 -0
- data/js/foundation/thememanager/js.inc +0 -0
- data/js/foundation/thememanager/thememanager.js +387 -0
- data/js/foundation/view/js.inc +0 -0
- data/js/foundation/view/markupview/js.inc +0 -0
- data/js/foundation/view/markupview/markupview.js +113 -0
- data/js/foundation/view/morphanimation/js.inc +0 -0
- data/js/foundation/view/morphanimation/morphanimation.js +236 -0
- data/js/foundation/view/view.js +1804 -0
- data/js/foundation/view/viewdefaults/js.inc +0 -0
- data/js/foundation/view/viewdefaults/viewdefaults.js +25 -0
- data/js/views/centerview/centerview.js +45 -0
- data/js/views/centerview/js.inc +0 -0
- data/js/views/inlineview/inlineview.js +14 -0
- data/js/views/inlineview/js.inc +0 -0
- data/js/views/scrollview/js.inc +0 -0
- data/js/views/scrollview/scrollview.js +39 -0
- data/lib/conf/default.rb +220 -0
- data/lib/conf/wizard.rb +303 -0
- data/lib/daemon/daemon.rb +293 -0
- data/lib/http/broker.rb +102 -0
- data/lib/http/rackup.rb +88 -0
- data/lib/http/request.rb +69 -0
- data/lib/http/response.rb +63 -0
- data/lib/plugins/gui_plugin.rb +129 -0
- data/lib/plugins/guiparser.rb +114 -0
- data/lib/plugins/plugin.rb +652 -0
- data/lib/plugins/plugin_plugins.rb +47 -0
- data/lib/plugins/plugin_sqlite_db.rb +72 -0
- data/lib/plugins/plugin_util.rb +96 -0
- data/lib/plugins/pluginmanager.rb +517 -0
- data/lib/plugins/servlet.rb +69 -0
- data/lib/session/msg.rb +291 -0
- data/lib/session/sessionmanager.rb +491 -0
- data/lib/session/sessionstorage.rb +314 -0
- data/lib/transporter/transporter.rb +254 -0
- data/lib/util/gzstring.rb +5 -0
- data/lib/values/hvalue.rb +323 -0
- data/lib/values/valuemanager.rb +152 -0
- data/plugins/client_pkg/client_pkg.rb +186 -0
- data/plugins/client_pkg/info.yaml +25 -0
- data/plugins/client_pkg/lib/client_pkg_build.rb +569 -0
- data/plugins/client_pkg/lib/client_pkg_cache.rb +50 -0
- data/plugins/client_pkg/lib/client_pkg_serve.rb +210 -0
- data/plugins/client_pkg/log/build_log +0 -0
- data/plugins/index_html/img/loading.gif +0 -0
- data/plugins/index_html/img/riassence.gif +0 -0
- data/plugins/index_html/index_html.rb +150 -0
- data/plugins/index_html/tmpl/index.html +22 -0
- data/plugins/index_html/tmpl/startup_index.html +29 -0
- data/plugins/legacy/disabled +0 -0
- data/plugins/legacy/disabled- +0 -0
- data/plugins/legacy/info.yaml +22 -0
- data/plugins/legacy/legacy.rb +15 -0
- data/plugins/main/js/riassence_ns.js +87 -0
- data/plugins/main/main.rb +234 -0
- data/plugins/main/values.yaml +8 -0
- data/plugins/ticketservices/lib/common.rb +300 -0
- data/plugins/ticketservices/lib/favicon.rb +38 -0
- data/plugins/ticketservices/lib/file.rb +58 -0
- data/plugins/ticketservices/lib/img.rb +50 -0
- data/plugins/ticketservices/lib/objblob.rb +66 -0
- data/plugins/ticketservices/lib/rsrc.rb +34 -0
- data/plugins/ticketservices/lib/upload.rb +206 -0
- data/plugins/ticketservices/ticketservices.rb +268 -0
- data/var/db/.git_include +0 -0
- data/var/log/.git_include +0 -0
- data/var/run/.git_include +0 -0
- metadata +390 -0
@@ -0,0 +1,314 @@
|
|
1
|
+
## Riassence Framework
|
2
|
+
# Copyright 2006 Riassence Inc.
|
3
|
+
# http://riassence.com/
|
4
|
+
#
|
5
|
+
# You should have received a copy of the GNU General Public License along
|
6
|
+
# with this software package. If not, contact licensing@riassence.com
|
7
|
+
##
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'sequel'
|
11
|
+
|
12
|
+
## HValue class for session restoration
|
13
|
+
require 'values/hvalue'
|
14
|
+
|
15
|
+
|
16
|
+
module RSence
|
17
|
+
|
18
|
+
=begin
|
19
|
+
SessionStorage doesn't do anything by itself, it's simply
|
20
|
+
the superclass for SessionManager that does all the boring
|
21
|
+
housekeeping duties.
|
22
|
+
|
23
|
+
Splitted of as a separate file to reduce the complexity
|
24
|
+
of SessionManager.
|
25
|
+
|
26
|
+
=end
|
27
|
+
class SessionStorage
|
28
|
+
attr_accessor :db
|
29
|
+
def initialize
|
30
|
+
## Session data storage (by ses_id)
|
31
|
+
@sessions = {}
|
32
|
+
|
33
|
+
## Session id by key
|
34
|
+
@session_keys = {}
|
35
|
+
|
36
|
+
## Session id by cookie key
|
37
|
+
@session_cookie_keys = {}
|
38
|
+
|
39
|
+
@clone_origins = {
|
40
|
+
# id => [ id, id, id ... ]
|
41
|
+
}
|
42
|
+
@clone_sources = {
|
43
|
+
# id => id
|
44
|
+
}
|
45
|
+
@clone_targets = {
|
46
|
+
# id => [ id, id, id ... ]
|
47
|
+
}
|
48
|
+
|
49
|
+
## Disposable keys (new ses_key each request)
|
50
|
+
@config = ::RSence.config[:session_conf]
|
51
|
+
|
52
|
+
@db_uri = ::RSence.config[:database][:ses_db]
|
53
|
+
|
54
|
+
db_init
|
55
|
+
|
56
|
+
@accept_requests = true
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
attr_reader :accept_requests
|
61
|
+
|
62
|
+
def db_test
|
63
|
+
if @db.table_exists?(:rsence_test)
|
64
|
+
@db.drop_table(:rsence_test)
|
65
|
+
end
|
66
|
+
@db.create_table(:rsence_test) { primary_key :id; String :test }
|
67
|
+
test_id = @db[:rsence_test].insert( :test => 'TestFoo' )
|
68
|
+
@db[:rsence_test].filter( :id => test_id ).update( :test => 'TestFoo2' )
|
69
|
+
@db[:rsence_test].filter( :id => test_id ).delete
|
70
|
+
@db[:rsence_test].delete
|
71
|
+
@db.drop_table(:rsence_test)
|
72
|
+
end
|
73
|
+
|
74
|
+
def db_close
|
75
|
+
@db.disconnect
|
76
|
+
end
|
77
|
+
|
78
|
+
def db_open
|
79
|
+
@db = Sequel.connect(@db_uri)
|
80
|
+
end
|
81
|
+
|
82
|
+
# def db_open
|
83
|
+
# ## Tests if database has sufficient privileges
|
84
|
+
# begin
|
85
|
+
# @db = Sequel.connect(@db_uri)
|
86
|
+
# db_test
|
87
|
+
# db_close
|
88
|
+
# @db = Sequel.connect(@db_uri)
|
89
|
+
# rescue => e
|
90
|
+
# $stderr.write( "SessionStorage: error #{e.inspect}\nReverting to default database.\n" )
|
91
|
+
# @db_uri = "sqlite://#{File.join(SERVER_PATH,'var','db','rsence_ses.db')}"
|
92
|
+
# @db = Sequel.connect(@db_uri)
|
93
|
+
# db_test
|
94
|
+
# db_close
|
95
|
+
# @db = Sequel.connect(@db_uri)
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
|
99
|
+
## Creates the 'rsence_session' table, if necessary
|
100
|
+
## This table is used to store sessions
|
101
|
+
def create_session_table
|
102
|
+
db_open
|
103
|
+
unless @db.table_exists?(:rsence_session)
|
104
|
+
puts "Creating session table..." if $DEBUG_MODE
|
105
|
+
@db.create_table :rsence_session do
|
106
|
+
primary_key( :id )
|
107
|
+
column( :cookie_key, String )
|
108
|
+
column( :ses_key, String )
|
109
|
+
column( :ses_timeout, Integer )
|
110
|
+
column( :user_id, Integer )
|
111
|
+
column( :ses_active, TrueClass )
|
112
|
+
column( :ses_stored, Integer )
|
113
|
+
column( :ses_data, File )
|
114
|
+
end
|
115
|
+
end
|
116
|
+
db_close
|
117
|
+
end
|
118
|
+
|
119
|
+
## Creates the 'rsence_version' table, if necessary
|
120
|
+
## This table is used to check for the need of future database upgrades
|
121
|
+
def create_version_table
|
122
|
+
db_open
|
123
|
+
unless @db.table_exists?(:rsence_version)
|
124
|
+
puts "Creating version info table..." if $DEBUG_MODE
|
125
|
+
@db.create_table :rsence_version do
|
126
|
+
Integer :version
|
127
|
+
end
|
128
|
+
@db[:rsence_version].insert(:version => 586)
|
129
|
+
end
|
130
|
+
db_close
|
131
|
+
end
|
132
|
+
|
133
|
+
## Creates the 'rsence_uploads' table, if necessary
|
134
|
+
## This table is used for storing temporary uploads before processing
|
135
|
+
def create_uploads_table
|
136
|
+
db_open
|
137
|
+
unless @db.table_exists?(:rsence_uploads)
|
138
|
+
puts "Creating uploads table..." if $DEBUG_MODE
|
139
|
+
@db.create_table :rsence_uploads do
|
140
|
+
primary_key( :id )
|
141
|
+
foreign_key( :ses_id, :rsence_session )
|
142
|
+
column( :upload_date, Integer )
|
143
|
+
column( :upload_done, Integer )
|
144
|
+
column( :ticket_id, String )
|
145
|
+
column( :file_size, Integer )
|
146
|
+
column( :file_name, String )
|
147
|
+
column( :file_mime, String )
|
148
|
+
column( :file_data, File )
|
149
|
+
end
|
150
|
+
end
|
151
|
+
db_close
|
152
|
+
end
|
153
|
+
|
154
|
+
# returns the version in the rsence_version table
|
155
|
+
def table_version
|
156
|
+
db_open
|
157
|
+
rsence_version = @db[:rsence_version].select(:version).all[0][:version]
|
158
|
+
db_close
|
159
|
+
return rsence_version
|
160
|
+
end
|
161
|
+
|
162
|
+
## Checks database connectivity and loads stored sessions from the database
|
163
|
+
def db_init
|
164
|
+
|
165
|
+
create_session_table
|
166
|
+
create_version_table
|
167
|
+
create_uploads_table
|
168
|
+
|
169
|
+
## Used for future upgrades:
|
170
|
+
# version = table_version
|
171
|
+
|
172
|
+
if @config[:reset_sessions]
|
173
|
+
puts "Resetting all sessions..."
|
174
|
+
reset_sessions()
|
175
|
+
else
|
176
|
+
restore_sessions()
|
177
|
+
end
|
178
|
+
|
179
|
+
return true
|
180
|
+
end
|
181
|
+
|
182
|
+
## Deletes all rows from rsence_session as well as rsence_uploads
|
183
|
+
def reset_sessions
|
184
|
+
db_open
|
185
|
+
@db[:rsence_session].delete if @db.table_exists?(:rsence_session)
|
186
|
+
@db[:rsence_uploads].delete if @db.table_exists?(:rsence_uploads)
|
187
|
+
db_close
|
188
|
+
end
|
189
|
+
|
190
|
+
## Restores all saved sessions from db to ram
|
191
|
+
def restore_sessions
|
192
|
+
puts "Restoring sessions..." if $DEBUG_MODE
|
193
|
+
db_open
|
194
|
+
@db[:rsence_session].all do |ses_row|
|
195
|
+
ses_id = ses_row[:id]
|
196
|
+
ses_data_dump = ses_row[:ses_data]
|
197
|
+
|
198
|
+
if ses_data_dump == nil
|
199
|
+
@db[:rsence_session].filter(:id => ses_id).delete
|
200
|
+
@db[:rsence_uploads].filter(:ses_id => ses_id).delete
|
201
|
+
else
|
202
|
+
ses_data = Marshal.restore( ses_data_dump )
|
203
|
+
ses_key = ses_data[:ses_key]
|
204
|
+
@sessions[ses_id] = ses_data
|
205
|
+
@session_keys[ ses_key ] = ses_id
|
206
|
+
@session_cookie_keys[ ses_data[:cookie_key] ] = ses_id
|
207
|
+
end
|
208
|
+
end
|
209
|
+
db_close
|
210
|
+
end
|
211
|
+
|
212
|
+
## Stores all sessions to db from ram
|
213
|
+
def store_sessions
|
214
|
+
puts "Storing sessions..." if $DEBUG_MODE
|
215
|
+
db_open
|
216
|
+
@sessions.each_key do |ses_id|
|
217
|
+
ses_data = @sessions[ ses_id ]
|
218
|
+
ses_data_dump = Marshal.dump( ses_data )
|
219
|
+
@db[:rsence_session].filter(
|
220
|
+
:id => ses_id
|
221
|
+
).update(
|
222
|
+
:cookie_key => ses_data[:cookie_key],
|
223
|
+
:ses_key => ses_data[:ses_key],
|
224
|
+
:user_id => ses_data[:user_id],
|
225
|
+
:ses_data => ses_data_dump.to_sequel_blob,
|
226
|
+
:ses_timeout => ses_data[:timeout],
|
227
|
+
:ses_stored => Time.now.to_i
|
228
|
+
)
|
229
|
+
end
|
230
|
+
db_close
|
231
|
+
end
|
232
|
+
|
233
|
+
## Shut-down signal, triggers store_sessions for now
|
234
|
+
def shutdown
|
235
|
+
@accept_requests = false
|
236
|
+
puts "Session shutdown in progress..." if $DEBUG_MODE
|
237
|
+
store_sessions
|
238
|
+
puts "Session shutdown complete." if $DEBUG_MODE
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
## Returns a new, unique session identifier by storing the params to the database
|
243
|
+
def new_ses_id( cookie_key, ses_key, timeout_secs, user_id=0 )
|
244
|
+
db_open
|
245
|
+
new_id = @db[:rsence_session].insert(
|
246
|
+
:cookie_key => cookie_key,
|
247
|
+
:ses_key => ses_key,
|
248
|
+
:ses_timeout => timeout_secs,
|
249
|
+
:user_id => user_id
|
250
|
+
)
|
251
|
+
db_close
|
252
|
+
return new_id
|
253
|
+
end
|
254
|
+
|
255
|
+
## Expires a session by its identifier
|
256
|
+
def expire_session( ses_id )
|
257
|
+
|
258
|
+
return unless @sessions.has_key? ses_id
|
259
|
+
|
260
|
+
ses_data = @sessions[ ses_id ]
|
261
|
+
|
262
|
+
# Makes the session invalid for xhr's by deleting its key
|
263
|
+
@session_keys.delete( ses_data[:ses_key] )
|
264
|
+
|
265
|
+
# Makes the session invalid for all requests by deleting its cookie key
|
266
|
+
@session_cookie_keys.delete( ses_data[:cookie_key] )
|
267
|
+
|
268
|
+
# Deletes the session data itself
|
269
|
+
@sessions.delete( ses_id )
|
270
|
+
|
271
|
+
# Removes all ticket-based storage bound to the session
|
272
|
+
@plugins[:ticketservices].expire_ses( ses_id ) if @plugins
|
273
|
+
|
274
|
+
# target -> source cleanup
|
275
|
+
if @clone_sources.has_key?( ses_id )
|
276
|
+
source_id = @clone_sources[ ses_id ]
|
277
|
+
@clone_sources.delete( ses_id ) if @clone_sources.has_key?( ses_id )
|
278
|
+
@clone_targets[ source_id ].delete( ses_id ) if @clone_targets.has_key?( source_id )
|
279
|
+
end
|
280
|
+
|
281
|
+
# source -> targets cleanup
|
282
|
+
if @clone_targets.has_key?( ses_id )
|
283
|
+
@clone_targets[ ses_id ].each do |target_id|
|
284
|
+
@clone_sources.delete( target_id ) if @clone_sources.has_key?( target_id )
|
285
|
+
end
|
286
|
+
@clone_targets.delete( ses_id ) if @clone_targets.has_key?( ses_id )
|
287
|
+
end
|
288
|
+
|
289
|
+
db_open
|
290
|
+
# Deletes the session's row from the database
|
291
|
+
@db[:rsence_session].filter(:id => ses_id).delete
|
292
|
+
db_close
|
293
|
+
|
294
|
+
end
|
295
|
+
|
296
|
+
## Expires all sessions that meet the timeout criteria
|
297
|
+
def expire_sessions
|
298
|
+
|
299
|
+
# Loop through all sessions in memory:
|
300
|
+
@sessions.each_key do |ses_id|
|
301
|
+
|
302
|
+
timed_out = @sessions[ ses_id ][:timeout] < Time.now.to_i
|
303
|
+
|
304
|
+
## Deletes the session, if the session is too old
|
305
|
+
expire_session( ses_id ) if timed_out
|
306
|
+
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|
313
|
+
|
314
|
+
|
@@ -0,0 +1,254 @@
|
|
1
|
+
#--
|
2
|
+
## Riassence Framework
|
3
|
+
# Copyright 2008 Riassence Inc.
|
4
|
+
# http://riassence.com/
|
5
|
+
#
|
6
|
+
# You should have received a copy of the GNU General Public License along
|
7
|
+
# with this software package. If not, contact licensing@riassence.com
|
8
|
+
##
|
9
|
+
#++
|
10
|
+
|
11
|
+
|
12
|
+
module RSence
|
13
|
+
|
14
|
+
=begin
|
15
|
+
Transporter is the counterpart to the client's HTransporter xhr engine.
|
16
|
+
=end
|
17
|
+
|
18
|
+
class Transporter
|
19
|
+
|
20
|
+
# ValueManager syncronizes value objects
|
21
|
+
require 'values/valuemanager'
|
22
|
+
|
23
|
+
# SessionManager creates, validates, stores and expires sessions
|
24
|
+
require 'session/sessionmanager'
|
25
|
+
|
26
|
+
# PluginManager handles all the plugins
|
27
|
+
require 'plugins/pluginmanager'
|
28
|
+
|
29
|
+
attr_accessor :valuemanager, :sessions, :plugins
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@config = ::RSence.config[:transporter_conf]
|
33
|
+
|
34
|
+
@valuemanager = ValueManager.new
|
35
|
+
@sessions = SessionManager.new( self )
|
36
|
+
@plugins = PluginManager.new( ::RSence.config[:plugin_paths], self, $DEBUG_MODE )
|
37
|
+
|
38
|
+
# Used by:
|
39
|
+
# plugins/main/main.rb
|
40
|
+
$SESSION = @sessions
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def servlet( request_type, request, response )
|
45
|
+
broker_urls = ::RSence.config[:broker_urls]
|
46
|
+
uri = request.fullpath
|
47
|
+
# if $DEBUG_MODE and uri == $config[:index_html][:respond_address] and request_type == :get
|
48
|
+
# unless ARGV.include?('-no-rescan') or ARGV.include?('--no-rescan')
|
49
|
+
# puts "Reloading plugins."
|
50
|
+
# if ARGV.include?('-say')
|
51
|
+
# Thread.new do
|
52
|
+
# Thread.pass
|
53
|
+
# system('say "Reloading plugins."')
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
# @plugins.rescan
|
57
|
+
# puts "Plugins reloaded."
|
58
|
+
# if ARGV.include?('-say')
|
59
|
+
# Thread.new do
|
60
|
+
# Thread.pass
|
61
|
+
# system('say "Plugins reloaded."')
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
|
67
|
+
if request_type == :post
|
68
|
+
## /x handles xhr without cookies
|
69
|
+
if uri == broker_urls[:x] and @sessions.accept_requests
|
70
|
+
xhr( request, response, { :cookies => true, :servlet => false } )
|
71
|
+
return true
|
72
|
+
## /hello handles the first xhr (with cookies, for session key)
|
73
|
+
elsif uri == broker_urls[:hello] and @sessions.accept_requests
|
74
|
+
xhr( request, response, { :cookies => true, :servlet => false } )
|
75
|
+
return true
|
76
|
+
else
|
77
|
+
session = {}
|
78
|
+
return @plugins.match_servlet( request_type, request, response, session )
|
79
|
+
## /SOAP handles SOAP Requests
|
80
|
+
# elsif uri == broker_urls[:soap]
|
81
|
+
# soap( request, response )
|
82
|
+
# return true
|
83
|
+
end
|
84
|
+
else
|
85
|
+
session = {}
|
86
|
+
return @plugins.match_servlet( request_type, request, response, session )
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
## handles incoming SOAP requests
|
91
|
+
# def soap(request, response)
|
92
|
+
# PluginManager.soap( request, response )
|
93
|
+
# end
|
94
|
+
|
95
|
+
# wrapper for the session manager stop client functionality
|
96
|
+
def xhr_error_handler(msg,err_name,err_extra_descr='')
|
97
|
+
@sessions.stop_client_with_message( msg,
|
98
|
+
@config[:messages][err_name][:title],
|
99
|
+
@config[:messages][err_name][:descr]+err_extra_descr,
|
100
|
+
@config[:messages][err_name][:uri]
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
# wrapper for tracebacks in xhr
|
105
|
+
def xhr_traceback_handler(e,err_descr='Transporter::UnspecifiedError')
|
106
|
+
puts "=="*40 if $DEBUG_MODE
|
107
|
+
puts err_descr
|
108
|
+
if $DEBUG_MODE
|
109
|
+
puts "--"*40
|
110
|
+
puts e.message
|
111
|
+
puts " #{e.backtrace.join("\n ")}"
|
112
|
+
puts "=="*40
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
## handles incoming XMLHttpRequests from the browser
|
117
|
+
def xhr(request, response, options = { :cookies => false, :servlet => false } )
|
118
|
+
|
119
|
+
session_conf = ::RSence.config[:session_conf]
|
120
|
+
|
121
|
+
options[:cookies] = false unless options.has_key?(:cookies)
|
122
|
+
|
123
|
+
if session_conf[:session_cookies] and session_conf[:trust_cookies]
|
124
|
+
options[:cookies] = true
|
125
|
+
end
|
126
|
+
|
127
|
+
# Creates the msg object, also checks or creates a new session; verifies session keys and such
|
128
|
+
msg = @sessions.init_msg( request, response, options )
|
129
|
+
|
130
|
+
response_success = true
|
131
|
+
|
132
|
+
# If the client encounters an error, display error message
|
133
|
+
if request.query.has_key?('err_msg')
|
134
|
+
response_success = false
|
135
|
+
client_error_msg = request.query['err_msg'].inspect
|
136
|
+
puts "\nCLIENT ERROR:\n#{client_error_msg}\n" if $DEBUG_MODE
|
137
|
+
xhr_error_handler(msg,:client_error,client_error_msg)
|
138
|
+
end
|
139
|
+
|
140
|
+
# If the session is valid, continue:
|
141
|
+
if msg.ses_valid and response_success
|
142
|
+
|
143
|
+
# If cookies are true, it means the url base needs to
|
144
|
+
# be changed from /hello to /x to prevent further cookie juggling.
|
145
|
+
if options[:cookies] and not options[:servlet]
|
146
|
+
msg.reply("COMM.Transporter.url=#{::RSence.config[:broker_urls][:x].to_json};")
|
147
|
+
end
|
148
|
+
|
149
|
+
# Appends a 'new session.' message for new sessions in $DEBUG_MODE:
|
150
|
+
puts "new session." if msg.new_session and $DEBUG_MODE
|
151
|
+
puts "restored session." if msg.restored_session and $DEBUG_MODE
|
152
|
+
puts "clone source." if msg.cloned_targets and $DEBUG_MODE
|
153
|
+
puts "clone target." if msg.cloned_source and $DEBUG_MODE
|
154
|
+
|
155
|
+
## Pass the client XML to the value manager
|
156
|
+
if request.query.has_key?( 'values' )
|
157
|
+
syncdata_str = request.query[ 'values' ]
|
158
|
+
begin
|
159
|
+
@valuemanager.xhr( msg, syncdata_str )
|
160
|
+
rescue => e
|
161
|
+
response_success = false
|
162
|
+
xhr_error_handler( msg, :valuemanager_xhr_error, e.message )
|
163
|
+
xhr_traceback_handler( e, "Transporter::ValueManagerXHRError: @valuemanager.xhr failed." )
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
## Calls the restore_ses of plugins, when a session is restored (page reload with previously active session)
|
168
|
+
if msg.restored_session
|
169
|
+
|
170
|
+
msg.session[:deps] = []
|
171
|
+
|
172
|
+
if msg.cloned_source
|
173
|
+
begin
|
174
|
+
@plugins.delegate( :cloned_target, msg, msg.cloned_source )
|
175
|
+
rescue => e
|
176
|
+
response_success = false
|
177
|
+
xhr_error_handler( msg, :plugin_delegate_cloned_target_error, e.message )
|
178
|
+
xhr_traceback_handler( e, "Transporter::PluginDelegateClonedTargetError: @plugins.delegate 'cloned_target' failed." )
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
begin
|
183
|
+
@plugins.delegate( :restore_ses, msg )
|
184
|
+
rescue => e
|
185
|
+
response_success = false
|
186
|
+
xhr_error_handler( msg, :plugin_delegate_restore_ses_error, e.message )
|
187
|
+
xhr_traceback_handler( e, "Transporter::PluginDelegateRestoreSesError: @plugins.delegate 'restore_ses' failed." )
|
188
|
+
end
|
189
|
+
|
190
|
+
elsif msg.new_session
|
191
|
+
begin
|
192
|
+
@plugins.delegate( :init_ses, msg )
|
193
|
+
rescue => e
|
194
|
+
response_success = false
|
195
|
+
xhr_error_handler( msg, :plugin_delegate_init_ses_error, e.message )
|
196
|
+
xhr_traceback_handler( e, "Transporter::PluginDelegateInitSesError: @plugins.delegate 'init_ses' failed." )
|
197
|
+
end
|
198
|
+
elsif msg.cloned_targets
|
199
|
+
begin
|
200
|
+
@plugins.delegate( :cloned_source, msg, msg.cloned_targets )
|
201
|
+
rescue => e
|
202
|
+
response_success = false
|
203
|
+
xhr_error_handler( msg, :plugin_delegate_cloned_source_error, e.message )
|
204
|
+
xhr_traceback_handler( e, "Transporter::PluginDelegateClonedSourceError: @plugins.delegate 'cloned_source' failed." )
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
## Calls validators for changed values
|
209
|
+
begin
|
210
|
+
@valuemanager.validate( msg )
|
211
|
+
rescue => e
|
212
|
+
response_success = false
|
213
|
+
xhr_error_handler( msg, :valuemanager_validate_error, e.message )
|
214
|
+
xhr_traceback_handler( e, "Transporter::ValueManagerValidateError: @valuemanager.validate failed." )
|
215
|
+
end
|
216
|
+
|
217
|
+
### Allows every plugin to respond to the idle call
|
218
|
+
begin
|
219
|
+
@plugins.delegate( :idle, msg )
|
220
|
+
rescue => e
|
221
|
+
response_success = false
|
222
|
+
xhr_error_handler( msg, :plugin_idle_error, e.message )
|
223
|
+
xhr_traceback_handler( e, "Transporter::PluginIdleError: @plugins.idle failed." )
|
224
|
+
end
|
225
|
+
|
226
|
+
### Processes outgoing values to client
|
227
|
+
begin
|
228
|
+
@valuemanager.sync_client( msg )
|
229
|
+
rescue => e
|
230
|
+
response_success = false
|
231
|
+
xhr_error_handler( msg, :valuemanager_sync_client_error, e.message )
|
232
|
+
xhr_traceback_handler( e, "Transporter::ValueManagerSyncClientError: @valuemanager.sync_client failed." )
|
233
|
+
end
|
234
|
+
|
235
|
+
else
|
236
|
+
|
237
|
+
# session is not valid, the error was set in SessionManager
|
238
|
+
response_success = false
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
msg.response_success = response_success
|
243
|
+
|
244
|
+
unless options[:servlet]
|
245
|
+
msg.response_done()
|
246
|
+
end
|
247
|
+
|
248
|
+
return msg
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
end
|
253
|
+
|
254
|
+
end
|