2008-12-02 22:09:34 +00:00
|
|
|
module Msf
|
|
|
|
module RPC
|
|
|
|
class Base
|
|
|
|
|
2010-07-20 20:36:09 +00:00
|
|
|
def initialize(framework,tokens,users)
|
2008-12-02 22:09:34 +00:00
|
|
|
@framework = framework
|
|
|
|
@tokens = tokens
|
|
|
|
@users = users
|
|
|
|
end
|
|
|
|
|
|
|
|
def authenticate(token)
|
2010-03-15 20:16:37 +00:00
|
|
|
|
2008-12-02 22:09:34 +00:00
|
|
|
stale = []
|
|
|
|
@tokens.each_key do |t|
|
2010-03-15 20:16:37 +00:00
|
|
|
user,ctime,mtime,perm = @tokens[t]
|
|
|
|
if ! perm and mtime + 300 < Time.now.to_i
|
2008-12-02 22:09:34 +00:00
|
|
|
stale << t
|
|
|
|
end
|
|
|
|
end
|
2010-03-15 20:16:37 +00:00
|
|
|
|
2008-12-02 22:09:34 +00:00
|
|
|
stale.each { |t| @tokens.delete(t) }
|
2010-03-15 20:16:37 +00:00
|
|
|
|
2008-12-02 22:09:34 +00:00
|
|
|
if(not @tokens[token])
|
|
|
|
raise ::XMLRPC::FaultException.new(401, "authentication error")
|
|
|
|
end
|
2010-03-15 20:16:37 +00:00
|
|
|
|
2008-12-02 22:09:34 +00:00
|
|
|
@tokens[token][2] = Time.now.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-03-15 20:16:37 +00:00
|
|
|
|