Fix Provider and Instance

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

Branch: refs/heads/master
Commit: 7b0c434dbe42c80d1bb276e7f24d27cee2ea6b74
Parents: cfc2ae1
Author: Jean-Louis Monteiro <jeano...@gmail.com>
Authored: Fri Mar 2 16:20:21 2018 +0100
Committer: Jean-Louis Monteiro <jeano...@gmail.com>
Committed: Fri Mar 2 16:20:21 2018 +0100

----------------------------------------------------------------------
 .../org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java    | 8 +++++++-
 tck/mp-jwt-embedded/src/test/resources/dev.xml              | 9 ++-------
 2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/7b0c434d/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
----------------------------------------------------------------------
diff --git 
a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
 
b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
index 0b6f3de..0d3488a 100644
--- 
a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
+++ 
b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
@@ -169,12 +169,18 @@ public class ClaimBean<T> implements Bean<T>, 
PassivationCapable {
                 // handle Provider<T>
                 if (rawTypeClass.isAssignableFrom(Provider.class)) {
                     final Type providerType = 
paramType.getActualTypeArguments()[0];
+                    if (providerType instanceof ParameterizedType && 
isOptional((ParameterizedType) providerType)) {
+                        return (T) Optional.ofNullable(getClaimValue(key));
+                    }
                     return getClaimValue(key);
                 }
 
                 // handle Instance<T>
                 if (rawTypeClass.isAssignableFrom(Instance.class)) {
                     final Type instanceType = 
paramType.getActualTypeArguments()[0];
+                    if (instanceType instanceof ParameterizedType && 
isOptional((ParameterizedType) instanceType)) {
+                        return (T) Optional.ofNullable(getClaimValue(key));
+                    }
                     return getClaimValue(key);
                 }
 
@@ -231,7 +237,7 @@ public class ClaimBean<T> implements Bean<T>, 
PassivationCapable {
             return getClaimValue(key);
         }
 
-        throw new IllegalStateException("Unhandled ClaimValue type");
+        throw new IllegalStateException("Unhandled Claim type " + 
annotated.getBaseType());
     }
 
     public static String getClaimKey(final Claim claim) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/7b0c434d/tck/mp-jwt-embedded/src/test/resources/dev.xml
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/test/resources/dev.xml 
b/tck/mp-jwt-embedded/src/test/resources/dev.xml
index b10e250..3814456 100644
--- a/tck/mp-jwt-embedded/src/test/resources/dev.xml
+++ b/tck/mp-jwt-embedded/src/test/resources/dev.xml
@@ -41,7 +41,6 @@
       </run>
     </groups>
     <classes>
-      <!-- OK
       <class 
name="org.eclipse.microprofile.jwt.tck.parsing.TokenValidationTest" />
       <class name="org.eclipse.microprofile.jwt.tck.util.TokenUtilsTest" />
       <class 
name="org.eclipse.microprofile.jwt.tck.parsing.TestTokenClaimTypesTest" />
@@ -50,16 +49,12 @@
       <class 
name="org.eclipse.microprofile.jwt.tck.container.jaxrs.PrimitiveInjectionTest" 
/>
       <class 
name="org.eclipse.microprofile.jwt.tck.container.jaxrs.ClaimValueInjectionTest" 
/>
       <class 
name="org.eclipse.microprofile.jwt.tck.container.jaxrs.JsonValueInjectionTest" 
/>
+      <class 
name="org.eclipse.microprofile.jwt.tck.container.jaxrs.ProviderInjectionTest" />
       <class 
name="org.eclipse.microprofile.jwt.tck.container.jaxrs.RolesAllowedTest" />
       <class 
name="org.eclipse.microprofile.jwt.tck.container.jaxrs.InvalidTokenTest" />
-      -->
-      <class 
name="org.eclipse.microprofile.jwt.tck.container.jaxrs.ProviderInjectionTest" />
-      <!-- KO
-      -->
     </classes>
   </test>
 
-  <!--
   <test name="extended-tests" verbose="10">
     <groups>
       <define name="extended-groups">
@@ -83,5 +78,5 @@
       <class 
name="org.eclipse.microprofile.jwt.tck.container.jacc.SubjectTest" />
     </classes>
   </test>
-  -->
+
 </suite>

Reply via email to