{"action":"created","comment":{"url":"https://api.github.com/repos/OSGP/Shared/pulls/comments/63495382","id":63495382,"diff_hunk":"@@ -0,0 +1,104 @@\n+/**\n+ * Copyright 2016 Smart Society Services B.V.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License.  You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ */\n+package com.alliander.osgp.shared.security;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.nio.file.Files;\n+import java.security.InvalidAlgorithmParameterException;\n+import java.security.InvalidKeyException;\n+import java.security.NoSuchAlgorithmException;\n+import java.security.NoSuchProviderException;\n+import java.util.Arrays;\n+\n+import javax.crypto.BadPaddingException;\n+import javax.crypto.Cipher;\n+import javax.crypto.IllegalBlockSizeException;\n+import javax.crypto.NoSuchPaddingException;\n+import javax.crypto.SecretKey;\n+import javax.crypto.spec.IvParameterSpec;\n+import javax.crypto.spec.SecretKeySpec;\n+\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import com.alliander.osgp.shared.exceptionhandling.EncrypterException;\n+\n+/**\n+ * Encryption service class that offers encrypt and decrypt methods to encrypt\n+ * or decrypt data.\n+ *\n+ * Both methods accept a file location path, which should lead to the location\n+ * of the secret key.\n+ */\n+public final class EncryptionService {\n+    private static final Logger LOGGER = LoggerFactory.getLogger(EncryptionService.class);\n+    /**\n+     * the algorithm used\n+     */\n+    public static final String ALGORITHM = \"AES/CBC/PKCS7PADDING\";\n+    /**\n+     * the id of the provider used\n+     */\n+    public static final String PROVIDER = \"BC\";\n+\n+    private final SecretKey key;\n+    private static final byte[] IVBYTES = new byte[16];\n+\n+    static {\n+        for (short s = 0; s < IVBYTES.length; s++) {","path":"shared/src/main/java/com/alliander/osgp/shared/security/EncryptionService.java","position":54,"original_position":54,"commit_id":"79e4d268cdbb64099afe38c0a25389e3f050528b","original_commit_id":"79e4d268cdbb64099afe38c0a25389e3f050528b","user":{"login":"hannek24","id":6457709,"avatar_url":"https://avatars.githubusercontent.com/u/6457709?v=3","gravatar_id":"","url":"https://api.github.com/users/hannek24","html_url":"https://github.com/hannek24","followers_url":"https://api.github.com/users/hannek24/followers","following_url":"https://api.github.com/users/hannek24/following{/other_user}","gists_url":"https://api.github.com/users/hannek24/gists{/gist_id}","starred_url":"https://api.github.com/users/hannek24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannek24/subscriptions","organizations_url":"https://api.github.com/users/hannek24/orgs","repos_url":"https://api.github.com/users/hannek24/repos","events_url":"https://api.github.com/users/hannek24/events{/privacy}","received_events_url":"https://api.github.com/users/hannek24/received_events","type":"User","site_admin":false},"body":"I don't see the reason why this kind of initialization is necessary. Ether remove the initialization or explain why this is necessary.","created_at":"2016-05-17T09:59:54Z","updated_at":"2016-05-17T09:59:55Z","html_url":"https://github.com/OSGP/Shared/pull/103#discussion_r63495382","pull_request_url":"https://api.github.com/repos/OSGP/Shared/pulls/103","_links":{"self":{"href":"https://api.github.com/repos/OSGP/Shared/pulls/comments/63495382"},"html":{"href":"https://github.com/OSGP/Shared/pull/103#discussion_r63495382"},"pull_request":{"href":"https://api.github.com/repos/OSGP/Shared/pulls/103"}}},"pull_request":{"url":"https://api.github.com/repos/OSGP/Shared/pulls/103","id":70185980,"html_url":"https://github.com/OSGP/Shared/pull/103","diff_url":"https://github.com/OSGP/Shared/pull/103.diff","patch_url":"https://github.com/OSGP/Shared/pull/103.patch","issue_url":"https://api.github.com/repos/OSGP/Shared/issues/103","number":103,"state":"open","locked":false,"title":"Slim 562 decryption problems","user":{"login":"eduarddrenth","id":10200360,"avatar_url":"https://avatars.githubusercontent.com/u/10200360?v=3","gravatar_id":"","url":"https://api.github.com/users/eduarddrenth","html_url":"https://github.com/eduarddrenth","followers_url":"https://api.github.com/users/eduarddrenth/followers","following_url":"https://api.github.com/users/eduarddrenth/following{/other_user}","gists_url":"https://api.github.com/users/eduarddrenth/gists{/gist_id}","starred_url":"https://api.github.com/users/eduarddrenth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduarddrenth/subscriptions","organizations_url":"https://api.github.com/users/eduarddrenth/orgs","repos_url":"https://api.github.com/users/eduarddrenth/repos","events_url":"https://api.github.com/users/eduarddrenth/events{/privacy}","received_events_url":"https://api.github.com/users/eduarddrenth/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-16T11:52:03Z","updated_at":"2016-05-17T09:59:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c5c8e30b1434b1087159be03252ce03d57ddcf6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OSGP/Shared/pulls/103/commits","review_comments_url":"https://api.github.com/repos/OSGP/Shared/pulls/103/comments","review_comment_url":"https://api.github.com/repos/OSGP/Shared/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OSGP/Shared/issues/103/comments","statuses_url":"https://api.github.com/repos/OSGP/Shared/statuses/79e4d268cdbb64099afe38c0a25389e3f050528b","head":{"label":"OSGP:SLIM-562-decryption-problems","ref":"SLIM-562-decryption-problems","sha":"79e4d268cdbb64099afe38c0a25389e3f050528b","user":{"login":"OSGP","id":11352045,"avatar_url":"https://avatars.githubusercontent.com/u/11352045?v=3","gravatar_id":"","url":"https://api.github.com/users/OSGP","html_url":"https://github.com/OSGP","followers_url":"https://api.github.com/users/OSGP/followers","following_url":"https://api.github.com/users/OSGP/following{/other_user}","gists_url":"https://api.github.com/users/OSGP/gists{/gist_id}","starred_url":"https://api.github.com/users/OSGP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSGP/subscriptions","organizations_url":"https://api.github.com/users/OSGP/orgs","repos_url":"https://api.github.com/users/OSGP/repos","events_url":"https://api.github.com/users/OSGP/events{/privacy}","received_events_url":"https://api.github.com/users/OSGP/received_events","type":"Organization","site_admin":false},"repo":{"id":32739219,"name":"Shared","full_name":"OSGP/Shared","owner":{"login":"OSGP","id":11352045,"avatar_url":"https://avatars.githubusercontent.com/u/11352045?v=3","gravatar_id":"","url":"https://api.github.com/users/OSGP","html_url":"https://github.com/OSGP","followers_url":"https://api.github.com/users/OSGP/followers","following_url":"https://api.github.com/users/OSGP/following{/other_user}","gists_url":"https://api.github.com/users/OSGP/gists{/gist_id}","starred_url":"https://api.github.com/users/OSGP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSGP/subscriptions","organizations_url":"https://api.github.com/users/OSGP/orgs","repos_url":"https://api.github.com/users/OSGP/repos","events_url":"https://api.github.com/users/OSGP/events{/privacy}","received_events_url":"https://api.github.com/users/OSGP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OSGP/Shared","description":"Shared libraries.","fork":false,"url":"https://api.github.com/repos/OSGP/Shared","forks_url":"https://api.github.com/repos/OSGP/Shared/forks","keys_url":"https://api.github.com/repos/OSGP/Shared/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OSGP/Shared/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OSGP/Shared/teams","hooks_url":"https://api.github.com/repos/OSGP/Shared/hooks","issue_events_url":"https://api.github.com/repos/OSGP/Shared/issues/events{/number}","events_url":"https://api.github.com/repos/OSGP/Shared/events","assignees_url":"https://api.github.com/repos/OSGP/Shared/assignees{/user}","branches_url":"https://api.github.com/repos/OSGP/Shared/branches{/branch}","tags_url":"https://api.github.com/repos/OSGP/Shared/tags","blobs_url":"https://api.github.com/repos/OSGP/Shared/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OSGP/Shared/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OSGP/Shared/git/refs{/sha}","trees_url":"https://api.github.com/repos/OSGP/Shared/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OSGP/Shared/statuses/{sha}","languages_url":"https://api.github.com/repos/OSGP/Shared/languages","stargazers_url":"https://api.github.com/repos/OSGP/Shared/stargazers","contributors_url":"https://api.github.com/repos/OSGP/Shared/contributors","subscribers_url":"https://api.github.com/repos/OSGP/Shared/subscribers","subscription_url":"https://api.github.com/repos/OSGP/Shared/subscription","commits_url":"https://api.github.com/repos/OSGP/Shared/commits{/sha}","git_commits_url":"https://api.github.com/repos/OSGP/Shared/git/commits{/sha}","comments_url":"https://api.github.com/repos/OSGP/Shared/comments{/number}","issue_comment_url":"https://api.github.com/repos/OSGP/Shared/issues/comments{/number}","contents_url":"https://api.github.com/repos/OSGP/Shared/contents/{+path}","compare_url":"https://api.github.com/repos/OSGP/Shared/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OSGP/Shared/merges","archive_url":"https://api.github.com/repos/OSGP/Shared/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OSGP/Shared/downloads","issues_url":"https://api.github.com/repos/OSGP/Shared/issues{/number}","pulls_url":"https://api.github.com/repos/OSGP/Shared/pulls{/number}","milestones_url":"https://api.github.com/repos/OSGP/Shared/milestones{/number}","notifications_url":"https://api.github.com/repos/OSGP/Shared/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OSGP/Shared/labels{/name}","releases_url":"https://api.github.com/repos/OSGP/Shared/releases{/id}","deployments_url":"https://api.github.com/repos/OSGP/Shared/deployments","created_at":"2015-03-23T15:02:43Z","updated_at":"2016-01-21T15:07:04Z","pushed_at":"2016-05-17T07:40:45Z","git_url":"git://github.com/OSGP/Shared.git","ssh_url":"git@github.com:OSGP/Shared.git","clone_url":"https://github.com/OSGP/Shared.git","svn_url":"https://github.com/OSGP/Shared","homepage":null,"size":803,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"development"}},"base":{"label":"OSGP:development","ref":"development","sha":"a0db75aee1eeabffeb079cfcc13fd8fd911ee427","user":{"login":"OSGP","id":11352045,"avatar_url":"https://avatars.githubusercontent.com/u/11352045?v=3","gravatar_id":"","url":"https://api.github.com/users/OSGP","html_url":"https://github.com/OSGP","followers_url":"https://api.github.com/users/OSGP/followers","following_url":"https://api.github.com/users/OSGP/following{/other_user}","gists_url":"https://api.github.com/users/OSGP/gists{/gist_id}","starred_url":"https://api.github.com/users/OSGP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSGP/subscriptions","organizations_url":"https://api.github.com/users/OSGP/orgs","repos_url":"https://api.github.com/users/OSGP/repos","events_url":"https://api.github.com/users/OSGP/events{/privacy}","received_events_url":"https://api.github.com/users/OSGP/received_events","type":"Organization","site_admin":false},"repo":{"id":32739219,"name":"Shared","full_name":"OSGP/Shared","owner":{"login":"OSGP","id":11352045,"avatar_url":"https://avatars.githubusercontent.com/u/11352045?v=3","gravatar_id":"","url":"https://api.github.com/users/OSGP","html_url":"https://github.com/OSGP","followers_url":"https://api.github.com/users/OSGP/followers","following_url":"https://api.github.com/users/OSGP/following{/other_user}","gists_url":"https://api.github.com/users/OSGP/gists{/gist_id}","starred_url":"https://api.github.com/users/OSGP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSGP/subscriptions","organizations_url":"https://api.github.com/users/OSGP/orgs","repos_url":"https://api.github.com/users/OSGP/repos","events_url":"https://api.github.com/users/OSGP/events{/privacy}","received_events_url":"https://api.github.com/users/OSGP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OSGP/Shared","description":"Shared libraries.","fork":false,"url":"https://api.github.com/repos/OSGP/Shared","forks_url":"https://api.github.com/repos/OSGP/Shared/forks","keys_url":"https://api.github.com/repos/OSGP/Shared/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OSGP/Shared/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OSGP/Shared/teams","hooks_url":"https://api.github.com/repos/OSGP/Shared/hooks","issue_events_url":"https://api.github.com/repos/OSGP/Shared/issues/events{/number}","events_url":"https://api.github.com/repos/OSGP/Shared/events","assignees_url":"https://api.github.com/repos/OSGP/Shared/assignees{/user}","branches_url":"https://api.github.com/repos/OSGP/Shared/branches{/branch}","tags_url":"https://api.github.com/repos/OSGP/Shared/tags","blobs_url":"https://api.github.com/repos/OSGP/Shared/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OSGP/Shared/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OSGP/Shared/git/refs{/sha}","trees_url":"https://api.github.com/repos/OSGP/Shared/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OSGP/Shared/statuses/{sha}","languages_url":"https://api.github.com/repos/OSGP/Shared/languages","stargazers_url":"https://api.github.com/repos/OSGP/Shared/stargazers","contributors_url":"https://api.github.com/repos/OSGP/Shared/contributors","subscribers_url":"https://api.github.com/repos/OSGP/Shared/subscribers","subscription_url":"https://api.github.com/repos/OSGP/Shared/subscription","commits_url":"https://api.github.com/repos/OSGP/Shared/commits{/sha}","git_commits_url":"https://api.github.com/repos/OSGP/Shared/git/commits{/sha}","comments_url":"https://api.github.com/repos/OSGP/Shared/comments{/number}","issue_comment_url":"https://api.github.com/repos/OSGP/Shared/issues/comments{/number}","contents_url":"https://api.github.com/repos/OSGP/Shared/contents/{+path}","compare_url":"https://api.github.com/repos/OSGP/Shared/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OSGP/Shared/merges","archive_url":"https://api.github.com/repos/OSGP/Shared/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OSGP/Shared/downloads","issues_url":"https://api.github.com/repos/OSGP/Shared/issues{/number}","pulls_url":"https://api.github.com/repos/OSGP/Shared/pulls{/number}","milestones_url":"https://api.github.com/repos/OSGP/Shared/milestones{/number}","notifications_url":"https://api.github.com/repos/OSGP/Shared/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OSGP/Shared/labels{/name}","releases_url":"https://api.github.com/repos/OSGP/Shared/releases{/id}","deployments_url":"https://api.github.com/repos/OSGP/Shared/deployments","created_at":"2015-03-23T15:02:43Z","updated_at":"2016-01-21T15:07:04Z","pushed_at":"2016-05-17T07:40:45Z","git_url":"git://github.com/OSGP/Shared.git","ssh_url":"git@github.com:OSGP/Shared.git","clone_url":"https://github.com/OSGP/Shared.git","svn_url":"https://github.com/OSGP/Shared","homepage":null,"size":803,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/OSGP/Shared/pulls/103"},"html":{"href":"https://github.com/OSGP/Shared/pull/103"},"issue":{"href":"https://api.github.com/repos/OSGP/Shared/issues/103"},"comments":{"href":"https://api.github.com/repos/OSGP/Shared/issues/103/comments"},"review_comments":{"href":"https://api.github.com/repos/OSGP/Shared/pulls/103/comments"},"review_comment":{"href":"https://api.github.com/repos/OSGP/Shared/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OSGP/Shared/pulls/103/commits"},"statuses":{"href":"https://api.github.com/repos/OSGP/Shared/statuses/79e4d268cdbb64099afe38c0a25389e3f050528b"}}}}