};
cloudeebus.getError = function(error) {
+ if (error.desc && error.uri)
+ return error.desc + " : " + error.uri;
if (error.desc)
return error.desc;
+ if (error.uri)
+ return error.uri;
+ if (error.name && error.message)
+ return error.name + " : " + error.message;
if (error.message)
return error.message;
+ if (error.name)
+ return error.name;
return error;
};
function onWAMPSessionConnectedCB(session) {
cloudeebus.wampSession = session;
- if (manifest)
+ if (manifest) {
cloudeebus.wampSession.authreq(
manifest.name,
- {permissions: manifest.permissions}
+ {permissions: manifest.permissions,
+ services: manifest.services}
).then(onWAMPSessionChallengedCB, onWAMPSessionAuthErrorCB);
+ }
else
cloudeebus.wampSession.authreq().then(function() {
cloudeebus.wampSession.auth().then(onWAMPSessionAuthenticatedCB, onWAMPSessionAuthErrorCB);
cloudeebus.BusConnection.prototype.addService = function(serviceName) {
var self = this;
+
+ if (!serviceName)
+ serviceName = "";
var promise = new cloudeebus.Promise(function (resolver) {
var cloudeebusService = new cloudeebus.Service(self.wampSession, self, serviceName);
OPENDOOR = False
CREDENTIALS = {}
WHITELIST = []
+SERVICELIST = []
NETMASK = []
###############################################################################
self.permissions = {};
self.permissions['permissions'] = permissions['permissions']
self.permissions['authextra'] = permissions['authextra']
+ self.permissions['services'] = permissions['services']
self.proxyObjects = {}
self.proxyMethods = {}
self.pendingCalls = []
busName = list[0]
self.bus = cache.dbusConnexion( busName )
self.srvName = list[1]
- if (self.services.has_key(self.srvName) == False):
+ if not OPENDOOR and (SERVICELIST == [] or SERVICELIST != [] and self.permissions['services'] == None):
+ SERVICELIST.index(self.srvName)
+
+ if (self.services.has_key(self.srvName) == False):
self.services[self.srvName] = dbus.service.BusName(name = self.srvName, bus = self.bus)
return self.srvName
def getAuthPermissions(self, key, extra):
return {'permissions': extra.get("permissions", None),
- 'authextra': extra.get("authextra", None)}
+ 'authextra': extra.get("authextra", None),
+ 'services': extra.get("services", None)}
def getAuthSecret(self, key):
secret = CREDENTIALS.get(key, None)
if key is None:
raise Exception("Authentication failed")
# check permissions, array.index throws exception
- for req in permissions['permissions']:
+ if (permissions['permissions'] != None):
+ for req in permissions['permissions']:
WHITELIST.index(req);
+ # check allowed service creation, array.index throws exception
+ if (permissions['services'] != None):
+ for req in permissions['services']:
+ SERVICELIST.index(req);
# create cloudeebus service instance
self.cloudeebusService = CloudeebusService(permissions)
# register it for RPC
help='path to credentials file')
parser.add_argument('-w', '--whitelist',
help='path to whitelist file')
+ parser.add_argument('-s', '--servicelist',
+ help='path to servicelist file')
parser.add_argument('-n', '--netmask',
help='netmask,IP filter (comma separated.) eg. : -n 127.0.0.1,192.168.2.0/24,10.12.16.0/255.255.255.0')
WHITELIST = json.load(jfile)
jfile.close()
+ if args.servicelist:
+ jfile = open(args.servicelist)
+ SERVICELIST = json.load(jfile)
+ jfile.close()
+
if args.netmask:
iplist = args.netmask.split(",")
for ip in iplist:
mask = "255.255.255.255"
NETMASK.append( {'ipAllowed': ipV4ToHex(ipAllowed), 'mask' : ipV4ToHex(mask)} )
+ if args.debug:
+ print "OPENDOOR='" + str(OPENDOOR) + "'"
+ print "CREDENTIALS='" + str(args.credentials) + "'"
+ print "WHITELIST='" + str(args.whitelist) + "'"
+ print "SERVICELIST='" + str(args.servicelist) + "'"
+ print "NETMASK='" + str(args.netmask) + "'"
+ print
+
uri = "ws://localhost:" + args.port
factory = WampServerFactory(uri, debugWamp = args.debug)