{"action":"created","comment":{"url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/comments/85102289","pull_request_review_id":5836561,"id":85102289,"diff_hunk":"@@ -0,0 +1,88 @@\n+<?php\n+\n+/**\n+ * Copyright 2016 SURFnet B.V.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+namespace OpenConext\\EngineBlockApiClientBundle\\Service;\n+\n+use OpenConext\\EngineBlockApiClientBundle\\Http\\JsonApiClient;\n+use OpenConext\\Profile\\Value\\Consent;\n+use OpenConext\\Profile\\Value\\ConsentList;\n+use OpenConext\\Profile\\Value\\SpecifiedConsent;\n+use OpenConext\\Profile\\Value\\SpecifiedConsentList;\n+use OpenConext\\ProfileBundle\\Attribute\\AttributeSetWithFallbacks;\n+use Surfnet\\SamlBundle\\SAML2\\Attribute\\Attribute;\n+use Surfnet\\SamlBundle\\SAML2\\Attribute\\AttributeSetInterface;\n+\n+final class AttributeReleasePolicyService\n+{\n+    /**\n+     * @var JsonApiClient\n+     */\n+    private $jsonApiClient;\n+\n+    public function __construct(JsonApiClient $jsonApiClient)\n+    {\n+        $this->jsonApiClient = $jsonApiClient;\n+    }\n+\n+    /**\n+     * @param ConsentList $consentList\n+     * @param AttributeSetInterface $attributeSet\n+     * @return SpecifiedConsentList\n+     */\n+    public function applyAttributeReleasePolicies(ConsentList $consentList, AttributeSetInterface $attributeSet)\n+    {\n+        $entityIds = $consentList->map(function (Consent $consent) {\n+            return $consent->getServiceProvider()->getEntity()->getEntityId()->getEntityId();\n+        });\n+\n+        $mappedAttributes = [];\n+        $definitions = [];\n+        foreach ($attributeSet as $attribute) {\n+            $name = $attribute->getAttributeDefinition()->getUrnMace();\n+\n+            if ($name === null) {\n+                $name = $attribute->getAttributeDefinition()->getUrnOid();\n+            }\n+\n+            $mappedAttributes[$name] = $attribute->getValue();\n+\n+            // Remember the attribute definitions so we can more easily build the attributes again\n+            $definitions[$name] = $attribute->getAttributeDefinition();\n+        }\n+\n+        $response = $this->jsonApiClient->post('/arp', [\n+            'entityIds'  => $entityIds,\n+            'attributes' => $mappedAttributes","path":"src/OpenConext/EngineBlockApiClientBundle/Service/AttributeReleasePolicyService.php","position":70,"original_position":70,"commit_id":"ac373308608aca1b9c94d98857c103fd6ed9fd83","original_commit_id":"ac373308608aca1b9c94d98857c103fd6ed9fd83","user":{"login":"arothuis","id":3816591,"avatar_url":"https://avatars.githubusercontent.com/u/3816591?v=3","gravatar_id":"","url":"https://api.github.com/users/arothuis","html_url":"https://github.com/arothuis","followers_url":"https://api.github.com/users/arothuis/followers","following_url":"https://api.github.com/users/arothuis/following{/other_user}","gists_url":"https://api.github.com/users/arothuis/gists{/gist_id}","starred_url":"https://api.github.com/users/arothuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arothuis/subscriptions","organizations_url":"https://api.github.com/users/arothuis/orgs","repos_url":"https://api.github.com/users/arothuis/repos","events_url":"https://api.github.com/users/arothuis/events{/privacy}","received_events_url":"https://api.github.com/users/arothuis/received_events","type":"User","site_admin":false},"body":"I know you can't always assume this will hold, but JSON's `[]` and `{}` are converted back to `[]` on the server side because we're decoding to arrays. I'm not sure about this.","created_at":"2016-10-26T11:33:46Z","updated_at":"2016-10-26T11:33:46Z","html_url":"https://github.com/OpenConext/OpenConext-profile/pull/70#discussion_r85102289","pull_request_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/70","_links":{"self":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/comments/85102289"},"html":{"href":"https://github.com/OpenConext/OpenConext-profile/pull/70#discussion_r85102289"},"pull_request":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/70"}}},"pull_request":{"url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/70","id":90396656,"html_url":"https://github.com/OpenConext/OpenConext-profile/pull/70","diff_url":"https://github.com/OpenConext/OpenConext-profile/pull/70.diff","patch_url":"https://github.com/OpenConext/OpenConext-profile/pull/70.patch","issue_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/70","number":70,"state":"open","locked":false,"title":"Apply attribute release policy to attributes under My Services","user":{"login":"arothuis","id":3816591,"avatar_url":"https://avatars.githubusercontent.com/u/3816591?v=3","gravatar_id":"","url":"https://api.github.com/users/arothuis","html_url":"https://github.com/arothuis","followers_url":"https://api.github.com/users/arothuis/followers","following_url":"https://api.github.com/users/arothuis/following{/other_user}","gists_url":"https://api.github.com/users/arothuis/gists{/gist_id}","starred_url":"https://api.github.com/users/arothuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arothuis/subscriptions","organizations_url":"https://api.github.com/users/arothuis/orgs","repos_url":"https://api.github.com/users/arothuis/repos","events_url":"https://api.github.com/users/arothuis/events{/privacy}","received_events_url":"https://api.github.com/users/arothuis/received_events","type":"User","site_admin":false},"body":"This implements #51.\r\n\r\nRelates to OpenConext/OpenConext-engineblock#350.","created_at":"2016-10-21T14:46:42Z","updated_at":"2016-10-26T11:33:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"036ad0994c59e2ef5ea79da9e9b989c9994bccb5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/70/commits","review_comments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/70/comments","review_comment_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/70/comments","statuses_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/statuses/ac373308608aca1b9c94d98857c103fd6ed9fd83","head":{"label":"OpenConext:feature/apply-attribute-release-policy","ref":"feature/apply-attribute-release-policy","sha":"ac373308608aca1b9c94d98857c103fd6ed9fd83","user":{"login":"OpenConext","id":1457650,"avatar_url":"https://avatars.githubusercontent.com/u/1457650?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenConext","html_url":"https://github.com/OpenConext","followers_url":"https://api.github.com/users/OpenConext/followers","following_url":"https://api.github.com/users/OpenConext/following{/other_user}","gists_url":"https://api.github.com/users/OpenConext/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenConext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenConext/subscriptions","organizations_url":"https://api.github.com/users/OpenConext/orgs","repos_url":"https://api.github.com/users/OpenConext/repos","events_url":"https://api.github.com/users/OpenConext/events{/privacy}","received_events_url":"https://api.github.com/users/OpenConext/received_events","type":"Organization","site_admin":false},"repo":{"id":44533794,"name":"OpenConext-profile","full_name":"OpenConext/OpenConext-profile","owner":{"login":"OpenConext","id":1457650,"avatar_url":"https://avatars.githubusercontent.com/u/1457650?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenConext","html_url":"https://github.com/OpenConext","followers_url":"https://api.github.com/users/OpenConext/followers","following_url":"https://api.github.com/users/OpenConext/following{/other_user}","gists_url":"https://api.github.com/users/OpenConext/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenConext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenConext/subscriptions","organizations_url":"https://api.github.com/users/OpenConext/orgs","repos_url":"https://api.github.com/users/OpenConext/repos","events_url":"https://api.github.com/users/OpenConext/events{/privacy}","received_events_url":"https://api.github.com/users/OpenConext/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenConext/OpenConext-profile","description":"Shows user's attributes and other profile information","fork":false,"url":"https://api.github.com/repos/OpenConext/OpenConext-profile","forks_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/forks","keys_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/teams","hooks_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/hooks","issue_events_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/events{/number}","events_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/events","assignees_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/assignees{/user}","branches_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/branches{/branch}","tags_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/tags","blobs_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/languages","stargazers_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/stargazers","contributors_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/contributors","subscribers_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/subscribers","subscription_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/subscription","commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/contents/{+path}","compare_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/merges","archive_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/downloads","issues_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues{/number}","pulls_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/labels{/name}","releases_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/releases{/id}","deployments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/deployments","created_at":"2015-10-19T12:42:43Z","updated_at":"2016-06-03T07:56:40Z","pushed_at":"2016-10-25T14:05:41Z","git_url":"git://github.com/OpenConext/OpenConext-profile.git","ssh_url":"git@github.com:OpenConext/OpenConext-profile.git","clone_url":"https://github.com/OpenConext/OpenConext-profile.git","svn_url":"https://github.com/OpenConext/OpenConext-profile","homepage":null,"size":2756,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"develop"}},"base":{"label":"OpenConext:develop","ref":"develop","sha":"d6a0ede4a93203823efe631fc993c230a51d6637","user":{"login":"OpenConext","id":1457650,"avatar_url":"https://avatars.githubusercontent.com/u/1457650?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenConext","html_url":"https://github.com/OpenConext","followers_url":"https://api.github.com/users/OpenConext/followers","following_url":"https://api.github.com/users/OpenConext/following{/other_user}","gists_url":"https://api.github.com/users/OpenConext/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenConext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenConext/subscriptions","organizations_url":"https://api.github.com/users/OpenConext/orgs","repos_url":"https://api.github.com/users/OpenConext/repos","events_url":"https://api.github.com/users/OpenConext/events{/privacy}","received_events_url":"https://api.github.com/users/OpenConext/received_events","type":"Organization","site_admin":false},"repo":{"id":44533794,"name":"OpenConext-profile","full_name":"OpenConext/OpenConext-profile","owner":{"login":"OpenConext","id":1457650,"avatar_url":"https://avatars.githubusercontent.com/u/1457650?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenConext","html_url":"https://github.com/OpenConext","followers_url":"https://api.github.com/users/OpenConext/followers","following_url":"https://api.github.com/users/OpenConext/following{/other_user}","gists_url":"https://api.github.com/users/OpenConext/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenConext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenConext/subscriptions","organizations_url":"https://api.github.com/users/OpenConext/orgs","repos_url":"https://api.github.com/users/OpenConext/repos","events_url":"https://api.github.com/users/OpenConext/events{/privacy}","received_events_url":"https://api.github.com/users/OpenConext/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenConext/OpenConext-profile","description":"Shows user's attributes and other profile information","fork":false,"url":"https://api.github.com/repos/OpenConext/OpenConext-profile","forks_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/forks","keys_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/teams","hooks_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/hooks","issue_events_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/events{/number}","events_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/events","assignees_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/assignees{/user}","branches_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/branches{/branch}","tags_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/tags","blobs_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/languages","stargazers_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/stargazers","contributors_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/contributors","subscribers_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/subscribers","subscription_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/subscription","commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/contents/{+path}","compare_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/merges","archive_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/downloads","issues_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues{/number}","pulls_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/labels{/name}","releases_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/releases{/id}","deployments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/deployments","created_at":"2015-10-19T12:42:43Z","updated_at":"2016-06-03T07:56:40Z","pushed_at":"2016-10-25T14:05:41Z","git_url":"git://github.com/OpenConext/OpenConext-profile.git","ssh_url":"git@github.com:OpenConext/OpenConext-profile.git","clone_url":"https://github.com/OpenConext/OpenConext-profile.git","svn_url":"https://github.com/OpenConext/OpenConext-profile","homepage":null,"size":2756,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/70"},"html":{"href":"https://github.com/OpenConext/OpenConext-profile/pull/70"},"issue":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/70"},"comments":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/70/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/70/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/70/commits"},"statuses":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/statuses/ac373308608aca1b9c94d98857c103fd6ed9fd83"}}}}
{"actor":{"display_login":"arothuis"}}