You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ra...@apache.org on 2018/10/01 10:18:44 UTC

[1/2] tomee git commit: TOMEE-2239 removing the try-catch block

Repository: tomee
Updated Branches:
  refs/heads/master a88c10cb0 -> f003c900e


TOMEE-2239 removing the try-catch block


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/600901a8
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/600901a8
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/600901a8

Branch: refs/heads/master
Commit: 600901a840ef91f7379ebe1615b336cbf7231e80
Parents: a88c10c
Author: Thiago Veronezi <th...@veronezi.org>
Authored: Wed Sep 19 18:15:04 2018 -0400
Committer: Roberto Cortez <ra...@yahoo.com>
Committed: Mon Oct 1 11:11:48 2018 +0100

----------------------------------------------------------------------
 .../tomee/microprofile/jwt/MPJWTFilter.java      | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/600901a8/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
----------------------------------------------------------------------
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
index d35fb93..27b4c57 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
@@ -68,24 +68,7 @@ public class MPJWTFilter implements Filter {
         final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
 
         // now wrap the httpServletRequest and override the principal so CXF can propagate into the SecurityContext
-        try {
-            chain.doFilter(new MPJWTServletRequestWrapper(httpServletRequest, authContextInfo.get()), response);
-
-        } catch (final Exception e) {
-            // this is an alternative to the @Provider bellow which requires registration on the fly
-            // or users to add it into their webapp for scanning or into the Application itself
-            if (MPJWTException.class.isInstance(e)) {
-                final MPJWTException jwtException = MPJWTException.class.cast(e);
-                HttpServletResponse.class.cast(response).sendError(jwtException.getStatus(), jwtException.getMessage());
-            }
-
-            if (MPJWTException.class.isInstance(e.getCause())) {
-                final MPJWTException jwtException = MPJWTException.class.cast(e.getCause());
-                HttpServletResponse.class.cast(response).sendError(jwtException.getStatus(), jwtException.getMessage());
-            }
-
-        }
-
+        chain.doFilter(new MPJWTServletRequestWrapper(httpServletRequest, authContextInfo.get()), response);
     }
 
     @Override


[2/2] tomee git commit: TOMEE-2239 add try-catch block back but add a final if statement

Posted by ra...@apache.org.
TOMEE-2239 add try-catch block back but add a final if statement


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/f003c900
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/f003c900
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/f003c900

Branch: refs/heads/master
Commit: f003c900ef859ccdef3a06604ef1550d3305912b
Parents: 600901a
Author: Thiago Veronezi <th...@veronezi.org>
Authored: Thu Sep 20 09:43:46 2018 -0400
Committer: Roberto Cortez <ra...@yahoo.com>
Committed: Mon Oct 1 11:16:47 2018 +0100

----------------------------------------------------------------------
 .../apache/tomee/microprofile/jwt/MPJWTFilter.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/f003c900/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
----------------------------------------------------------------------
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
index 27b4c57..78f059e 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
@@ -68,7 +68,22 @@ public class MPJWTFilter implements Filter {
         final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
 
         // now wrap the httpServletRequest and override the principal so CXF can propagate into the SecurityContext
-        chain.doFilter(new MPJWTServletRequestWrapper(httpServletRequest, authContextInfo.get()), response);
+        try {
+            chain.doFilter(new MPJWTServletRequestWrapper(httpServletRequest, authContextInfo.get()), response);
+
+        } catch (final Exception e) {
+            // this is an alternative to the @Provider bellow which requires registration on the fly
+            // or users to add it into their webapp for scanning or into the Application itself
+            if (MPJWTException.class.isInstance(e)) {
+                final MPJWTException jwtException = MPJWTException.class.cast(e);
+                HttpServletResponse.class.cast(response).sendError(jwtException.getStatus(), jwtException.getMessage());
+            } else if (MPJWTException.class.isInstance(e.getCause())) {
+                final MPJWTException jwtException = MPJWTException.class.cast(e.getCause());
+                HttpServletResponse.class.cast(response).sendError(jwtException.getStatus(), jwtException.getMessage());
+            } else {
+                throw e;
+            }
+        }
     }
 
     @Override