Changeset 3240 for TI02-CSML


Ignore:
Timestamp:
17/01/08 12:07:13 (11 years ago)
Author:
domlowe
Message:

security info now added to csmldocs during scanning

Location:
TI02-CSML/trunk/csml
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/csmllibs/csmlbuilder.py

    r3221 r3240  
    66    #this class contains all the method calls to create and populate a csmldoc 
    77    #it needs to be provided with several bits of information to be able to do this. 
    8     def __init__(self,datasetid, directory,csmlft, mapping, timedimension ,outputfile,printscreen,timestorage,spatialstorage,valuestorage, minaxes): 
     8    def __init__(self,datasetid, directory,csmlft, mapping, timedimension ,outputfile,printscreen,timestorage,spatialstorage,valuestorage, minaxes, secallow, secdeny): 
    99        if datasetid is not None: 
    1010            self.datasetid = datasetid 
     
    2323        self.csml = None  # csml object holds the csml document in memory. 
    2424        self.ds_element = None #<Dataset> tag, root node. 
     25        self.secallow=secallow 
     26        self.secdeny=secdeny 
    2527          
    2628    def build(self): 
     
    3335            print 'error: Cannot find a config file at this location.' 
    3436            sys.exit() 
    35              
     37        self.addSecurity() 
    3638        self.createFeatureFileMap() 
    3739        if self.spatialstorage=='fileextract': 
     
    7476        #self.ds.description=csml.parser.Description(strGmlDescription) 
    7577     
    76     def createCSML(self): 
    77         print "Create CSML" 
    78         #create an empty csml document and dataset tag 
    79         self.csml, self.ds_element = csml.csmllibs.csmlmeta.createDataset() 
    80         #add gml metadata elements 
    81         self.csml, self.ds_element = csml.csmllibs.csmlmeta.addGMLMetadata(self.csml, self.directory, self.ds_element) 
    82  
     78    def addSecurity(self):         
     79        '''Adds NDG style AccessControlPolicy to the dataset based on info in config file''' 
     80        def _buildSimpleCondition(condition): 
     81            #builds the tag structure for a SimpleCondition 
     82            scond=csml.parser.SimpleCondition() 
     83            parts=condition.split(' ') 
     84            attauth=csml.parser.csString(parts[0]) 
     85            role=csml.parser.csString(parts[1])  
     86            scond.attrauthRole=role 
     87            scond.dgAttributeAuthority=attauth 
     88            return scond 
     89         
     90        acp=csml.parser.AccessControlPolicy() 
     91        if self.secallow: 
     92            for condition in self.secallow.split(','): 
     93                dgSecurityCondition=csml.parser.DgSecurityCondition() 
     94                dgSecurityCondition.effect=csml.parser.csString('allow') 
     95                dgSecurityCondition.addChildElem('simpleCondition', _buildSimpleCondition(condition)) 
     96                acp.addChildElem('dgSecurityCondition', dgSecurityCondition) 
     97        if self.secdeny: 
     98            for condition in self.secallow.split(','): 
     99                dgSecurityCondition=csml.parser.DgSecurityCondition() 
     100                dgSecurityCondition.effect=csml.parser.csString('deny') 
     101                dgSecurityCondition.addChildElem('simpleCondition', _buildSimpleCondition(condition)) 
     102                acp.addChildElem('dgSecurityCondition', dgSecurityCondition) 
     103        self.ds.accessControlPolicy=acp        
     104         
    83105    def createFeatureFileMap(self): 
    84106        print "Create FFMAP" 
  • TI02-CSML/trunk/csml/csmlscan.py

    r3239 r3240  
    202202    #build CSML document 
    203203    print ROOTDIRECTORY 
    204     csmldataset=csmllibs.csmlbuilder.csmlBuilder(DATASETID,ROOTDIRECTORY,FEATURETYPE,MAPPING,TIMEDIMENSION, OUTPUTFILE, PRINTSCREEN,TIMESTORAGE,SPATIALSTORAGE,VALUESTORAGE, MINAXES) 
     204    csmldataset=csmllibs.csmlbuilder.csmlBuilder(DATASETID,ROOTDIRECTORY,FEATURETYPE,MAPPING,TIMEDIMENSION, OUTPUTFILE, PRINTSCREEN,TIMESTORAGE,SPATIALSTORAGE,VALUESTORAGE, MINAXES, SEC_ALLOW, SEC_DENY) 
    205205    csmldataset.build() 
    206206 
Note: See TracChangeset for help on using the changeset viewer.