Skip to Content
0
Former Member
Apr 21, 2004 at 02:09 PM

HTMLstream to Client, Basic Authentication - EP5.0

54 Views

Hello,

since a few weeks Internetexplorer dosent support Basic Authentication Login with URL. For this reason i try to write a small login iView. But now i have a problem with frame pages:

I open a URL connection with Base64 coded name and password. Then i open an Inputstream from the Connection.

This works fine without EP 5.0.

But how i can write the Inputstream to an iView?

I tried this SAP Portal methods:

- response.write - doesnt work because the Portals sends his own code in front of the Strings. So there are two Header Tags (for example).

- NonIsolatedHtmlContainer - can recieve an Inputstream but doenst like Frames

- IsolatedHtmlContainer - can't recieve Inputstreams, but can work with Frames.

Does anybody have an idea what a good way is to bring the Content to the client?

I think about this: Is there a way to give the URLConnection Object (after i opened the connection) to the response Object?

The Page i want to Display in the iView is an Outlook Web Access Page (Frames and Javascript).

It is not much Code, so i postet it here:

package hoefer.ba;
import hoefer.ba.URL_Connector;
import java.net.*;
import java.io.*;
import com.sapportals.htmlb.*;
import com.sapportals.htmlb.enum.*;
import com.sapportals.htmlb.event.*;
import com.sapportals.htmlb.page.*;
import com.sapportals.portal.htmlb.page.*;
import com.sapportals.portal.prt.component.*;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentSession;
import com.sapportals.portal.prt.component.IPortalComponentContext;
import com.sapportals.portal.prt.component.IPortalComponentProfile;
import hoefer.ba.bean.BA_Bohne;
import com.sapportals.htmlb.htmlcontainer.*;
public class Authenticator extends PageProcessorComponent
{
	public DynPage getPage()
	{
		return new AuthenticatorDynPage();
	}
	public static class AuthenticatorDynPage extends JSPDynPage
	{
		public void doInitialization()
		{
			URL url = null;
			InputStream in = null;
			try
			{
				url = new URL("the_url_i_would_log_in");
				in =
					URL_Connector.openAuthorizedStream(
						url,
						"name",
						"password");
			}
			catch (Exception e)
			{
			}
			

			IPortalComponentRequest request =
				(IPortalComponentRequest) this.getRequest();
			IPortalComponentContext myContext = request.getComponentContext();
			IPortalComponentProfile myProfile = myContext.getProfile();			
			BA_Bohne bean = new BA_Bohne();
			setBeanFromProfile(myProfile, bean);

			bean.setHtmlStream(in);

			myProfile.putValue("BA_Bohne", bean);					
		}
		public void doProcessAfterInput() throws PageException
		{
		}
		public void doProcessBeforeOutput() throws PageException
		{
			this.setJspName("html_container.jsp");
		}
		private void setBeanFromProfile(
			IPortalComponentProfile myProfile,
			BA_Bohne myBean)
		{
			myBean.setHeight(myProfile.getProperty("height"));
			myBean.setWidth(myProfile.getProperty("width"));
			myBean.setSrcUrl(myProfile.getProperty("srcUrl"));
			myBean.setScrolling(myProfile.getProperty("scrolling"));
			myBean.setBordered(myProfile.getProperty("bordered"));
			myBean.setTooltip(myProfile.getProperty("tooltip"));
		}
	}
}

And the other Class:

package hoefer.ba;
/**
 * @author Patrick Höfer
 *
 * Hier Kommentar einfügen
 */
import java.net.*;
import java.io.*;
public class URL_Connector
{
	public static InputStream openAuthorizedStream(
		URL url,
		String name,
		String passwd)
		throws IOException
	{
		URLConnection conn = url.openConnection();
		conn.setDoInput(true);
		conn.setDefaultAllowUserInteraction(true);
		conn.setRequestProperty(
			"Authorization",
			userNamePasswordBase64(name, passwd));
		conn.connect();			
		return conn.getInputStream();
	}
	private static String userNamePasswordBase64(
		String username,
		String password)
	{
		String s = username + ":" + password;
		String encs = new sun.misc.BASE64Encoder().encode(s.getBytes());
		return "Basic " + encs;
	}	
}

Best Regards,

Patrick

http://www.unternehmensportale.biz

Add the new Code Tags - Paddy