Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 import rospy
00020 from privilege import Privilege
00021 import base64
00022
00023
00024
00025 class User(object):
00026
00027 UNKNOWN = 'Unknown'
00028 NONE = UNKNOWN
00029 DEFAULT_LNG = 'en'
00030
00031 def __init__(self, userid = None, privilege = Privilege.NONE):
00032
00033 self.userid = userid or ''
00034 self.created = ''
00035 self.modified = ''
00036 self.connected = ''
00037 self.privilege = privilege
00038 self.password = ''
00039 self.encoded = False
00040 self.language = self.DEFAULT_LNG
00041
00042 if userid is not None:
00043 self.connected = rospy.get_time()
00044
00045 def init(self, userid, privilege):
00046 self.connected = rospy.get_time()
00047 self.userid = userid
00048 self.privilege = privilege
00049
00050 def setUserId(self, user_id):
00051 self.userid = user_id
00052
00053 def getUserId(self):
00054 return self.userid
00055
00056 def setUserPrivilege(self, privilege):
00057 self.privilege = privilege
00058
00059 def getUserPrivilege(self):
00060 return self.privilege
00061
00062 def setUserLanguage(self, lng):
00063 self.language = lng
00064
00065 def getUserLanguage(self):
00066 return self.language
00067
00068 def whenCreated(self):
00069 return self.created
00070
00071 def getWhenUserModified(self):
00072 return self.created
00073
00074 def getUserSinceConnected(self):
00075 return self.connected
00076
00077 def setUserPassword(self, password, encode = True):
00078
00079 if encode:
00080 self.password = base64.b64encode(password)
00081 else:
00082 self.password = password
00083
00084 self.encoded = encode
00085
00086 def getUserPassword(self, decode = False):
00087
00088 if decode:
00089 return base64.b64decode(self.password)
00090 else:
00091 return self.password
00092
00093 def __str__(self):
00094 return 'User[%s,%s]'%(self.userid, Privilege.TOSTR[self.privilege])
00095
00096
00097