Fixed clientId encoding in OAuth2ClientControllerTest.

Change-Id: I37664d909cc610a7433edd96755aba05e9e6dc8b
diff --git a/full/Changes b/full/Changes
index d23bcc5..079302b 100644
--- a/full/Changes
+++ b/full/Changes
@@ -1,5 +1,5 @@
 version 0.60.5
-12/07/2018
+02/08/2018
 	- Added service layer to the search controller (margaretha)
 	- Added OAuth2 scope checking in search and VC controllers (margaretha)
 	- Added handling OAuth2 bearer token for VC access and User group controllers (margaretha)
@@ -12,6 +12,8 @@
 	- Added OAuth2 access token tests (margaretha)
 	- Updated maven surefire setting for faster test suite runtime (margaretha)
 	- Implemented refreshing OAuth2 access token (margaretha)
+	- Fixed issue #27 (margaretha)
+	- Fixed clientId encoding in OAuth2ClientControllerTest (margaretha)
 	
 version 0.60.4
 05/07/2018
diff --git a/full/src/main/java/de/ids_mannheim/korap/encryption/RandomCodeGenerator.java b/full/src/main/java/de/ids_mannheim/korap/encryption/RandomCodeGenerator.java
index e6b60ae..2b85f94 100644
--- a/full/src/main/java/de/ids_mannheim/korap/encryption/RandomCodeGenerator.java
+++ b/full/src/main/java/de/ids_mannheim/korap/encryption/RandomCodeGenerator.java
@@ -1,5 +1,7 @@
 package de.ids_mannheim.korap.encryption;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
@@ -50,7 +52,7 @@
                     .getInstance(config.getMessageDigestAlgorithm());
             md.update(bytes);
             byte[] digest = md.digest();
-            String code = Base64.encodeBase64String(digest);
+            String code = Base64.encodeBase64URLSafeString(digest);
             md.reset();
             return code;
         }
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/oltu/service/OltuAuthorizationService.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/oltu/service/OltuAuthorizationService.java
index cff1ce2..7ce105f 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/oltu/service/OltuAuthorizationService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/oltu/service/OltuAuthorizationService.java
@@ -73,7 +73,7 @@
         String scope, code;
         try {
             checkResponseType(authzRequest.getResponseType());
-            code = URLEncoder.encode(codeGenerator.createRandomCode(), "UTF-8");
+            code = codeGenerator.createRandomCode();
             scope = createAuthorization(username, authzRequest.getClientId(),
                     redirectUriStr, authzRequest.getScopes(), code,
                     authenticationTime, null);
@@ -82,12 +82,6 @@
             e.setRedirectUri(redirectURI);
             throw e;
         }
-        catch (UnsupportedEncodingException e) {
-            KustvaktException ke = new KustvaktException(
-                    StatusCodes.GENERAL_ERROR, e.getMessage());
-            ke.setRedirectUri(redirectURI);
-            throw ke;
-        }
 
         OAuthResponse oAuthResponse;
         try {