Fixed MP JWT Deploy.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/944b4190 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/944b4190 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/944b4190 Branch: refs/heads/tomee-7.1.x Commit: 944b41901870ed315c65577c7bd4031732228e97 Parents: 4b2d148 Author: Roberto Cortez <radcor...@yahoo.com> Authored: Wed Jul 25 15:14:46 2018 +0100 Committer: Roberto Cortez <radcor...@yahoo.com> Committed: Wed Jul 25 18:41:38 2018 +0100 ---------------------------------------------------------------------- .../org/apache/tomee/microprofile/jwt/MPJWTFilter.java | 10 +++++++--- tomee/tomee-microprofile-webapp/pom.xml | 3 --- 2 files changed, 7 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/944b4190/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 a7b47d3..3990ad2 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 @@ -20,6 +20,7 @@ import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo; import org.apache.tomee.microprofile.jwt.principal.JWTCallerPrincipalFactory; import org.eclipse.microprofile.jwt.JsonWebToken; +import javax.enterprise.inject.Instance; import javax.inject.Inject; import javax.security.auth.Subject; import javax.servlet.Filter; @@ -50,22 +51,25 @@ import java.util.stream.Collectors; public class MPJWTFilter implements Filter { @Inject - private JWTAuthContextInfo authContextInfo; + private Instance<JWTAuthContextInfo> authContextInfo; @Override public void init(final FilterConfig filterConfig) throws ServletException { // nothing so far - + System.out.println("MPJWTFilter.init"); } @Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { + if (authContextInfo.isUnsatisfied()) { + return; + } 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), response); + 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 http://git-wip-us.apache.org/repos/asf/tomee/blob/944b4190/tomee/tomee-microprofile-webapp/pom.xml ---------------------------------------------------------------------- diff --git a/tomee/tomee-microprofile-webapp/pom.xml b/tomee/tomee-microprofile-webapp/pom.xml index 54b915e..c9c2f0c 100644 --- a/tomee/tomee-microprofile-webapp/pom.xml +++ b/tomee/tomee-microprofile-webapp/pom.xml @@ -76,7 +76,6 @@ <version>${microprofile.config.impl.version}</version> </dependency> - <!-- <dependency> <groupId>org.eclipse.microprofile.jwt</groupId> <artifactId>microprofile-jwt-auth-api</artifactId> @@ -88,8 +87,6 @@ <artifactId>mp-jwt</artifactId> <version>${microprofile.jwt.impl.version}</version> </dependency> - --> - </dependencies> <build>