def onConnect(self, request): myAES = AESCipher(key) if 'cookie' in request.headers: try: cookie = Cookie.SimpleCookie() cookie.load(str(request.headers['cookie'])) except Cookie.CookieError: pass if ('gtoken' in cookie) and ('wsid' in cookie): gtoken = cookie['gtoken'].value wsid = cookie['wsid'].value user_data = json.loads(myAES.decrypt(wsid)) mycams = CamCheck().cbquery(user_data['user_id']) if mycams == user_data['cams']: return None else: self.sendClose() elif ('wsid' in cookie) and ('PSClient' in request.headers['user-agent']): wsid = cookie['wsid'].value cambot = json.loads(myAES.decrypt(wsid)) if cambot['id'] in request.path: return None else: self.sendClose() else: self.sendClose() else: self.sendClose()
def dispPage(self,request): cookie = request.getCookie('gtoken') if cookie: gitkit_user = gitkit_instance.VerifyGitkitToken(cookie) if gitkit_user: userdetails = {'display_name': gitkit_user.name, 'photo_url':gitkit_user.photo_url} if gitkit_user.photo_url is None: userdetails['photo_url']='/images/home/slider/slide1/cloud1.png' mycams = CamCheck().cbquery(gitkit_user.user_id) if len(mycams) > 0: myAES = AESCipher(key) cookie_data = {'user_id':gitkit_user.user_id,'cams':mycams,'time':long(time.time())} expiry = time.strftime("%a, %d-%b-%Y %T GMT", time.gmtime(time.time()+self.maxAge)) request.addCookie('wsid',myAES.encrypt(json.dumps(cookie_data)),expires=expiry,path=b"/") welcome = PSjinja_env.get_template('user_cam_details.html') request.write(welcome.render(user=userdetails,mycams=mycams).encode('utf-8')) else: request.setResponseCode(401) noauth = PSjinja_env.get_template('not_authorized.html') request.write(noauth.render().encode('utf-8')) else: request.setResponseCode(401) noauth = PSjinja_env.get_template('not_authorized.html') request.write(noauth.render().encode('utf-8')) return request
def makePage(self,request): myAES = AESCipher(key) gtoken = request.getCookie('gtoken') wsid = request.getCookie('wsid') try: vid = int(request.args['vid'][0]) except (KeyError,ValueError,IndexError): vid = None user_data = json.loads(myAES.decrypt(wsid)) gitkit_user = gitkit_instance.VerifyGitkitToken(gtoken) if gitkit_user and user_data['user_id']: userdetails = {'display_name': gitkit_user.name, 'photo_url':gitkit_user.photo_url} if gitkit_user.photo_url is None: userdetails['photo_url']='/images/home/slider/slide1/cloud1.png' mycams = CamCheck().cbquery(gitkit_user.user_id) if mycams == user_data['cams']: try: camid, camname = mycams[vid] except (TypeError,IndexError): camid, camname = mycams[0] wsurl = '/cam/view/'+camid live = PSjinja_env.get_template('live_MSE.html') request.write(live.render(user=userdetails,cam=camname,wsurl=wsurl).encode('utf-8')) return request else: self.errorPage(request) else: self.errorPage(request)
def onConnect(self,request): myAES = AESCipher(key) if 'cookie' in request.headers: try: cookie = Cookie.SimpleCookie() cookie.load(str(request.headers['cookie'])) except Cookie.CookieError: pass if ('gtoken' in cookie) and ('wsid' in cookie): gtoken = cookie['gtoken'].value wsid = cookie['wsid'].value user_data = json.loads(myAES.decrypt(wsid)) mycams = CamCheck().cbquery(user_data['user_id']) if mycams == user_data['cams']: return None else: self.sendClose() elif ('wsid' in cookie) and ('PSClient' in request.headers['user-agent']): wsid = cookie['wsid'].value cambot = json.loads(myAES.decrypt(wsid)) if cambot['id'] in request.path: return None else: self.sendClose() else: self.sendClose() else: self.sendClose()
def onConnect(self, request): myAES = AESCipher(key) if 'cookie' in request.headers: try: cookie = Cookie.SimpleCookie() cookie.load(str(request.headers['cookie'])) except Cookie.CookieError: pass if ('wsid' in cookie) and ('PSClient' in request.headers['user-agent']): wsid = cookie['wsid'].value cambot = json.loads(myAES.decrypt(wsid)) if cambot['id'] in request.path: self.temp_location = self.factory.temp_path.child( cambot['id']) if not self.temp_location.exists(): self.temp_location.makedirs() f = self.temp_location.child(u'index.html') g = FilePath("/home/chetan/pscore/templates/live_hls.html" ).asTextMode() content = g.getContent() new = content.replace("++camid++", cambot['id']) f.setContent(new) return None else: self.sendClose(1000, "Not authorised") else: self.sendClose(1000, "Not authorised") else: self.sendClose(1000, "Not authorised")
def makePage(self,request): myAES = AESCipher(key) gtoken = request.getCookie('gtoken') wsid = request.getCookie('wsid') try: vid = int(request.args['vid'][0]) except (KeyError,ValueError,IndexError): vid = None user_data = json.loads(myAES.decrypt(wsid)) gitkit_user = gitkit_instance.VerifyGitkitToken(gtoken) if gitkit_user and user_data['user_id']: userdetails = {'display_name': gitkit_user.name, 'photo_url':gitkit_user.photo_url} if gitkit_user.photo_url is None: userdetails['photo_url']='/images/home/slider/slide1/cloud1.png' mycams = CamCheck().cbquery(gitkit_user.user_id) if mycams == user_data['cams']: try: camid, camname = mycams[vid] except (TypeError,IndexError): camid, camname = mycams[0] wsurl = '/cam/stream/'+camid live = PSjinja_env.get_template('live.html') request.write(live.render(user=userdetails,cam=camname,wsurl=wsurl).encode('utf-8')) return request else: self.errorPage(request) else: self.errorPage(request)
def onConnect(self,request): myAES = AESCipher(key) if 'cookie' in request.headers: try: cookie = Cookie.SimpleCookie() cookie.load(str(request.headers['cookie'])) except Cookie.CookieError: pass if ('wsid' in cookie) and ('PSClient' in request.headers['user-agent']): wsid = cookie['wsid'].value cambot = json.loads(myAES.decrypt(wsid)) if cambot['id'] in request.path: self.temp_location = self.factory.temp_path.child(cambot['id']) if not self.temp_location.exists(): self.temp_location.makedirs() f = self.temp_location.child(u'index.html') g = FilePath("/home/chetan/pscore/templates/live_hls.html").asTextMode() content = g.getContent() new = content.replace("++camid++",cambot['id']) f.setContent(new) return None else: self.sendClose(1000,"Not authorised") else: self.sendClose(1000,"Not authorised") else: self.sendClose(1000,"Not authorised")
def cbDBRes(self,result,cambot,request): if len(result) == 0: master = None else: camid, master = result myAES = AESCipher(key) cambot['master'] = master expiry = time.strftime("%a, %d-%b-%Y %T GMT", time.gmtime(time.time()+self.maxAge)) cambot['expiry'] = expiry request.addCookie('wsid',myAES.encrypt(json.dumps(cambot)),expires=expiry,path=b"/") request.finish()
def checkAuth(self, request): myAES = AESCipher(key) gtoken = request.getCookie('gtoken') wsid = request.getCookie('wsid') user_data = json.loads(myAES.decrypt(wsid)) gitkit_user = gitkit_instance.VerifyGitkitToken(gtoken) mycams = CamCheck().cbquery(gitkit_user.user_id) if mycams == user_data['cams']: print "1--> {0} authenticated".format(gitkit_user.user_id) return request else: return failure.Failure()
def checkAuth(self,request): myAES = AESCipher(key) gtoken = request.getCookie('gtoken') wsid = request.getCookie('wsid') user_data = json.loads(myAES.decrypt(wsid)) gitkit_user = gitkit_instance.VerifyGitkitToken(gtoken) mycams = CamCheck().cbquery(gitkit_user.user_id) if mycams == user_data['cams']: print "1--> {0} authenticated".format(gitkit_user.user_id) return request else: return failure.Failure()
def checkAuth(self, camid, request): myAES = AESCipher(key) gtoken = request.getCookie('gtoken') wsid = request.getCookie('wsid') try: user_data = json.loads(myAES.decrypt(wsid)) gitkit_user = gitkit_instance.VerifyGitkitToken(gtoken) mycams = CamCheck().cbquery(gitkit_user.user_id) if any(camid in x for x in mycams): self.webAuthenticated = True else: self.webAuthenticated = False except TypeError: self.webAuthenticated = False return self.webAuthenticated
def checkAuth(self,camid,request): myAES = AESCipher(key) gtoken = request.getCookie('gtoken') wsid = request.getCookie('wsid') try: user_data = json.loads(myAES.decrypt(wsid)) gitkit_user = gitkit_instance.VerifyGitkitToken(gtoken) mycams = CamCheck().cbquery(gitkit_user.user_id) if any(camid in x for x in mycams): self.webAuthenticated = True else: self.webAuthenticated = False except TypeError: self.webAuthenticated = False return self.webAuthenticated
def onConnect(self, request): myAES = AESCipher(key) if 'cookie' in request.headers: try: cookie = Cookie.SimpleCookie() cookie.load(str(request.headers['cookie'])) except Cookie.CookieError: pass if ('wsid' in cookie) and ('PSClient' in request.headers['user-agent']): wsid = cookie['wsid'].value cambot = json.loads(myAES.decrypt(wsid)) if cambot['id'] in request.path: self.temp_location = self.factory.temp_path.child( cambot['id']) if not self.temp_location.exists(): self.temp_location.makedirs() f = self.temp_location.child(u'index.html') g = FilePath("/home/chetan/pscore/templates/live_hls.html" ).asTextMode() content = g.getContent() new = content.replace("++camid++", cambot['id']) f.setContent(new) return None else: self.sendClose(1000, "Not authorised") elif ('wsid' in cookie) and ('gtoken' in cookie): wsid = cookie['wsid'].value gtoken = cookie['gtoken'].value user_data = json.loads(myAES.decrypt(wsid)) gitkit_user = gitkit_instance.VerifyGitkitToken(gtoken) mycams = CamCheck().cbquery(gitkit_user.user_id) camid = request.path.split("/")[3] self.temp_location = self.factory.temp_path.child(camid) if any(camid in x for x in mycams): return None else: self.sendClose(1000, "Not authorised") else: self.sendClose(1000, "Not authorised") else: self.sendClose(1000, "Not authorised")
def onConnect(self,request): myAES = AESCipher(key) if 'cookie' in request.headers: try: cookie = Cookie.SimpleCookie() cookie.load(str(request.headers['cookie'])) except Cookie.CookieError: pass if ('wsid' in cookie) and ('PSClient' in request.headers['user-agent']): wsid = cookie['wsid'].value cambot = json.loads(myAES.decrypt(wsid)) if cambot['id'] in request.path: self.temp_location = self.factory.temp_path.child(cambot['id']) if not self.temp_location.exists(): self.temp_location.makedirs() f = self.temp_location.child(u'index.html') g = FilePath("/home/chetan/pscore/templates/live_hls.html").asTextMode() content = g.getContent() new = content.replace("++camid++",cambot['id']) f.setContent(new) return None else: self.sendClose(1000,"Not authorised") elif ('wsid' in cookie) and ('gtoken' in cookie): wsid = cookie['wsid'].value gtoken = cookie['gtoken'].value user_data = json.loads(myAES.decrypt(wsid)) gitkit_user = gitkit_instance.VerifyGitkitToken(gtoken) mycams = CamCheck().cbquery(gitkit_user.user_id) camid = request.path.split("/")[3] self.temp_location = self.factory.temp_path.child(camid) if any(camid in x for x in mycams): return None else: self.sendClose(1000,"Not authorised") else: self.sendClose(1000,"Not authorised") else: self.sendClose(1000,"Not authorised")
def onConnect(self,request): myAES = AESCipher(key) if 'cookie' in request.headers: try: cookie = Cookie.SimpleCookie() cookie.load(str(request.headers['cookie'])) except Cookie.CookieError: pass if ('wsid' in cookie) and ('PSClient' in request.headers['user-agent']): wsid = cookie['wsid'].value cambot = json.loads(myAES.decrypt(wsid)) if cambot['id'] in request.path: return None else: self.sendClose() else: self.sendClose() else: self.sendClose()