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

  • Home
  • SEARCH
  • 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 9173507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:35:56+00:00 2026-06-17T16:35:56+00:00

I have a Solr server running as a webapp on jetty. I now want

  • 0

I have a Solr server running as a webapp on jetty.
I now want to add a custom authentication procedure to jetty, to ad/remove users that can access the solr search.

The user sends a token that needs to be verified by a 3. party server before the user is allowed to access the solr server.

How can i intercept requests to the solr server from within jetty and do some kind of session management for authenticated users?

Somebody posted a similar question for tomcat: implementing-custom-authentication-with-tomcat the answer there was to use filters. There are some filter classes available for jetty, but are they similar to tomcat and how would i deploy my own filter class?

Are there any tutorials for these kind of problems?

  • 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-17T16:35:57+00:00Added an answer on June 17, 2026 at 4:35 pm

    Well nobody seems to answer so i will start answering my own question step by step.

    Filters are the right approach to my problem. They are not something that is tomcat or jetty specific, instead they are standardized by the Java Servlet specification version 2.3. So both tomcat or jetty or any other webserver that implements the Java Servlet specification should run filters.

    As example for a use case for filters, this oracle/java article lists:
    “Authentication-Blocking requests based on user identity.”

    this is exactly what i want to do.
    I will try using filters and update this answer with my progress, until i find that the question is sufficiently answered.

    Step 1, preparations for Filter development
    before you can start writing your own filter you have to setup your IDE for JavaEE development or write the required build files for your build tool. There are a lot of tutorials out there already explaining this.
    for Example:
    Eclipse + Tomcat
    Maven + Jetty

    Step 2, write the most simple hello world filter

    package hello.world.filter;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    
    public class HelloWorldFilter implements Filter {
    
        public void init(FilterConfig fConfig) throws ServletException {
        }
    
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {        
            PrintWriter out = response.getWriter();
            out.print("hello World");
        }
    
        public void destroy() {
        }
    
    }
    

    Step 3, deploy your filter on your running solr server
    Now this step is not as easy as you might think it is. I thought i could just package my authentication filter into a war file and then use it for just any application i have running on any servlet server. Sadly it doesn’t seem to work like that. Every webapp gets deployed on your server in its own context an cannot access the context of other webapps (at least on jetty as far as i know). Solr itself for example is a webapp, and has the context http://localhost:8983/solr/. Even if you would deploy you webapp in the context http://localhost:8983/* or http://localhost:8983/solr/* this would not affect solr at all and everyone would still be able to access your solr server.

    The solution is to integrate your filter into the solr webapp.
    To do that you have to first package your HelloWorldFilter.class into a jar file. Then go to the directory where your solr server is located and unpack the solr.war file. (In your standard installation this would normally be solr-4.1.0/example/webapps). Now you have to change the context file for the solr webapp, because its no longer packaged in solr.war but instead consists of a directory. Got to solr-4.1.0/example/contexts and open solr.xml. Change the line <Set name="war"><SystemProperty name="jetty.home"/>/webapps/solr.war</Set> into <Set name="war"><SystemProperty name="jetty.home"/>/webapps/solr</Set>. Now you can actually deploy your filter: Copy your jar file into the folder solr-4.1.0/example/webapps/solr/WEB-INF/lib.
    As a last step we have to let solr know that our filter should be deployed while solr starts. To do that open solr-4.1.0/example/webapps/solr/WEB-INF/web.xml and add the following lines:

       <filter>
        <filter-name>HelloWorldFilter</filter-name>
        <filter-class>hello.world.filter.HelloWorldFilter</filter-class>
      </filter> 
    

    before the lines

    <filter>
        <filter-name>SolrRequestFilter</filter-name>
        ...
    

    And also ad:

    <filter-mapping>
      <filter-name>HelloWorldFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
    

    before any other filter mapping in the file.

    Safe everything and restart your solr server. Instead of the solr web interface you should now see “hello world” on any context after http://localhost:8983/solr/.

    Now you can start replacing

    PrintWriter out = response.getWriter();
    out.print("hello World");
    

    with your own custom authentication inside the doFilter method.

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

Sidebar

Related Questions

I have an object that I want to add to my Solr server that
I am new to solr. I have a solr server. I want to add
On my development system I have a Solr server running that is queried by
I have Solr running on my server on localhost in the Jetty container. This
I have followed this guide to install Solr in TomCat running on Windows Server
I am running Solr on my windows machine using jetty. I have downloaded the
I have recently installed Solr on server and i want to restrict only local
I am using Solr 3.5.0 with the example server under jetty-6.1-SNAPSHOT. I have started
I have a Solr search server that serves JSON to my web front-end which
I have a Solr MoreLikeThis query that is producing some decidedly non-related results. When

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.