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 7666217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:46:41+00:00 2026-05-31T14:46:41+00:00

I’m using jax-rs (jersey) to create a website / web-service that other users can

  • 0

I’m using jax-rs (jersey) to create a website / web-service that other users can access, and I have come to the point where adding authentication / authorization is a necessity; so that I can use the security annotations, I have implemented a javax.servlet.Filter whose url-pattern is */.

Apache is running in front of my tomcat instance, verifying credentials and passing the REMOTE_USER header to my web-service so I can determine what resources a user has access to. My problem is that regardless of what request object I look at, I see no REMOTE_USER header; I’ve also tried injecting the Request with the @Context param, but to no avail.

Please help me.

web.xml:

<web-app ...>
<display-name>ws</display-name>
<filter>
    <filter-name>REST Service</filter-name>
    <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>base.resources</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name>
        <param-value>WEB-INF/views</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
        <param-value>/(js|css|(WEB-INF/views))/.*</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.spi.container.ResourceFilters</param-name>
        <param-value>com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory</param-value>
    </init-param>
</filter>

<filter>
    <filter-name>auth-filter</filter-name>
    <filter-class>base.auth.AuthFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>auth-filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>REST Service</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

filter.java:

    public void doFilter(ServletRequest req, ServletResponse response, FilterChain next) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) req;      
    HttpSession session = request.getSession();
    AuthUser userPrincipal = null;
    Object sessionUser = session.getAttribute("user");
    if(sessionUser != null) userPrincipal = (AuthUser) sessionUser;
    else userPrincipal = new AuthUser();

    // load in the user principal
    Enumeration eheaders = req.getAttributeNames();
    while(eheaders.hasMoreElements()){
        System.out.println(eheaders.nextElement().toString());
    }

    String user = (String) req.getAttribute("REMOTE_USER");
...
  • 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-05-31T14:46:42+00:00Added an answer on May 31, 2026 at 2:46 pm

    HttpServletRequest.getAttribute() and getAttributeNames() has nothing to do with HTTP headers. Try getHeaderNames() and getHeaders()

    Also instead of adding a servlet filter, you may consider adding a Jersey filter – see http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/container/filter/package-summary.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.