Reputation: 2655
I have the following annotation bounded with the following interceptor
@Target( AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@InterceptorBinding
annotation class NamesAllowed(vararg val values: String)
@ScopesAllowed("")
@Priority(9)
@Interceptor
class NamesAllowedInterceptor {
@Inject
var jwt: JsonWebToken? = null
@AroundInvoke
fun intercept(ic: InvocationContext): Any {
// some logic
return ic.proceed()
}
}
The annotation is used to extract a custom claim and check a list of names from an incoming JWT
@GET
@Path("/identifier")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
@ScopesAllowed("some_scope") <---
fun getMyCoolResource(): Response {
// some logic executed
return Response.ok()
}
Problem
The NamesAllowedInterceptor#intercept is never triggered.
When I define my annotation without parameters:
@Target( AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@InterceptorBinding
annotation class NamesAllowed
The NamesAllowedInterceptor#intercept is triggered. =s
Any help?
Upvotes: 0
Views: 492
Reputation: 6607
Your interceptor only applies to @ScopesAllowed("")
. It doesn't apply to @ScopesAllowed("anything-else")
.
It looks like you need the annotation member's value to be ignored during interceptor resolution. For that, you need to annotate the annotation member with @Nonbinding
.
Not sure if this is the correct Kotlin syntax, but it should look like this:
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@InterceptorBinding
annotation class ScopesAllowed(@Nonbinding vararg val values: String)
Upvotes: 1