• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding a customized header to an HTTP request

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Does anyone know of a way to add a custom header to an HTTP request?

My situation is that I'm trying to get Single Sign-on working between an SAP portal and the Adobe Connect product. Adobe Connect can be configured to have the user's id (which has been authenticated by my separate program) passed to it in a developer-specified header field.

I have (I think) sufficient documentation to do the authentication part of the process however I can't figure out how to add the user ID (once I've determined it) to a custom header field in a request to the Adobe Connect login URL.

Anyone know how I'd go about doing this?

Thanks in advance,
David

PS I realize using something other than a header would be easier but I'm constrained by the requirements of the Adobe Connect package that I'm working with.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

What kind of software is it that sends the HTTP request? A browser? Java code of yours? Some 3rd party software?
 
David Michell
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It'll be the user's browser coming via my Java code.

The scenario that I'm envisioning is that the user has logged into our SAP portal and gone through the standard authentication process there. They then hit a link within the portal to go to Adobe Connect. That particular link actually sends them to my servlet which checks that they're authenticated (using a Java package made available by SAP), extracts their user ID, adds it to the necessary custom header field and then forwards the request on to the Adobe Connect login page.

Alternatively I may need to create a new request within my servlet with the custom header added. I then parse the response from Adobe Connect verifying the login is successful and getting the appropriate session cookie. I think return that session information back to the user and redirect them to the Adobe Connect home page.

(as you can tell I'm still in the process of investigating how this is going to work, unfortunately I've fallen at the first hurdle because of the difficulty of adding information into a custom header in a request)

PS Thanks for the welcome.
[ September 15, 2008: Message edited by: David Michell ]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't add headers when forwarding or redirecting a browser request. It's possible to set custom headers if you create your own (Http)URLConnection, though, like you mention for the alternative approach.
 
David Michell
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
... It's possible to set custom headers if you create your own (Http)URLConnection, though, like you mention for the alternative approach.



That sounds promising. I've had a look at the javadocs for the HttpUrlConnection class though and I can't find any methods for adding headers (only for getting them). Could you point me in the direction of some documentation and/or code that I could follow to do this?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at e140 here; it shows the opposite (retrieving headers).

Setting them is done using the addRequestProperty and setRequestProperty methods.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adding custom headers are possible in case you send an AJAX request. Other it's browser's work to create HttpRequest object using http protocol and we can't interfere in this process. Instead of doing all this you better use cookies to send that userId, or use url rewriting.
 
David Michell
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
Setting them is done using the addRequestProperty and setRequestProperty methods.



Does that therefore mean that Headers and RequestProperties are the same thing?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you get the solution?

I've spent half a day trying to solve SSO HTTP Header type access to an Adobe LC Workspace (web app). I can confirm-test it to work using Modify Headers Firefox plugin.

My plan was to create a servlet, where I would navigate with my browser... the servlet would modify httpservletrequest (adding http header parameter user=someuser) and navigate to Workspace site using modified httpservletrequest.

Can you please elaborate?


Thank you
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dlse,
I have the same scenario like yours, ie to add http header to a request sent to adobe live cycle. Could you please tell me how you could solve this.

Would really appreciate your reply in this matter.

Thanks and regards,

Anu
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic