Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8458611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:07:36+00:00 2026-06-10T13:07:36+00:00

I am developing REST services with two types. before login no session token will

  • 0

I am developing REST services with two types.

  • before login no session token will be passed to HTTP header.
  • after login session token will be passed in each request.

I dont want to include @HeaderParam in each and every REST method. I want to intercept it first and based on that I want to check the validity of session. Please let me know

  1. how I can intercept based on headers in RESTEasy
  2. How to avoid intercepting few methods

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:07:38+00:00Added an answer on June 10, 2026 at 1:07 pm

    I solved this problem using PreProcessInterceptor

    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.METHOD)
    public @interface Securable {
      String header() default "session-token";
    }
    
    @Provider
    @ServerInterceptor
    public class ValidationInterceptor implements PreProcessInterceptor, AcceptedByMethod {
    
      @Context
      private HttpServletRequest servletRequest;
    
      @Override
      public boolean accept(Class clazz, Method method) {
        return method.isAnnotationPresent(Securable.class);
      }
    
      @Override
      public ServerResponse preProcess(HttpRequest httpRequest, ResourceMethod resourceMethod) throws Failure,
          WebApplicationException {
    
        Securable securable =  resourceMethod.getMethod().getAnnotation(Securable.class);
        String headerValue = servletRequest.getHeader(securable.header());
    
        if (headerValue == null){
          return (ServerResponse)Response.status(Status.BAD_REQUEST).entity("Invalid Session").build();
        }else{
          // Validatation logic goes here
        }
    
        return null;
      }
    }
    

    The annotation @Securable will be used on REST service which needs to be validated.

    @Securable
    @PUT
    public Response updateUser(User user)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have experience developing in android and using REST services, but now I'd like
I'm developing a program using Windows 7. There are WCF services (soap, rest) that
I'm currently developing a WCF REST Web Service that will be running on Microsoft
I am developing an application, which communicates with other applications with REST services, i.e.
I'm developing a product that will use extensively of Restlet for consume WCF Rest
We're developing a few new services that will run on JBoss and will be
We are planning on developing a layer of REST services to expose services hosted
I'm developing an application, that makes use of some REST web services. It's technical
I am developing a set of REST services. I am planning to use Hibernate
Sorry, this questions sounds silly, but after developing some of my RESTful services using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.