comparison src/server/server.py @ 605:917e271975d9 frontends_multi_profiles

server + browser side: implementation of new getEntitiesData bridge method + added a security check: only a white list of entities can be gotten
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:46:15 +0100
parents a5019e62c3e9
children ea27925ef2a8
comparison
equal deleted inserted replaced
600:32dbbc941123 605:917e271975d9
32 32
33 from sat.core.log import getLogger 33 from sat.core.log import getLogger
34 log = getLogger(__name__) 34 log = getLogger(__name__)
35 from sat_frontends.bridge.DBus import DBusBridgeFrontend, BridgeExceptionNoService, const_TIMEOUT as BRIDGE_TIMEOUT 35 from sat_frontends.bridge.DBus import DBusBridgeFrontend, BridgeExceptionNoService, const_TIMEOUT as BRIDGE_TIMEOUT
36 from sat.core.i18n import _, D_ 36 from sat.core.i18n import _, D_
37 from sat.core import exceptions
37 from sat.tools.xml_tools import paramsXML2XMLUI 38 from sat.tools.xml_tools import paramsXML2XMLUI
38 39
39 import re 40 import re
40 import glob 41 import glob
41 import os.path 42 import os.path
461 except: 462 except:
462 log.warning('Invalid room jid') 463 log.warning('Invalid room jid')
463 return 464 return
464 self.sat_host.bridge.radiocolLaunch(invited, room_jid, profile) 465 self.sat_host.bridge.radiocolLaunch(invited, room_jid, profile)
465 466
467 def jsonrpc_getEntitiesData(self, jids, keys):
468 """Get cached data for several entities at once
469
470 @param jids: list jids from who we wants data, or empty list for all jids in cache
471 @param keys: name of data we want (list)
472 @return: requested data"""
473 if not C.ALLOWED_ENTITY_DATA.issuperset(keys):
474 raise exceptions.PermissionError("Trying to access unallowed data (hack attempt ?)")
475 profile = ISATSession(self.session).profile
476 try:
477 return self.sat_host.bridge.getEntitiesData(jids, keys, profile)
478 except Exception as e:
479 raise Failure(jsonrpclib.Fault(C.ERRNUM_BRIDGE_ERRBACK, unicode(e)))
480
466 def jsonrpc_getEntityData(self, jid, keys): 481 def jsonrpc_getEntityData(self, jid, keys):
467 """Get cached data for an entit 482 """Get cached data for an entity
483
468 @param jid: jid of contact from who we want data 484 @param jid: jid of contact from who we want data
469 @param keys: name of data we want (list) 485 @param keys: name of data we want (list)
470 @return: requested data""" 486 @return: requested data"""
487 if not C.ALLOWED_ENTITY_DATA.issuperset(keys):
488 raise exceptions.PermissionError("Trying to access unallowed data (hack attempt ?)")
471 profile = ISATSession(self.session).profile 489 profile = ISATSession(self.session).profile
472 try: 490 try:
473 return self.sat_host.bridge.getEntityData(jid, keys, profile) 491 return self.sat_host.bridge.getEntityData(jid, keys, profile)
474 except Exception as e: 492 except Exception as e:
475 raise Failure(jsonrpclib.Fault(C.ERRNUM_BRIDGE_ERRBACK, unicode(e))) 493 raise Failure(jsonrpclib.Fault(C.ERRNUM_BRIDGE_ERRBACK, unicode(e)))
476 494
477 def jsonrpc_getCard(self, jid): 495 def jsonrpc_getCard(self, jid_):
478 """Get VCard for entiry 496 """Get VCard for entiry
479 @param jid: jid of contact from who we want data 497 @param jid_: jid of contact from who we want data
480 @return: id to retrieve the profile""" 498 @return: id to retrieve the profile"""
481 profile = ISATSession(self.session).profile 499 profile = ISATSession(self.session).profile
482 return self.sat_host.bridge.getCard(jid, profile) 500 return self.sat_host.bridge.getCard(jid_, profile)
483 501
484 def jsonrpc_getAccountDialogUI(self): 502 def jsonrpc_getAccountDialogUI(self):
485 """Get the dialog for managing user account 503 """Get the dialog for managing user account
486 @return: XML string of the XMLUI""" 504 @return: XML string of the XMLUI"""
487 profile = ISATSession(self.session).profile 505 profile = ISATSession(self.session).profile