Skip to Content

Accessing a web page protected by BASIC authentication

Sometimes when working on a portal implementation project you need to show an external page that has been protected by BASIC authentication. For connecting to page protected by form based authentication the AppIntegrator works fine, however it fails for a basic authentication page.

This is because Microsoft has applied security patch applied to the IE that prevents sending the username and password in the URL directly like this

The only alternative is to send the username and password in the HTTP headers of the request. Also the username/password combination should be BASE64 encoded.

Here’s how you can do it in your abstract portal component.

In the lines
String userPassword = “username:password”;
String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
we are creating the credentials string and encoding it using the BASE64 encoding.

And in the line
uc.setRequestProperty (“Authorization”, “Basic ” + encoding);
we are adding the encoded credentials string to the HTTP request headers.

Now you should be able to see the web pages that require BASIC authentication.

You must be Logged on to comment or reply to a post.
  • Hi,

    Is it possible to get the logged user and its password in the portal? Otherwise, you’ll need to put user and password hardcoded into the function… ?



  • Hi,

    I’m trying to do usermapping towards our SLD and DTR systems, but unfortunately, this solution does not solve my needs.

    Firstly, for the SLD system, it’s returning “Browser not supported”, eventhough I added “User-Agent” property to give the identity of a mozilla based browser (IE 6.0).

    Secondly, relative URLs in the destination adopt to the current server’s hostname, so that no links or images work correctly.

    Isn’t it possible to rewrite the header of the IPortalComponentRequest object and set the properties there? I’m twisting my head on this one…

    I’m hoping you have a solution for this 🙂

    Best Regards,
    Hans Petter Bjørn