Reputation: 20460
i am using play framework , i need to check the user's permissions with @secure annotation , but i get a problem here :
@secure(UID=???)
public static void removeFavorite(Long storyId,Long userId){
}
can any one tell me how to pass the "userId" parameter to "UID" in the annotation ?
PS : the "userId" parameter is in request scope.
many thanks!
Upvotes: 2
Views: 1360
Reputation: 88727
AFAIK you can't change annotations at runtime (at least not without dynamic code generation). Additionally, annotations are static, i.e. they apply to classes or class members (fields, methods etc.) and can't be changed per instance. Thus you can't pass the userId
to that annotation.
I dont know what
@securedoes, but generally, you'd read the annotation at runtime and optionally check its static parameters and if those checks succeed you'd read the
userId` parameter and do whatever is appropriate when that annotation is present.
Upvotes: 2