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 11:03:56 UTC
[2/3] tomee git commit: TOMEE-2239 add try-catch block back but add a
final if statement
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/cb747b09
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/cb747b09
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/cb747b09
Branch: refs/heads/tomee-7.1.x
Commit: cb747b0912c7a54866430b56743378d1640ca0b0
Parents: 1bf7963
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:33:03 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/cb747b09/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