You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2019/05/16 13:27:39 UTC

[tomee] branch master updated (6285034 -> 8514a2d)

This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git.


    from 6285034  Javadoc errors
     new 36c0d5c  Switch to debug as not all requests will have a JWT
     new 8514a2d  Perform a sanity check on the generated class

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../bval/GeneratedConstraintsMissingException.java | 31 +++++++++++-----------
 .../jwt/bval/ValidationConstraints.java            |  8 ++++++
 .../jwt/bval/ValidationInterceptor.java            |  2 +-
 3 files changed, 24 insertions(+), 17 deletions(-)
 copy itests/failover/src/main/java/org/apache/openejb/server/control/Context.java => mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/GeneratedConstraintsMissingException.java (57%)


[tomee] 01/02: Switch to debug as not all requests will have a JWT

Posted by db...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 36c0d5c4b1a07909f3f612998152512d501cd69c
Author: David Blevins <da...@gmail.com>
AuthorDate: Thu May 16 19:53:09 2019 +0900

    Switch to debug as not all requests will have a JWT
---
 .../org/apache/tomee/microprofile/jwt/bval/ValidationInterceptor.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/ValidationInterceptor.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/ValidationInterceptor.java
index 74e9c5e..a1e2e33 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/ValidationInterceptor.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/ValidationInterceptor.java
@@ -52,7 +52,7 @@ public class ValidationInterceptor implements ContainerRequestFilter {
             final Supplier<JsonWebToken> tokenSupplier = (Supplier<JsonWebToken>) requestContext.getProperty(JWT_SUPPLIER);
 
             if (tokenSupplier == null) {
-                VALIDATION.error("No JsonWebToken found in request attribute '" + JWT_SUPPLIER + "'");
+                VALIDATION.debug("No JsonWebToken found in request attribute '" + JWT_SUPPLIER + "'");
                 return;
             }
 


[tomee] 02/02: Perform a sanity check on the generated class

Posted by db...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 8514a2dd8a31b193fa1a4e8e5801fd1797f295a4
Author: David Blevins <da...@gmail.com>
AuthorDate: Thu May 16 22:26:15 2019 +0900

    Perform a sanity check on the generated class
---
 .../bval/GeneratedConstraintsMissingException.java | 41 ++++++++++++++++++++++
 .../jwt/bval/ValidationConstraints.java            |  8 +++++
 2 files changed, 49 insertions(+)

diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/GeneratedConstraintsMissingException.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/GeneratedConstraintsMissingException.java
new file mode 100644
index 0000000..9dc50b8
--- /dev/null
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/GeneratedConstraintsMissingException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomee.microprofile.jwt.bval;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+public class GeneratedConstraintsMissingException extends IllegalStateException {
+
+    private final List<Method> original;
+    private final List<Method> generated;
+
+    public GeneratedConstraintsMissingException(final List<Method> original, final List<Method> generated) {
+        super(String.format("Expected %s constrained methods, found %s", original.size(), generated.size()));
+
+        this.original = original;
+        this.generated = generated;
+    }
+
+    public List<Method> getOriginal() {
+        return original;
+    }
+
+    public List<Method> getGenerated() {
+        return generated;
+    }
+}
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/ValidationConstraints.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/ValidationConstraints.java
index a0b4968..82c024d 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/ValidationConstraints.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/bval/ValidationConstraints.java
@@ -27,6 +27,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -53,6 +54,13 @@ public class ValidationConstraints {
 
         if (constraintsClazz == null) return null;
 
+        final List<Method> original = ValidationGenerator.getConstrainedMethods(componentClass);
+        final List<Method> generated = ValidationGenerator.getConstrainedMethods(constraintsClazz);
+
+        if (original.size() != generated.size()) {
+            throw new GeneratedConstraintsMissingException(original, generated);
+        }
+
         final Object instance;
         try {
             instance = constraintsClazz.newInstance();