Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using filter, is it possible to insert name/value pair into header?

 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking to put togeather a filter which would simulate the siteminder web agent. This web agent puts two variables into the header,
"sm-userid" & "sm-userdomain"; I would like to simulate this behavior but have not found any documentatio on adding header values. Can it be done?
Regards,
Joshua
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Joshua,
When you say "adding header values" do you mean "adding HTTP response hearder values"? If yes, then you can use the HttpServletResponse interface methods (addHeader, addIntHeader, addDataHeader) to modify or add headers to the response stream.
And, yes this can be done in a Filter becuase the response and request objectives are passed to the doFilter method.
Regards,
Bryan
 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bryan,
Siteminder adds header values to the request. I would like to simulate this for our development environment. Unfortunately adding headers to the response will not help me here.
I have another filter which is looking for the siteminder information using request.getHeader("foo").
Any ideas?
Regards,
Joshua
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you can extend HttpServletRequestWrapper to create a class that will "wrap" a request to add your special functionality. Presumably you would then forward the wrapped request instead of the original one.
Have not tried this myself.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic