diff --git a/library/server/wsf_extension/src/wsf_handler_helper.e b/library/server/wsf/extension/wsf_handler_helper.e similarity index 100% rename from library/server/wsf_extension/src/wsf_handler_helper.e rename to library/server/wsf/extension/wsf_handler_helper.e diff --git a/library/server/wsf_extension/src/wsf_handler_routes_recorder.e b/library/server/wsf/extension/wsf_handler_routes_recorder.e similarity index 100% rename from library/server/wsf_extension/src/wsf_handler_routes_recorder.e rename to library/server/wsf/extension/wsf_handler_routes_recorder.e diff --git a/library/server/wsf_extension/src/wsf_request_utility.e b/library/server/wsf/extension/wsf_request_utility.e similarity index 100% rename from library/server/wsf_extension/src/wsf_request_utility.e rename to library/server/wsf/extension/wsf_request_utility.e diff --git a/library/server/wsf_extension/src/wsf_resource_handler_helper.e b/library/server/wsf/extension/wsf_resource_handler_helper.e similarity index 100% rename from library/server/wsf_extension/src/wsf_resource_handler_helper.e rename to library/server/wsf/extension/wsf_resource_handler_helper.e diff --git a/library/server/wsf_extension/src/wsf_value_utility.e b/library/server/wsf/extension/wsf_value_utility.e similarity index 100% rename from library/server/wsf_extension/src/wsf_value_utility.e rename to library/server/wsf/extension/wsf_value_utility.e diff --git a/library/server/wsf/router/support/starts_with/wsf_starts_with_handler.e b/library/server/wsf/router/support/starts_with/wsf_starts_with_handler.e index 0da0fc96..3eaa14c3 100644 --- a/library/server/wsf/router/support/starts_with/wsf_starts_with_handler.e +++ b/library/server/wsf/router/support/starts_with/wsf_starts_with_handler.e @@ -18,9 +18,9 @@ feature -- Execution feature {WSF_ROUTER} -- Mapping - new_mapping (a_uri: READABLE_STRING_8): WSF_STARTS_WITH_MAPPING + new_mapping (a_uri: READABLE_STRING_8): WSF_ROUTER_MAPPING do - create Result.make (a_uri, Current) + create {WSF_STARTS_WITH_MAPPING} Result.make (a_uri, Current) end note diff --git a/library/server/wsf/router/support/uri/wsf_uri_handler.e b/library/server/wsf/router/support/uri/wsf_uri_handler.e index 82037a52..04d97f60 100644 --- a/library/server/wsf/router/support/uri/wsf_uri_handler.e +++ b/library/server/wsf/router/support/uri/wsf_uri_handler.e @@ -18,9 +18,9 @@ feature -- Execution feature {WSF_ROUTER} -- Mapping - new_mapping (a_uri: READABLE_STRING_8): WSF_URI_MAPPING + new_mapping (a_uri: READABLE_STRING_8): WSF_ROUTER_MAPPING do - create Result.make (a_uri, Current) + create {WSF_URI_MAPPING} Result.make (a_uri, Current) end note diff --git a/library/server/wsf/router/support/uri_template/wsf_uri_template_handler.e b/library/server/wsf/router/support/uri_template/wsf_uri_template_handler.e index 620a0c74..4e3866d6 100644 --- a/library/server/wsf/router/support/uri_template/wsf_uri_template_handler.e +++ b/library/server/wsf/router/support/uri_template/wsf_uri_template_handler.e @@ -18,9 +18,9 @@ feature -- Execution feature {WSF_ROUTER} -- Mapping - new_mapping (a_tpl: READABLE_STRING_8): WSF_URI_TEMPLATE_MAPPING + new_mapping (a_tpl: READABLE_STRING_8): WSF_ROUTER_MAPPING do - create Result.make (a_tpl, Current) + create {WSF_URI_TEMPLATE_MAPPING} Result.make (a_tpl, Current) end note diff --git a/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_handler.e b/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_handler.e index f430ab6d..28aa3e59 100644 --- a/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_handler.e +++ b/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_handler.e @@ -12,9 +12,9 @@ inherit feature {WSF_ROUTER} -- Mapping - new_mapping (a_tpl: READABLE_STRING_8): WSF_URI_TEMPLATE_CONTEXT_MAPPING [C] + new_mapping (a_tpl: READABLE_STRING_8): WSF_ROUTER_MAPPING do - create Result.make (a_tpl, Current) + create {WSF_URI_TEMPLATE_CONTEXT_MAPPING [C]} Result.make (a_tpl, Current) end note diff --git a/library/server/wsf/session/wsf_cookie_session.e b/library/server/wsf/session/wsf_cookie_session.e new file mode 100644 index 00000000..02551985 --- /dev/null +++ b/library/server/wsf/session/wsf_cookie_session.e @@ -0,0 +1,193 @@ +note + description: "Summary description for {WSF_SESSION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_COOKIE_SESSION + +inherit + WSF_SESSION + +create + make, + make_new + +feature {NONE} -- Initialization + + make (req: WSF_REQUEST; a_cookie_name: detachable like cookie_name; a_manager: WSF_SESSION_MANAGER) + local + l_uuid: detachable READABLE_STRING_32 + do + manager := a_manager + initialize (a_cookie_name) + if attached {WSF_STRING} req.cookie (cookie_name) as c_uuid then + l_uuid := c_uuid.value + elseif attached {WSF_STRING} req.query_parameter (cookie_name) as q_uuid then + l_uuid := q_uuid.value + end + if l_uuid /= Void and then session_exists (l_uuid) then + uuid := l_uuid + load + else + is_pending := True + build + end + end + + make_new (a_cookie_name: detachable like cookie_name; a_manager: WSF_SESSION_MANAGER) + do + manager := a_manager + initialize (a_cookie_name) + is_pending := True + build + end + + initialize (a_cookie_name: detachable like cookie_name) + do + if a_cookie_name = Void or else a_cookie_name.is_empty then + cookie_name := "_EWF_SESSION_ID" + else + cookie_name := a_cookie_name + end + end + +feature -- Cookie + + apply_to (h: HTTP_HEADER; a_request: WSF_REQUEST; a_path: detachable READABLE_STRING_8) + local + dt: detachable DATE_TIME + l_domain: detachable READABLE_STRING_8 + do + l_domain := a_request.server_name + if l_domain.same_string ("localhost") then + -- Due to limitation of specific handling of local cookies + -- it is recommended to use Void or IP instead of "localhost" + l_domain := Void + end + if is_destroyed then + h.put_cookie (cookie_name, "deleted", "Thu, 01 Jan 1970 00:00:00 GMT", a_path, l_domain, False, True) + else + dt := expiration + if dt = Void then + create dt.make_now_utc + dt.day_add (40) + end + h.put_cookie_with_expiration_date (cookie_name, uuid, dt, a_path, l_domain, False, True) + end + end + + cookie_name: READABLE_STRING_8 + +feature -- Access + + uuid: READABLE_STRING_8 + + data: WSF_SESSION_DATA + + expiration: detachable DATE_TIME + +feature -- status + + is_pending: BOOLEAN + + is_destroyed: BOOLEAN + +feature -- Control + + destroy + do + is_destroyed := True + data.wipe_out + delete + end + + commit + do + save + end + + set_expiration (dt: like expiration) + do + expiration := dt + end + +feature {NONE} -- Storage + + manager: WSF_SESSION_MANAGER + + session_exists (a_uuid: like uuid): BOOLEAN + do + Result := manager.session_exists (a_uuid) + end + + init_data + do + create data.make (0) + data.compare_objects + end + + sessions_folder_name: READABLE_STRING_8 + local + dn: DIRECTORY_NAME + once + create dn.make_from_string ((create {EXECUTION_ENVIRONMENT}).current_working_directory) + dn.extend ("_sessions_") + Result := dn.string + end + + load + do + if manager.session_exists (uuid) then + if attached manager.session_data (uuid) as d then + data := d + set_expiration (data.expiration) + else + init_data + save + end + else + build + end + rescue + print ("ouch") + end + + build + do + uuid := uuid_generator.generate_uuid.out + init_data + save + end + + save + do + manager.save_session (Current) + end + + delete + do + manager.delete_session (Current) + end + +feature {NONE} -- Implementation + + uuid_generator: UUID_GENERATOR + once + create Result + end + +note + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end + diff --git a/library/server/wsf/session/wsf_fs_session_manager.e b/library/server/wsf/session/wsf_fs_session_manager.e new file mode 100644 index 00000000..459fe911 --- /dev/null +++ b/library/server/wsf/session/wsf_fs_session_manager.e @@ -0,0 +1,160 @@ +note + description: "Summary description for {WSF_FS_SESSION_MANAGER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_FS_SESSION_MANAGER + +inherit + WSF_SESSION_MANAGER + +create + make, + make_with_folder + +feature {NONE} -- Initialization + + make + do + make_with_folder ("_WSF_SESSIONS_") + end + + make_with_folder (a_folder: like sessions_folder_name) + do + sessions_folder_name := a_folder + end + + sessions_folder_name: STRING_8 + +feature -- Access + + session_exists (a_session_uuid: like {WSF_SESSION}.uuid): BOOLEAN + local + f: RAW_FILE + do + create f.make (file_name (a_session_uuid)) + Result := f.exists and then f.is_readable + end + + session_data (a_session_uuid: like {WSF_SESSION}.uuid): detachable like {WSF_SESSION}.data + local + f: RAW_FILE + do + create f.make (file_name (a_session_uuid)) + if f.exists and then f.is_readable then + f.open_read + if attached data_from_file (f) as d then + Result := d + end + f.close + end + rescue + debug + print ("Error occurred in " + generator) + end + end + +feature -- Persistence + + save_session (a_session: WSF_SESSION) + local + f: RAW_FILE + rescued: BOOLEAN + do + if not rescued then + if a_session.is_destroyed then + delete_session (a_session) + else + ensure_session_folder_exists + create f.make (file_name (a_session.uuid)) + if not f.exists or else f.is_writable then + f.create_read_write + a_session.data.set_expiration (a_session.expiration) + f.general_store (a_session.data) + f.close + end + end + end + rescue + debug + io.error.put_string (generator + ": trouble saving session") + end + rescued := True + retry + end + + delete_session (a_session: WSF_SESSION) + local + f: RAW_FILE + rescued: BOOLEAN + do + if not rescued then + create f.make (file_name (a_session.uuid)) + if f.exists then + f.delete + end + end + rescue + debug + io.error.put_string (generator + ": trouble deleting session") + end + rescued := True + retry + end + +feature {NONE} -- Implementation + + data_from_file (f: FILE): detachable like session_data + require + f.is_open_read and f.is_readable + local + rescued: BOOLEAN + do + if + not rescued and then + attached {like session_data} f.retrieved as d + then + Result := d + end + rescue + debug + --FIXME + io.error.put_string (generator + ": incompatible session content") + end + rescued := True + retry + end + + ensure_session_folder_exists + local + d: DIRECTORY + once + create d.make (sessions_folder_name) + if not d.exists then + d.recursive_create_dir + end + ensure + sessions_folder_exists_and_writable: sessions_folder_exists_and_writable + end + + sessions_folder_exists_and_writable: BOOLEAN + local + d: DIRECTORY + do + create d.make (sessions_folder_name) + Result := d.exists and then d.is_writable + end + + file_name (a_uuid: like {WSF_SESSION}.uuid): READABLE_STRING_8 + local + fn: FILE_NAME + do + create fn.make_from_string (sessions_folder_name) + fn.set_file_name (a_uuid.out) + fn.add_extension ("session") + Result := fn.string + end + +end diff --git a/library/server/wsf/session/wsf_session.e b/library/server/wsf/session/wsf_session.e new file mode 100644 index 00000000..eca5db08 --- /dev/null +++ b/library/server/wsf/session/wsf_session.e @@ -0,0 +1,97 @@ +note + description: "Summary description for {WSF_SESSION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_SESSION + +feature -- Access + + uuid: READABLE_STRING_8 + deferred + end + + data: WSF_SESSION_DATA + deferred + end + + expiration: detachable DATE_TIME + deferred + end + + expired: BOOLEAN + do + if attached expiration as e then + Result := e < (create {DATE_TIME}.make_now_utc) + end + end +feature -- status + + is_pending: BOOLEAN + -- New session pending to be applied? + -- i.e: sent back to the client + deferred + end + + is_destroyed: BOOLEAN + deferred + end + +feature -- Entries + + table: TABLE_ITERABLE [detachable ANY, READABLE_STRING_32] + do + Result := data + end + + item (k: READABLE_STRING_GENERAL): detachable ANY + do + Result := data.item (table_key (k)) + end + + remember (v: detachable ANY; k: READABLE_STRING_GENERAL) + do + data.force (v, table_key (k)) + end + + forget (k: READABLE_STRING_GENERAL) + do + data.remove (table_key (k)) + end + +feature {NONE} -- Implementation + + table_key (k: READABLE_STRING_GENERAL): STRING_32 + do + Result := k.as_string_32 + end + +feature -- Control + + destroy + deferred + end + + commit + deferred + end + + apply_to (h: HTTP_HEADER; a_request: WSF_REQUEST; a_path: detachable READABLE_STRING_8) + deferred + end + +note + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end + diff --git a/library/server/wsf/session/wsf_session_data.e b/library/server/wsf/session/wsf_session_data.e new file mode 100644 index 00000000..a7675ec0 --- /dev/null +++ b/library/server/wsf/session/wsf_session_data.e @@ -0,0 +1,27 @@ +note + description: "Summary description for {WSF_SESSION_DATA}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_SESSION_DATA + +inherit + HASH_TABLE [detachable ANY, READABLE_STRING_32] + +create + make + +feature -- Access + + expiration: detachable DATE_TIME + +feature -- Element change + + set_expiration (dt: like expiration) + do + expiration := dt + end + +end diff --git a/library/server/wsf/session/wsf_session_factory.e b/library/server/wsf/session/wsf_session_factory.e new file mode 100644 index 00000000..ac690f80 --- /dev/null +++ b/library/server/wsf/session/wsf_session_factory.e @@ -0,0 +1,16 @@ +note + description: "Summary description for {WSF_SESSION_FACTORY}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_SESSION_FACTORY [G -> WSF_SESSION] + +feature -- Access + + new_session (req: WSF_REQUEST; a_reuse: BOOLEAN; m: WSF_SESSION_MANAGER): G + deferred + end + +end diff --git a/library/server/wsf/session/wsf_session_manager.e b/library/server/wsf/session/wsf_session_manager.e new file mode 100644 index 00000000..7d08073f --- /dev/null +++ b/library/server/wsf/session/wsf_session_manager.e @@ -0,0 +1,30 @@ +note + description: "Summary description for {WSF_SESSION_MANAGER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_SESSION_MANAGER + +feature -- Access + + session_exists (a_uuid: like {WSF_SESSION}.uuid): BOOLEAN + deferred + end + + session_data (a_uuid: like {WSF_SESSION}.uuid): detachable like {WSF_SESSION}.data + deferred + end + +feature -- Persistence + + save_session (a_session: WSF_SESSION) + deferred + end + + delete_session (a_session: WSF_SESSION) + deferred + end + +end diff --git a/library/server/wsf_extension/wsf_extension-safe.ecf b/library/server/wsf/wsf_extension-safe.ecf similarity index 93% rename from library/server/wsf_extension/wsf_extension-safe.ecf rename to library/server/wsf/wsf_extension-safe.ecf index 1e644b30..ab34a5f3 100644 --- a/library/server/wsf_extension/wsf_extension-safe.ecf +++ b/library/server/wsf/wsf_extension-safe.ecf @@ -13,6 +13,6 @@ - + diff --git a/library/server/wsf_extension/wsf_extension.ecf b/library/server/wsf/wsf_extension.ecf similarity index 93% rename from library/server/wsf_extension/wsf_extension.ecf rename to library/server/wsf/wsf_extension.ecf index d9c06cc9..e3622f9b 100644 --- a/library/server/wsf_extension/wsf_extension.ecf +++ b/library/server/wsf/wsf_extension.ecf @@ -13,6 +13,6 @@ - + diff --git a/library/server/wsf/wsf_session-safe.ecf b/library/server/wsf/wsf_session-safe.ecf new file mode 100644 index 00000000..0c679d78 --- /dev/null +++ b/library/server/wsf/wsf_session-safe.ecf @@ -0,0 +1,20 @@ + + + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + + + + diff --git a/library/server/wsf/wsf_session.ecf b/library/server/wsf/wsf_session.ecf new file mode 100644 index 00000000..5c2e26b0 --- /dev/null +++ b/library/server/wsf/wsf_session.ecf @@ -0,0 +1,20 @@ + + + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + + + + diff --git a/library/server/wsf_extension/license.lic b/library/server/wsf_extension/license.lic deleted file mode 100644 index d4d72876..00000000 --- a/library/server/wsf_extension/license.lic +++ /dev/null @@ -1,10 +0,0 @@ -${NOTE_KEYWORD} - copyright: "2011-${YEAR}, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" - license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" - source: "[ - Eiffel Software - 5949 Hollister Ave., Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com - ]"