Package ndg :: Package saml :: Package saml2 :: Package binding :: Package soap :: Package client :: Module subjectquery
[hide private]

Source Code for Module ndg.saml.saml2.binding.soap.client.subjectquery

 1  """SAML 2.0 bindings module implements SOAP binding for subject query 
 2   
 3  NERC DataGrid Project 
 4  """ 
 5  __author__ = "P J Kershaw" 
 6  __date__ = "12/02/10" 
 7  __copyright__ = "(C) 2010 Science and Technology Facilities Council" 
 8  __license__ = "http://www.apache.org/licenses/LICENSE-2.0" 
 9  __contact__ = "Philip.Kershaw@stfc.ac.uk" 
10  __revision__ = '$Id: subjectquery.py 8047 2012-03-28 09:46:29Z rwilkinson $' 
11  import logging 
12  log = logging.getLogger(__name__) 
13   
14  from ndg.saml.saml2.core import SubjectQuery, Subject, NameID 
15  from ndg.saml.saml2.binding.soap.client import SOAPBindingInvalidResponse 
16  from ndg.saml.saml2.binding.soap.client.requestbase import ( 
17      RequestBaseSOAPBinding,) 
18   
19 -class SubjectQueryResponseError(SOAPBindingInvalidResponse):
20 """SAML Response error from Subject Query"""
21 22
23 -class SubjectQuerySOAPBinding(RequestBaseSOAPBinding):
24 """SAML Subject Query SOAP Binding 25 """ 26 SUBJECT_ID_OPTNAME = 'subjectID' 27 SUBJECT_ID_FORMAT_OPTNAME = 'subjectIdFormat' 28 29 CONFIG_FILE_OPTNAMES = ( 30 SUBJECT_ID_OPTNAME, 31 SUBJECT_ID_FORMAT_OPTNAME 32 ) 33 34 __PRIVATE_ATTR_PREFIX = "__" 35 __slots__ = tuple([__PRIVATE_ATTR_PREFIX + i 36 for i in CONFIG_FILE_OPTNAMES]) 37 del i 38 39 QUERY_TYPE = SubjectQuery 40
41 - def __init__(self, **kw):
42 '''Create SOAP Client for a SAML Subject Query''' 43 self.__subjectIdFormat = None 44 super(SubjectQuerySOAPBinding, self).__init__(**kw)
45
46 - def addQueryAttributes(self, query):
47 """Adds to a query attributes that are configured for 48 SubjectQuerySOAPBinding. 49 """ 50 super(SubjectQuerySOAPBinding, self).addQueryAttributes(query) 51 # Initialise a Subject with the configured format. 52 query.subject = Subject() 53 nameID = NameID() 54 nameID.format = self.subjectIdFormat 55 query.subject.nameID = nameID
56
57 - def _getSubjectIdFormat(self):
58 return self.__subjectIdFormat
59
60 - def _setSubjectIdFormat(self, value):
62 63 subjectIdFormat = property(_getSubjectIdFormat, _setSubjectIdFormat, 64 doc="Subject Name ID format") 65
66 - def setQuerySubjectId(self, query, subjectID):
67 """Sets the subject ID for a query created by SubjectQuerySOAPBinding or 68 a derived class. 69 """ 70 if not query.subject: 71 query.subject = Subject() 72 nameID = NameID() 73 nameID.format = self.subjectIdFormat 74 query.subject.nameID.value = subjectID
75