Exemplo n.º 1
0
def checkDataStorePriv(conf, ds, priv):
    import json
    import datastores.service as dss
    groups = getGroup(conf)
    path = dss.getPath(conf, ds)
    if len(priv) > 1:
        cpriv = []
        for i in range(0, len(priv)):
            cpriv += [priv[i]]
    else:
        cpriv = [priv]
    try:
        f = open(path + ".mmpriv", "rb")
        priv0 = f.read()
        f.close()
    except:
        #print >> sys.stderr,"Unable to load the following file "+str(path)+".mmpriv"
        return True
    privs = priv0.split("\n")
    privf = []
    for i in privs:
        privf += [i.split(",")]
    cnt = 0
    for i in privf:
        for group in groups:
            if i[0] == group:
                ecnt = 0
                for k in cpriv:
                    for j in range(0, 3):
                        if k == mmatypes[j]:
                            if i[j + 1] == "1" or i[j + 1] == "true":
                                ecnt += 1
                return (len(cpriv) == ecnt)
    return False
Exemplo n.º 2
0
def checkDataStorePriv(conf,ds,priv):
    import json
    import datastores.service as dss
    groups=getGroup(conf)
    path=dss.getPath(conf,ds)
    if len(priv)>1:
        cpriv=[]
        for i in range(0,len(priv)):
            cpriv+=[priv[i]]
    else:
        cpriv=[priv]
    try:
        f=open(path+".mmpriv","rb")
        priv0=f.read()
        f.close()
    except:
        #print >> sys.stderr,"Unable to load the following file "+str(path)+".mmpriv"
        return True
    privs=priv0.split("\n")
    privf=[]
    for i in privs:
        privf+=[i.split(",")]
    cnt=0
    for i in privf:
        for group in groups:
            if i[0]==group:
                ecnt=0
                for k in cpriv:
                    for j in range(0,3):
                        if k==mmatypes[j]:
                            if i[j+1]=="1" or i[j+1]=="true":
                                ecnt+=1
                return (len(cpriv)==ecnt)
    return False
Exemplo n.º 3
0
def checkDataSourcePriv(conf, m, dst, ds, priv):
    if m is None:
        import mapscript
        import datastores.service as dss
        path = dss.getPath(conf, dst)
        try:
            m = mapscript.mapObj(path + "ds_ows.map")
        except Exception, e:
            conf["lenv"]["message"] = zoo._("Unalbe to open the map ") + str(e)
            return False
Exemplo n.º 4
0
def checkDataSourcePriv(conf,m,dst,ds,priv):
    if m is None:
        import mapscript
        import datastores.service as dss
        path=dss.getPath(conf,dst)
        try:
            m=mapscript.mapObj(path+"ds_ows.map")
        except Exception, e:
            conf["lenv"]["message"]=zoo._("Unalbe to open the map ")+str(e)
            return False
Exemplo n.º 5
0
def checkDataSourcePriv(conf,m,dst,ds,priv):
    if m is None:
        import mapscript
        import datastores.service as dss
        path=dss.getPath(conf,dst)
        m=mapscript.mapObj(path+"ds_ows.map")
    if priv.count("w")==0:
        if checkDataStorePriv(conf,dst,"rx"):
            return checkLayerPriv(conf,m,ds,priv)
        else:
            return False
    else:
        if checkDataStorePriv(conf,dst,"rwx"):
            return checkLayerPriv(conf,m,ds,priv)
        else:
            return False
Exemplo n.º 6
0
def checkDataSourcePriv(conf, m, dst, ds, priv):
    if m is None:
        import mapscript
        import datastores.service as dss
        path = dss.getPath(conf, dst)
        m = mapscript.mapObj(path + "ds_ows.map")
    if priv.count("w") == 0:
        if checkDataStorePriv(conf, dst, "rx"):
            return checkLayerPriv(conf, m, ds, priv)
        else:
            return False
    else:
        if checkDataStorePriv(conf, dst, "rwx"):
            return checkLayerPriv(conf, m, ds, priv)
        else:
            return False