Beispiel #1
0
    def _getObjectAcl(self):

        self._LOGGER.info("getting the object acl")

        grantList = self.application.objectSrv.getObjectACL(
            self.s3Request.BUCKET, self.s3Request.OBJECT, self.getUser(), self.s3Request.ID_REQUEST
        )

        if len(grantList) == 0:
            return {"AccessControlPolicy": {"Owner": {"ID": self.user.uid, "DisplayName": ""}}}

        # FIXME MOVE IN Service object->Dict convertion
        outList = []
        for grant in grantList:
            grants = ""
            grants += '<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">'
            grants += "<ID>%s</ID>" % grant.uid
            grants += "<DisplayName></DisplayName>"
            grants += "</Grantee>"
            grants += "<Permission>%s</Permission>" % ACPHelper.permToS3Acl(grant.permission)
            outList.append(grants)

        self._LOGGER.debug("Outlist : %s" % outList)
        return {
            "AccessControlPolicy": {
                "Owner": {"ID": self.user.uid, "DisplayName": ""},
                "AccessControlList": {"Grant": outList},
            }
        }
Beispiel #2
0
    def _getBucketLogging(self):

        self._LOGGER.info('Getting the logging of the bucket')
        #FIXME move object to dict in service
        loggingList = self.application.bucketSrv.getBucketLogging(self.s3Request.BUCKET,self.getUser(),self.s3Request.ID_REQUEST)
        self._LOGGER.debug('LoggingList : %s' % loggingList)         
        if loggingList == []:
            return {'BucketLoggingStatus xmlns="http://doc.s3.amazonaws.com/2006-03-01': None }

        
        outList = []
        if loggingList :
            for grant in loggingList:
                grants = ""
                grants +='<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser>'
                grants += "<ID>%s</ID>" % grant.uid
                grants +='</Grantee>'
                grants += "<Permission>%s</Permission>" % ACPHelper.permToS3Acl(grant.permission)
                outList.append(grants)                     
        self._LOGGER.debug('Outlist : %s' % loggingList) 
          
      
        return {"BucketLoggingStatus ": {
             "LoggingEnabled"  :  {"TargetBucket": self.fsRequest.BUCKET,
                                   "TargetPrefix": 'valore'},
                                   "TargetGrants": {
                                                    "Grant": outList}
             }
         }
Beispiel #3
0
    def _getObjectAcl(self):

        self._LOGGER.info("getting the object acl")

        grantList = self.application.objectSrv.getObjectACL(
            self.s3Request.BUCKET, self.s3Request.OBJECT, self.getUser(),
            self.s3Request.ID_REQUEST)

        if len(grantList) == 0:
            return {
                "AccessControlPolicy": {
                    "Owner": {
                        "ID": self.user.uid,
                        "DisplayName": ""
                    }
                }
            }

        #FIXME MOVE IN Service object->Dict convertion
        outList = []
        for grant in grantList:
            grants = ""
            grants += '<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">'
            grants += "<ID>%s</ID>" % grant.uid
            grants += "<DisplayName></DisplayName>"
            grants += '</Grantee>'
            grants += "<Permission>%s</Permission>" % ACPHelper.permToS3Acl(
                grant.permission)
            outList.append(grants)

        self._LOGGER.debug('Outlist : %s' % outList)
        return {
            "AccessControlPolicy": {
                "Owner": {
                    "ID": self.user.uid,
                    "DisplayName": ""
                },
                "AccessControlList": {
                    "Grant": outList
                }
            }
        }
Beispiel #4
0
    def _getBucketLogging(self):

        self._LOGGER.info('Getting the logging of the bucket')
        #FIXME move object to dict in service
        loggingList = self.application.bucketSrv.getBucketLogging(
            self.s3Request.BUCKET, self.getUser(), self.s3Request.ID_REQUEST)
        self._LOGGER.debug('LoggingList : %s' % loggingList)
        if loggingList == []:
            return {
                'BucketLoggingStatus xmlns="http://doc.s3.amazonaws.com/2006-03-01':
                None
            }

        outList = []
        if loggingList:
            for grant in loggingList:
                grants = ""
                grants += '<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser>'
                grants += "<ID>%s</ID>" % grant.uid
                grants += '</Grantee>'
                grants += "<Permission>%s</Permission>" % ACPHelper.permToS3Acl(
                    grant.permission)
                outList.append(grants)
        self._LOGGER.debug('Outlist : %s' % loggingList)

        return {
            "BucketLoggingStatus ": {
                "LoggingEnabled": {
                    "TargetBucket": self.fsRequest.BUCKET,
                    "TargetPrefix": 'valore'
                },
                "TargetGrants": {
                    "Grant": outList
                }
            }
        }