Automatic generation produced by ISE Eiffel
indexing
description: "Deferred Class that is a template for all User Data Access Classes"
author: "Marco Piccioni, Peizhu Li"
date: "$Date$"
revision: "$0.6$"
deferred class
USER_MANAGER
feature -- Attributes
user_list: HASH_TABLE [USER, STRING_8]
encryptor: ENCRYPTOR
-- encrypt user login name and password, void to skip encryption
feature --Basic Operations
add_user (a_user: USER)
--adds a user to the userlist
require
a_user_valid: a_user /= Void
user_not_exists: not username_defined (a_user.username)
do
user_list.extend (a_user, a_user.username)
ensure
one_user_added: user_list.count = old user_list.count + 1
end
update_user (a_user: USER)
--update a existing user
require
a_user_valid: a_user /= Void
user_exists: username_defined (a_user.username)
do
user_list.replace (a_user, a_user.username)
ensure
same_user_number: user_list.count = old user_list.count
end
delete_user_by_name (username: STRING_8)
--
require
username_exists: username /= Void and then not username.is_empty and then user_list.has (username)
do
user_list.remove (username)
ensure
one_user_removed: user_list.count = old user_list.count - 1
end
get_user_by_name (username: STRING_8): USER
-- return the USER object identified by username
require
username_exists: username /= Void and then not username.is_empty and then user_list.has (username)
do
Result := user_list [username]
ensure
user_found: Result /= Void
end
username_defined (username: STRING_8): BOOLEAN
--adds a user to the userlist
require
username_valid: username /= Void and then not username.is_empty
do
Result := user_list.has (username)
end
is_user_authentication_valid (username, pass: STRING_8): BOOLEAN
-- check user authentication
require
name_pass_not_empty: username /= Void and then not username.is_empty and then pass /= Void and then not pass.is_empty
do
user_list.start
user_list.search (username)
if user_list.found then
if user_list [username].password.is_equal (pass) then
Result := True
end
end
end
set_encryptor (cryptor: ENCRYPTOR)
-- retrieve the saved session object with given session_id
do
encryptor := cryptor
end
user_count: INTEGER_32
--
do
Result := user_list.count
end
persist_data
deferred
end
invariant
invariant_clause: True
end -- class USER_MANAGER
-- Generated by ISE Eiffel --
For more details: www.eiffel.com