on 04-21-2004 3:09 PM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Dagfinn,
thanks for the hint. Now i can send content to the client without the EP overload. It works fine.
For those of you who want to try my code:
I make a mistake in planing, this dosnt works! I only can Access the first URL and send it to the client. In this URL are links to other ressources. the client trys to access these Links and must authenticate (because the Portal J2EE engine, where my code runs, has access to the OWA and not the client).
I dont know how i can make the authentication for the client in the J2EE Server (without writing an proxy class and url-rewriting in the HTML-Stream - but this is to much work). Has anybody an Idea?
Best regards,
Patrick
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.