Changeset 5667


Ignore:
Timestamp:
25/08/09 13:16:18 (10 years ago)
Author:
pjkersha
Message:

Refactoring SOAPBindingMiddleware to accept a ZSI Service binding input from an upstream middleware component.

Location:
TI12-security/trunk/python
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg_security_server/ndg/security/server/wsgi/attributeauthority.py

    r5666 r5667  
    221221        dictionary 
    222222        """ 
    223         app = AttributeAuthoritySOAPBindingMiddleware(app) 
    224          
    225         optName = prefix + AttributeAuthoritySOAPBindingMiddleware.\ 
    226                                         ATTRIBUTE_AUTHORITY_KEYNAME_CFG_OPTNAME 
    227         defaultValue = AttributeAuthoritySOAPBindingMiddleware.\ 
    228                                         DEFAULT_ATTRIBUTE_AUTHORITY_KEYNAME 
    229                                          
    230         app.keyName = app_conf.get(optName, defaultValue) 
    231          
     223        app = cls(app) 
     224        app.keyName = app_conf.get(cls.ATTRIBUTE_AUTHORITY_KEYNAME_CFG_OPTNAME, 
     225                                   cls.DEFAULT_ATTRIBUTE_AUTHORITY_KEYNAME) 
    232226        return app 
    233227    
  • TI12-security/trunk/python/ndg_security_server/ndg/security/server/wsgi/zsi.py

    r5637 r5667  
    258258         
    259259        super(SOAPBindingMiddleware, self).__init__(*arg, **kw) 
     260        self.__serviceSOAPBinding = None 
     261        self.__enableWSDLQuery = False 
     262 
     263    def _getServiceSOAPBinding(self): 
     264        return self.__serviceSOAPBinding 
     265 
     266    def _setServiceSOAPBinding(self, value): 
     267        """Instance must be ZSI ServiceSOAPBinding derived type""" 
     268        if not isinstance(value, ServiceSOAPBinding): 
     269            raise TypeError('Expecting bool type for "enableWSDLQuery"; got ' 
     270                            '%r' % type(value)) 
     271        self.__serviceSOAPBinding = value 
     272 
     273    serviceSOAPBinding = property(fget=_getServiceSOAPBinding,  
     274                                  fset=_setServiceSOAPBinding,  
     275                                  doc="ServiceSOAPBinding's Docstring") 
     276 
     277    def _getEnableWSDLQuery(self): 
     278        return self.__enableWSDLQuery 
     279 
     280    def _setEnableWSDLQuery(self, value): 
     281        if not isinstance(value, bool): 
     282            raise TypeError('Expecting bool type for "enableWSDLQuery"; got ' 
     283                            '%r' % type(value)) 
     284        self.__enableWSDLQuery = value 
     285         
     286    enableWSDLQuery = property(fget=_getEnableWSDLQuery,  
     287                               fset=_setEnableWSDLQuery,  
     288                               doc="EnableWSDLQuery's Docstring") 
     289 
     290         
     291#        # Check for Service binding in config 
     292#        if 'ServiceSOAPBindingClass' in self.app_conf: 
     293#            modName, className = \ 
     294#                        self.app_conf['ServiceSOAPBindingClass'].rsplit('.', 1) 
     295# 
     296#            self.serviceSOAPBinding = instantiateClass(modName, 
     297#                                   className, 
     298#                                   objectType=ServiceSOAPBinding, 
     299#                                   classProperties=self.serviceSOAPBindingKw)             
     300#        else:  
     301#            self.serviceSOAPBinding = ServiceSOAPBinding() 
     302#         
     303#        # Flag to enable display of WSDL via wsdl query arg in a GET request 
     304#        self.enableWSDLQuery = self.app_conf.get('enableWSDLQuery', False) and\ 
     305#                                hasattr(self.serviceSOAPBinding, '_wsdl') 
     306 
     307    @classmethod 
     308    def filter_app_factory(cls, app, global_conf, **app_conf): 
     309         
     310        app = cls(app) 
    260311         
    261312        # Check for Service binding in config 
    262         if 'ServiceSOAPBindingClass' in self.app_conf: 
     313        if 'ServiceSOAPBindingClass' in app.app_conf: 
    263314            modName, className = \ 
    264                         self.app_conf['ServiceSOAPBindingClass'].rsplit('.', 1) 
     315                            app_conf['ServiceSOAPBindingClass'].rsplit('.', 1) 
    265316 
    266317            self.serviceSOAPBinding = instantiateClass(modName, 
     
    272323         
    273324        # Flag to enable display of WSDL via wsdl query arg in a GET request 
    274         self.enableWSDLQuery = self.app_conf.get('enableWSDLQuery', False) and\ 
     325        app.enableWSDLQuery = self.app_conf.get('enableWSDLQuery', False) and\ 
    275326                                hasattr(self.serviceSOAPBinding, '_wsdl') 
    276  
    277  
     327                                 
     328        # Check for WSGI Service SOAP Binding 
     329        if callable(self.serviceSOAPBinding): 
     330            app = self.serviceSOAPBinding(app) 
     331             
     332        return app 
     333     
    278334    def _getServiceSOAPBindingKw(self): 
    279335        '''Extract keywords to specific to SOAP Service Binding set in app_conf 
     
    320376                                                    'in environ' % i)     
    321377            ps = self.parseRequest(environ) 
    322              
     378                
    323379            # Map SOAP Action to method in binding class 
    324380            soapMethodName = 'soap_%s' % environ['HTTP_SOAPACTION'].strip('"') 
  • TI12-security/trunk/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/site-a.ini

    r5648 r5667  
    1414wsseCfgFilePath = %(here)s/site-a.ini 
    1515wsseCfgFileSection = WS-Security 
     16attributeAuthorityEnvironKeyName = 'attribute-authority' 
     17attributeQueryInterfaceEnvironKeyName = 'attributeQueryInterface' 
    1618 
    1719[server:main] 
     
    2325paste.app_factory = ndg.security.test.config.attributeauthority.sitea.siteAServerApp:app_factory 
    2426 
    25 # Chain of SOAP Middleware filters 
     27# Chain of SOAP Middleware filters - Nb. WS-Security filters apply to the SOAP 
     28# Binding filter only. 
    2629[pipeline:main] 
    27 pipeline = wsseSignatureVerificationFilter  
    28                    AttributeAuthorityFilter  
     30pipeline = AttributeAuthorityFilter  
     31                   wsseSignatureVerificationFilter  
     32                   AttributeAuthoritySOAPBindingFilter 
     33                   SOAPServiceBindingFilter 
    2934                   wsseSignatureFilter  
     35                   AttributeAuthoritySAMLSoapBindingFilter 
    3036                   mainApp 
    3137 
    3238 
    3339[filter:AttributeAuthorityFilter] 
    34 paste.filter_app_factory = ndg.security.server.wsgi.zsi:SOAPBindingMiddleware 
    35 ServiceSOAPBindingClass = ndg.security.server.zsi.attributeauthority.AttributeAuthorityWS 
    36 ServiceSOAPBindingPropPrefix = attributeAuthority 
    37 attributeAuthority.wsseSignatureVerificationFilterID = wsseSignatureVerificationFilter01 
     40paste.filter_app_factory = ndg.security.server.wsgi.attributeauthority:AttributeAuthorityMiddleware.filter_app_factory 
     41prefix = attributeauthority. 
     42 
     43# Key name by which the WSDL SOAP based interface may reference this 
     44# service 
     45attributeauthority.environKeyName = %(attributeAuthorityEnvironKeyName)s 
     46 
     47# Key name for the SAML SOAP binding based interface to reference this 
     48# service's attribute query method 
     49attributeAuthority.environKeyNameAttributeQueryInterface: %(attributeQueryInterfaceEnvironKeyName)s 
    3850 
    3951# Attribute Authority settings 
     
    7385attributeAuthority.caCertFilePathList: $NDGSEC_TEST_CONFIG_DIR/ca/ndg-test-ca.crt 
    7486 
     87 
     88# SOAP WSDL Based Binding to the Attribute Authority 
     89[filter:AttributeAuthoritySOAPBindingFilter] 
     90paste.filter_app_factory = ndg.security.server.wsgi.zsi:SOAPBindingMiddleware 
     91ServiceSOAPBindingClass = ndg.security.server.wsgi.attributeauthority.AttributeAuthoritySOAPBindingMiddleware.filter_app_factory 
     92ServiceSOAPBindingPropPrefix = attributeauthority.soapbinding. 
     93attributeauthority.soapbinding.attributeAuthorityEnvironKeyName = %(attributeAuthorityEnvironKeyName)s 
     94attributeauthority.soapbinding.wsseSignatureVerificationFilterID = wsseSignatureVerificationFilter01 
     95 
    7596referencedFilters = wsseSignatureVerificationFilter01 
    7697path = /AttributeAuthority 
    7798enableWSDLQuery = True 
    7899charset = utf-8 
     100 
     101 
     102# SAML SOAP Binding to the Attribute Authority 
     103[filter:AttributeAuthoritySAMLSoapBindingFilter] 
     104paste.filter_app_factory = ndg.security.server.wsgi.saml:SOAPAttributeInterfaceMiddleware.filter_app_factory 
     105prefix = saml.soapbinding. 
     106 
     107saml.soapbinding.pathMatchList = /attributeauthority/saml 
     108saml.soapbinding.queryInterfaceKeyName = %(attributeQueryInterfaceEnvironKeyName)s 
     109 
    79110 
    80111[filter:wsseSignatureVerificationFilter] 
Note: See TracChangeset for help on using the changeset viewer.