Fixed unknown authentication scheme, missing VC entity & parameter
checker

Change-Id: I2f0eb38e3dbe8105ccc42f7d386587a9be5504a1
diff --git a/core/src/main/java/de/ids_mannheim/korap/authentication/http/HttpAuthorizationHandler.java b/core/src/main/java/de/ids_mannheim/korap/authentication/http/HttpAuthorizationHandler.java
index 5eed64f..2470d4e 100644
--- a/core/src/main/java/de/ids_mannheim/korap/authentication/http/HttpAuthorizationHandler.java
+++ b/core/src/main/java/de/ids_mannheim/korap/authentication/http/HttpAuthorizationHandler.java
@@ -7,9 +7,10 @@
 import de.ids_mannheim.korap.exceptions.StatusCodes;
 import de.ids_mannheim.korap.utils.ParameterChecker;
 
-/** Implementation of Basic HTTP authentication scheme (see RFC 7253 
- *  and 7617) for client asking for authorization and sending user 
- *  data.  
+/**
+ * Implementation of Basic HTTP authentication scheme (see RFC 7253
+ * and 7617) for client asking for authorization and sending user
+ * data.
  * 
  * @author margaretha
  * 
@@ -17,13 +18,13 @@
 @Component
 public class HttpAuthorizationHandler {
 
-    public static String createBasicAuthorizationHeaderValue (String username, 
+    public static String createBasicAuthorizationHeaderValue (String username,
             String password) throws KustvaktException {
         ParameterChecker.checkStringValue(username, "username");
         ParameterChecker.checkStringValue(password, "password");
 
         String credentials = TransferEncoding.encodeBase64(username, password);
-        return AuthenticationScheme.BASIC.displayName()+" " + credentials;
+        return AuthenticationScheme.BASIC.displayName() + " " + credentials;
     }
 
     public AuthorizationData parseAuthorizationHeaderValue (
@@ -42,8 +43,15 @@
         }
 
         AuthorizationData data = new AuthorizationData();
-        data.setAuthenticationScheme(
-                AuthenticationScheme.valueOf(values[0].toUpperCase()));
+        String scheme = values[0];
+        try {
+            data.setAuthenticationScheme(
+                    AuthenticationScheme.valueOf(scheme.toUpperCase()));
+        }
+        catch (IllegalArgumentException e) {
+            throw new KustvaktException(StatusCodes.AUTHENTICATION_FAILED,
+                    "Authentication scheme is not supported.", scheme);
+        }
         data.setToken(values[1]);
         return data;
     }
diff --git a/core/src/main/java/de/ids_mannheim/korap/utils/ParameterChecker.java b/core/src/main/java/de/ids_mannheim/korap/utils/ParameterChecker.java
index 5b6670f..b4cf3cf 100644
--- a/core/src/main/java/de/ids_mannheim/korap/utils/ParameterChecker.java
+++ b/core/src/main/java/de/ids_mannheim/korap/utils/ParameterChecker.java
@@ -10,40 +10,40 @@
     public static void checkObjectValue (Object obj, String name)
             throws KustvaktException {
         if (obj == null) {
-            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, name,
-                    "null");
+            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT,
+                    name + " is null", name);
         }
     }
-    
+
     public static void checkCollection (Collection<?> collection, String name)
             throws KustvaktException {
         if (collection == null) {
-            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, name,
-                    "null");
+            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT,
+                    name + " is null", name);
         }
-        else if (collection.isEmpty()){
-            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, name,
-                    "empty");
+        else if (collection.isEmpty()) {
+            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, 
+                    name + " is empty", name);
         }
     }
 
     public static void checkStringValue (String string, String name)
             throws KustvaktException {
         if (string == null) {
-            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, name,
-                    "null");
+            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, 
+                    name + " is null", name);
         }
         else if (string.isEmpty()) {
-            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, name,
-                    "empty");
+            throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, 
+                    name + " is empty", name);
         }
     }
 
     public static void checkIntegerValue (int integer, String name)
             throws KustvaktException {
         if (integer == 0) {
-            throw new KustvaktException(StatusCodes.MISSING_PARAMETER, name,
-                    "0");
+            throw new KustvaktException(StatusCodes.MISSING_PARAMETER, 
+                    name + " is missing", name);
         }
     }
 }