tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlmonte...@apache.org
Subject [06/38] tomee git commit: Better handling of the internal application
Date Mon, 16 Apr 2018 22:45:10 GMT
Better handling of the internal application


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

Branch: refs/heads/master
Commit: 7acf3146b12e5bbd0e4db58ed432345ca4eec4ae
Parents: a2468e4
Author: Jean-Louis Monteiro <jeanouii@gmail.com>
Authored: Wed Feb 21 16:45:35 2018 +0100
Committer: Jean-Louis Monteiro <jeanouii@gmail.com>
Committed: Wed Feb 21 16:45:35 2018 +0100

----------------------------------------------------------------------
 .../server/cxf/rs/MPJWTSecurityContextTest.java | 22 +++++++-------------
 1 file changed, 8 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/7acf3146/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/MPJWTSecurityContextTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/MPJWTSecurityContextTest.java
b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/MPJWTSecurityContextTest.java
index b7bceb5..266aa66 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/MPJWTSecurityContextTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/MPJWTSecurityContextTest.java
@@ -23,6 +23,7 @@ import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.observer.Observes;
 import org.apache.openejb.server.cxf.rs.event.ExtensionProviderRegistration;
 import org.apache.openejb.server.cxf.rs.event.ServerCreated;
+import org.apache.openejb.server.rest.InternalApplication;
 import org.apache.openejb.spi.SecurityService;
 import org.apache.openejb.testing.Classes;
 import org.apache.openejb.testing.Configuration;
@@ -101,7 +102,7 @@ public class MPJWTSecurityContextTest {
 
     @LoginConfig(authMethod = "MP-JWT")
     @ApplicationPath("/api")
-    public class RestApplication extends Application {
+    public static class RestApplication extends Application {
 
     }
 
@@ -122,22 +123,15 @@ public class MPJWTSecurityContextTest {
         public void obs(@Observes final ServerCreated event) {
             System.out.println("Observer.obs");
             final ApplicationInfo appInfo = (ApplicationInfo) event.getServer().getEndpoint().get("javax.ws.rs.core.Application");
-            final Application application = appInfo.getProvider();
-            final LoginConfig annotation = application.getClass().getAnnotation(LoginConfig.class);
-            if (annotation != null) {
-                // add the ContainerRequestFilter on the fly
-            }
-        }
-
-        public void extension(@Observes final ExtensionProviderRegistration registration)
{
-            System.out.println("Observer.extension");
-            // nothing useful here because we cannot access the application
-            final ApplicationInfo appInfo = (ApplicationInfo) registration.getServer().getEndpoint().get("javax.ws.rs.core.Application");
-            final Application application = appInfo.getProvider();
+            final Application application = InternalApplication.class.isInstance(appInfo.getProvider())
+                            ? InternalApplication.class.cast(appInfo.getProvider()).getOriginal()
+                            : appInfo.getProvider();
             final LoginConfig annotation = application.getClass().getAnnotation(LoginConfig.class);
             if (annotation != null && "MP-JWT".equals(annotation.authMethod())) {
                 // add the ContainerRequestFilter on the fly
-                registration.getProviders().add(new MySecuCtx());
+                if (InternalApplication.class.isInstance(appInfo.getProvider())) {
+                    InternalApplication.class.cast(appInfo.getProvider()).getClasses().add(MySecuCtx.class);
+                }
             }
         }
     }


Mime
View raw message