vendredi 29 mai 2015

Access NameBinding value inside my filter

I've a filter for my REST service. A normal authentication filter.

Now I need to pass a boolean in to it. From this link I got to this point:

@NameBinding
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
public @interface AuthenticationFilterBinding {

    boolean checkAccountStatus() default true;
}

And in my filter implementation I've:

@AuthenticationFilterBinding
@Provider
@Priority(FilterPriority.AUTHENTICATION_PRIORITY)
public class AuthenticationFilter extends AuthenticationAbstractFilter implements ContainerRequestFilter {

    private static final Logger logger = LoggerFactory.getLogger(AuthenticationFilter.class);

    @Override
    public void filter(ContainerRequestContext requestContext) {

    // Here I need to check the value of checkAccountStatus() defined in the code above.

    // How can I access that value?

    // My filter logic goes here
    }
}

On my endpoints I've something like:

@POST
@Path("/photo")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@AuthenticationFilterBinding(checkAccountStatus = false)
@ManagedAsync
public void setUserPhoto(@Suspended AsyncResponse ar, @FormDataParam("image") InputStream fileStream, @HeaderParam(Constant.HEADER_USER_ID) long userId) { 
    // ...
}

My problem is that I need to check the value of checkAccountStatus inside my filter and that is my problem here, how can I access it?

Aucun commentaire:

Enregistrer un commentaire