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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:35:22+00:00 2026-05-30T06:35:22+00:00

I am currently developing a RESTful Webservice in Java using the Jersey library. For

  • 0

I am currently developing a RESTful Webservice in Java using the Jersey library.

For security reasons, we want a custom authentication similar to Amazons Simple Storage Service. This requires, however, that I calculate an MD5 hash of the body (if there is any) to authenticate the request.

So far, I have used a custom Authenticator and Realm and plugged them into my context.
Upon trying to calculate the hash I first used the request itself resulting in an IllegalStateException, since the body can only be read once.

After investigating the problem I tried to wrap the request inside a HttpServletRequestWrapper but hasn’t been successful so far.

I am basically using a wrapper like the one shown here:
http://forums.oracle.com/forums/thread.jspa?threadID=2156814&tstart=0

Inside my realm, where I do the authentication, I am first creating the wrapper like so:

MyRequestWrapper requestWrapper = new MyRequestWrapper(request);

then I am calculating the MD5 using the requestWrapper
and finally forwarding it

request.getRequestDispatcher("/*").forward(requestWrapper, response);

The processing works fine but I get an error like this after that:

Servlet.service() for servlet Jersey REST Service threw exception
java.lang.IllegalStateException
    at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407)
    at com.sun.jersey.spi.container.servlet.WebComponent$Writer.finish(WebComponent.java:285)
    at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:241)

Note that there is no mentioning of the getReader or getInputStream being called before (like I got without using any wrapper at all).

Now I am sure I am doing something wrong here but I really don’t know much about this and would be really glad if someone could help me out here 🙂

Best Regards,
Lukas

  • 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-30T06:35:24+00:00Added an answer on May 30, 2026 at 6:35 am

    As stated in my comment to my question:

    I was accessing getReader() from the request. Response I did not touch. However I found that the problem was forwarding the wrapper. I didn’t explicitly state this in my question but I am using tomcat and tried to use the above code inside a valve. I am still interested in the question if this is also possible from a valve, since this fits better into the tomcat model. I have now moved to using a filter which is not so nice, but works

    I found however that this solution is quite nice (using a filter) instead of a tomcat valve.

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

Sidebar

Related Questions

Currently I'm developing some infrastructure and I've implemented my own RESTful authentication mechanism. Now
I'm currently developing a library for the bitbucket issues RESTful API. I made good
I am currently developing a library, HAMMER , and using CMake as its build
Currently developing an application using the newest version of symfony, obtained through PEAR. This
I was currently developing a desktop application in C# using mono and testing in
I am currently developing a Rails application using a database that was designed before
I'm currently developing a PHP application that's using an Access database as a backend.
Currently developing a connector DLL to HP's Quality Center. I'm using their (insert expelative)
I´m currently developing a web site using Symfony2. On 'dev' environment everything works just
Im currently developing a Silverlight application that connects to an old webservice. Our old

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.