From 09d9ea40895bd2caa158e89723914c85517c013d Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Wed, 4 Apr 2012 18:44:55 +0200 Subject: debug --- coip/apps/saml2/views.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'coip/apps/saml2') diff --git a/coip/apps/saml2/views.py b/coip/apps/saml2/views.py index a04e4d2..d394fd6 100644 --- a/coip/apps/saml2/views.py +++ b/coip/apps/saml2/views.py @@ -14,6 +14,7 @@ from saml2.metadata import entity_descriptor from saml2.saml import NAME_FORMAT_URI from django.conf import settings from django.views.decorators.csrf import csrf_exempt +from saml2.request import AttributeQuery def get_full_path(request,path=None): if path == None: @@ -75,6 +76,29 @@ def metadata(request): ed = entity_descriptor(cnf, 0) return HttpResponse(content=ed,content_type="text/xml") +def parse_attribute_query(aa, xml_string, decode=True): + """ Parse an attribute query + + :param xml_string: The Attribute Query as an XML string + :param decode: Whether the xmlstring is base64encoded and zipped + :return: 3-Tuple containing: + subject - identifier of the subject + attribute - which attributes that the requestor wants back + query - the whole query + """ + receiver_addresses = aa.conf.endpoint("attribute_service") + attribute_query = AttributeQuery( aa.sec, receiver_addresses) + + attribute_query = attribute_query.loads(xml_string, decode=decode) + attribute_query = attribute_query.verify() + logging.info(repr(attribute_query)) + #logging.info("KEYS: %s" % attribute_query.message.keys()) + # Subject is described in the a saml.Subject instance + subject = attribute_query.subject_id() + attribute = attribute_query.attribute() + + return subject, attribute, attribute_query.message + @csrf_exempt def aq(request): if request.method == 'POST': @@ -83,7 +107,7 @@ def aq(request): aa = server.Server(config=cnf, log=logging, debug=1, stype="aa") request_xml = soap.parse_soap_enveloped_saml_attribute_query(request.raw_post_data) logging.debug(request_xml) - (subject, attribute, aq) = aa.parse_attribute_query(request_xml,False) + (subject, attribute, aq) = parse_attribute_query(aa,request_xml,False) sp_entityid = aq.issuer.text claims = {} -- cgit v1.1