Changeset 5356 for cowsclient


Ignore:
Timestamp:
05/06/09 12:26:16 (10 years ago)
Author:
domlowe
Message:

NDG Security working with Openlayers client. Version as cowsclient 0.1.0.

Location:
cowsclient/cowsclient
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cowsclient/cowsclient/controllers/wmsviz.py

    r5336 r5356  
    1818import copy, logging 
    1919log = logging.getLogger(__name__) 
     20import urllib 
    2021 
    2122class WmsvizController(BaseController): 
     
    2930        g.helpIcon='layout/icons/help.png'  #needs to go in config 
    3031         
    31          
     32 
    3233        self.inputs=dict(parse_querystring(request.environ)) 
    3334        log.info(self.inputs) 
     
    3940        if 'REQUEST' in self.inputs:             
    4041            if self.inputs['REQUEST'] == 'GetWebMapContext': 
    41                 log.debug('request is in inputs and is of getwmapcontext') 
    42                 return GetWebMapContext(self) 
     42                wmc= GetWebMapContext(self)                     
     43                return wmc 
    4344            elif self.inputs['REQUEST'] == 'GetLegend': 
    4445                return GetLegend(self) 
     
    5859                 
    5960        if ('ENDPOINT' in self.inputs): 
     61            log.info('endpoint') 
     62         
     63            urlstring=str(self.inputs['ENDPOINT']) 
     64            req = urllib2.Request(urlstring) 
     65            req.add_header('Cookie', request.headers.get('Cookie', '')) 
     66            try: 
     67                    filehandle = urllib2.urlopen(req) 
     68            except urllib2.HTTPError, e: 
     69                if e.code == 401: 
     70                    log.info ('401 unauthorized error in cowsclient') 
     71                    return abort(401) #triggers ndg security framework 
     72                elif e.code == 403:  #TODO: 403 response is UNTESTED. 
     73                    # User is authenticated but doesn't have the required permissions 
     74                    # or an error occurred in the authorization process 
     75                    # Read response 
     76                    response = e.read() 
     77                    # Send response to user 
     78                    self.start_response("%d %s" % (e.code, e.msg), e.headers.dict.items()) 
     79                    return response 
    6080            self.addViewItem(self.inputs['ENDPOINT']) 
    6181         
  • cowsclient/cowsclient/lib/wmc_util.py

    r5340 r5356  
    77and getting associated legend data 
    88 
    9 @author: Calum Byrom 
     9@author: Calum Byrom, modified for NDG Security by Dominic Lowe 
    1010""" 
    1111from cowsclient.lib.base import * 
     
    8484        raise exceptions.MissingParameterValue, "ENDPOINT parameter required" 
    8585    log.info('Getting WebMapContext from endpoint: ' + endpoint)    
    86      
     86    urlstring=('%s&request=GetContext'%(str(endpoint))) 
    8787    #cookies are passed to enable authorisation mechanisms e.g. ndg security 
    88     try: 
    89         req = urllib2.Request(endpoint,urllib.urlencode(request.params),{'Cookie': request.headers.get('Cookie', '')}) 
    90         filehandle = urllib2.urlopen(req) 
    91     except IOError: 
    92         raise exceptions.URLUnavailable, "Could not access WMC endpoint: %s" % endpoint 
     88    #try: 
     89 
     90    req = urllib2.Request(urlstring) 
     91    req.add_header('Cookie', request.headers.get('Cookie', '')) 
     92    filehandle = urllib2.urlopen(req) 
    9393    return filehandle.read() 
    94          
Note: See TracChangeset for help on using the changeset viewer.