{"action":"created","issue":{"url":"https://api.github.com/repos/rohe/pysaml2/issues/282","labels_url":"https://api.github.com/repos/rohe/pysaml2/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/rohe/pysaml2/issues/282/comments","events_url":"https://api.github.com/repos/rohe/pysaml2/issues/282/events","html_url":"https://github.com/rohe/pysaml2/issues/282","id":116141056,"number":282,"title":"Patch to get encryption of an attribute_response","user":{"login":"isaaclw","id":89917,"avatar_url":"https://avatars.githubusercontent.com/u/89917?v=3","gravatar_id":"","url":"https://api.github.com/users/isaaclw","html_url":"https://github.com/isaaclw","followers_url":"https://api.github.com/users/isaaclw/followers","following_url":"https://api.github.com/users/isaaclw/following{/other_user}","gists_url":"https://api.github.com/users/isaaclw/gists{/gist_id}","starred_url":"https://api.github.com/users/isaaclw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaaclw/subscriptions","organizations_url":"https://api.github.com/users/isaaclw/orgs","repos_url":"https://api.github.com/users/isaaclw/repos","events_url":"https://api.github.com/users/isaaclw/events{/privacy}","received_events_url":"https://api.github.com/users/isaaclw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-10T16:18:43Z","updated_at":"2015-11-10T19:55:13Z","closed_at":null,"body":"I'm fairly certain I'm using this library wrong, but I couldn't figure out how to get encryption work for the:\r\n\r\n\"def create_attribute_response\" on the server object.\r\n\r\nI had to:\r\n1) change the function to pass through kwargs. The 'encrypt_assertion' flag was being dropped. (use of args seemed incorrect since it's referencing 'keyword arguments' or kwargs)\r\n2) I also had to add 'sp_entity_id' to the kwargs so that the _response function had that value\r\n3) I had to turn the response to a string before passing it to '_encrypt_assertion' so that the pre_encrypt didn't strip out all the AttribtueStatement entities (this one feels the hacky-est)\r\n\r\nThe customer I'm working for is insisting that we \"initiate\" with Attribute response, so I wonder if we're doing things non-standard. They're using some corporate Java library.\r\n\r\nAnyway, attached is the patch that I used on the library in case that's helpful.\r\n\r\n```\r\ndiff --git a/src/saml2/entity.py b/src/saml2/entity.py\r\nindex 1d191f8..3f04bc2 100644\r\n--- a/src/saml2/entity.py\r\n+++ b/src/saml2/entity.py\r\n@@ -718,7 +718,7 @@ class Entity(HTTPBase):\r\n                     response = signed_instance_factory(response, self.sec,\r\n                                                        to_sign_assertion)\r\n                 response = self._encrypt_assertion(encrypt_cert_assertion,\r\n-                                                   sp_entity_id, response)\r\n+                                                   sp_entity_id, str(response))\r\n             else:\r\n                 if to_sign:\r\n                     response = signed_instance_factory(response, self.sec,\r\ndiff --git a/src/saml2/server.py b/src/saml2/server.py\r\nindex ae2c6f1..a8aea99 100644\r\n--- a/src/saml2/server.py\r\n+++ b/src/saml2/server.py\r\n@@ -465,7 +465,6 @@ class Server(Entity):\r\n                 pass\r\n \r\n         to_sign = []\r\n-        args = {}\r\n         if identity:\r\n             _issuer = self._issuer(issuer)\r\n             ast = Assertion(identity)\r\n@@ -489,10 +488,13 @@ class Server(Entity):\r\n                 # Just the assertion or the response and the assertion ?\r\n                 to_sign = [(class_name(assertion), assertion.id)]\r\n \r\n-            args[\"assertion\"] = assertion\r\n+            kwargs[\"assertion\"] = assertion\r\n+\r\n+        if sp_entity_id:\r\n+            kwargs['sp_entity_id'] = sp_entity_id\r\n \r\n         return self._response(in_response_to, destination, status, issuer,\r\n-                              sign_response, to_sign, **args)\r\n+                              sign_response, to_sign, **kwargs)\r\n \r\n     # ------------------------------------------------------------------------\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/rohe/pysaml2/issues/comments/155548004","html_url":"https://github.com/rohe/pysaml2/issues/282#issuecomment-155548004","issue_url":"https://api.github.com/repos/rohe/pysaml2/issues/282","id":155548004,"user":{"login":"isaaclw","id":89917,"avatar_url":"https://avatars.githubusercontent.com/u/89917?v=3","gravatar_id":"","url":"https://api.github.com/users/isaaclw","html_url":"https://github.com/isaaclw","followers_url":"https://api.github.com/users/isaaclw/followers","following_url":"https://api.github.com/users/isaaclw/following{/other_user}","gists_url":"https://api.github.com/users/isaaclw/gists{/gist_id}","starred_url":"https://api.github.com/users/isaaclw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaaclw/subscriptions","organizations_url":"https://api.github.com/users/isaaclw/orgs","repos_url":"https://api.github.com/users/isaaclw/repos","events_url":"https://api.github.com/users/isaaclw/events{/privacy}","received_events_url":"https://api.github.com/users/isaaclw/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T19:55:13Z","updated_at":"2015-11-10T19:55:13Z","body":"Ok, some other issues, I should have waited till I got everything working. I think most of it might work fine for me if I pass the right flags through to _response from the server object. (which explains my hacky entity patch)"}}