[keycloak-user] javax.interceptor for implements of RealmResourceProvider

GU STONE stone_gu at hotmail.com
Thu Apr 20 16:19:38 EDT 2017


Hello,

I have some customized ResourceProviders implements RealmResourceProvider (follow the example in keycloak: org.keycloak.examples.rest), something like this:

public class UserProvider implements RealmResourceProvider {
   ...
   @Path("/{username}/pre-authentication")
   @PUT
   @Produces(MediaType.APPLICATION_JSON)
   public Response validateAuthenticationRequest(@PathParam("username") String username, @HeaderParam("Authorization") String authorization) {
   }
   ...
}

I also create Log Interceptor following the document here: https://docs.oracle.com/javaee/7/tutorial/cdi-adv006.htm, <https://docs.oracle.com/javaee/7/tutorial/cdi-adv006.htm> and add Log interceptor annotation in previous class like :

public class UserProvider implements RealmResourceProvider {
   ...
   @Path("/{username}/pre-authentication")
   @LogInterceptor
   @PUT
   @Produces(MediaType.APPLICATION_JSON)
   public Response validateAuthenticationRequest(@PathParam("username") String username, @HeaderParam("Authorization") String authorization) {
   }
   ...
}


But the Interceptor doesn't work. Do you have any ideas why?

Many Thanks!
Stone



25.6 Using Interceptors in CDI Applications - Java ...<https://docs.oracle.com/javaee/7/tutorial/cdi-adv006.htm>
docs.oracle.com
25.6 Using Interceptors in CDI Applications. An interceptor is a class used to interpose in method invocations or lifecycle events that occur in an associated target ...




More information about the keycloak-user mailing list