summaryrefslogtreecommitdiffstats
path: root/sample/soap/authheader/authmgr.rb
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-03 15:38:36 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-03 15:38:36 +0000
commit6133b96d61c705c7aefdf6f577f0da5796bc522d (patch)
treece6b571d063d031d1b5cba3ba7671ca138405a3a /sample/soap/authheader/authmgr.rb
parent70105b2706511a6358a32b805fb55f187e942698 (diff)
downloadruby-6133b96d61c705c7aefdf6f577f0da5796bc522d.tar.gz
ruby-6133b96d61c705c7aefdf6f577f0da5796bc522d.tar.xz
ruby-6133b96d61c705c7aefdf6f577f0da5796bc522d.zip
This commit was manufactured by cvs2svn to create branch 'ruby_1_8'.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/soap/authheader/authmgr.rb')
-rw-r--r--sample/soap/authheader/authmgr.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/sample/soap/authheader/authmgr.rb b/sample/soap/authheader/authmgr.rb
new file mode 100644
index 000000000..a4d3b66c0
--- /dev/null
+++ b/sample/soap/authheader/authmgr.rb
@@ -0,0 +1,41 @@
+class Authmgr
+ def initialize
+ @users = {
+ 'NaHi' => 'passwd',
+ 'HiNa' => 'wspass'
+ }
+ @sessions = {}
+ end
+
+ def login(userid, passwd)
+ userid and passwd and @users[userid] == passwd
+ end
+
+ # returns userid
+ def auth(sessionid)
+ @sessions[sessionid]
+ end
+
+ def create_session(userid)
+ while true
+ key = create_sessionkey
+ break unless @sessions[key]
+ end
+ @sessions[key] = userid
+ key
+ end
+
+ def get_session(userid)
+ @sessions.index(userid)
+ end
+
+ def destroy_session(sessionkey)
+ @sessions.delete(sessionkey)
+ end
+
+private
+
+ def create_sessionkey
+ Time.now.usec.to_s
+ end
+end