Home » Eclipse Projects » Remote Application Platform (RAP) » Problem with RAP Browser component and SSL
| |
Re: Problem with RAP Browser component and SSL [message #507436 is a reply to message #507285] |
Wed, 13 January 2010 09:06   |
NkD Missing name Messages: 61 Registered: July 2009 |
Member |
|
|
When I monitor the communication (in Fiddler2) I can see this code in
the response:
....
var w = wm.newWidget( "w829", "w827", true, null,
"org.eclipse.swt.browser.Browser" );
w.setSpace( 63, 279, 10, 112 );
w.setZIndex( 299 );
w.setTabIndex( 3 );
w.setBackgroundColor( null );
w.setSource(
" http://proxyserver:port/webapp/org.eclipse.swt.browser/text- 699174304.html"
);
....
So the server generates absolute URL in attribute "source". The problem
is that client (browser) uses HTTPS for communication with the proxy,
but the proxy uses non-secure HTTP with Tomcat. It seems that RAP uses
ContextProvider.getRequest().getScheme() for building the URL. Therefore
there is HTTP protocol in the generated URL that is sent to the client
and this URL cannot be handled by the proxy because the client can only
use HTTPS with the proxy.
It is interesting that this problem is only in FireFox (using version
3.5.7) but not in Internet Explorer (tested versions 7 and 8). I tried
to monitor IE by means of Fiddler2 but in this case the problem was the
same as in FF.
I went through the sources of BrowserLCA and here is the execution path
(marked with "===>"):
------------------------------------------------------------ --
class BrowserLCA
------------------------------------------------------------ --
public void renderChanges( final Widget widget ) throws IOException {
Browser browser = ( Browser )widget;
ControlLCAUtil.writeChanges( browser );
===> writeUrl( browser );
writeExecute( browser );
WidgetLCAUtil.writeCustomVariant( browser );
}
private static void writeUrl( final Browser browser )
throws IOException
{
if( hasUrlChanged( browser ) ) {
JSWriter writer = JSWriter.getWriterFor( browser );
writer.set( QX_FIELD_SOURCE, ===> getUrl( browser ) );
}
}
static String getUrl( final Browser browser ) throws IOException {
String text = getText( browser );
String url = browser.getUrl();
String result;
if( text != null && !"".equals( text.trim() ) ) {
===> result = registerHtml( text );
} else if( url != null && !"".equals( url.trim() ) ) {
result = url;
} else {
result = registerHtml( BLANK_HTML );
}
return result;
}
private static String registerHtml( final String html ) throws
IOException {
String name = createUrlFromHtml( html );
byte[] bytes = html.getBytes( "UTF-8" );
InputStream inputStream = new ByteArrayInputStream( bytes );
ResourceManager.getInstance().register( name, inputStream );
return ===> ResourceManager.getInstance().getLocation( name );
}
------------------------------------------------------------ --
class RsourceManagerImpl
------------------------------------------------------------ --
public String getLocation( final String name ) {
ParamCheck.notNull( name, "name" );
String key = createKey( name );
String fileName = ( String )repository.get( key );
Assert.isNotNull( fileName, "No resource registered for key " + name );
return ===> createRequestURL( fileName, findVersion( name ) );
}
private static String createRequestURL( final String fileName,
final Integer version )
{
String result;
String newFileName = fileName.replace( '\\', '/' );
if( isDeliveryMode( DELIVER_FROM_DISK ) ) {
StringBuffer url = new StringBuffer();
url.append( ===> URLHelper.getContextURLString() );
url.append( "/" );
String escapedFilename = escapeFilename( newFileName );
url.append( versionedResourceName( escapedFilename, version ) );
result = url.toString();
} else {
StringBuffer url = new StringBuffer();
url.append( URLHelper.getURLString( false ) );
URLHelper.appendFirstParam( url, RequestParams.RESOURCE,
newFileName );
if( version != null ) {
URLHelper.appendParam( url,
RequestParams.RESOURCE_VERSION,
String.valueOf( version.intValue() ) );
}
result = ContextProvider.getResponse().encodeURL( url.toString() );
}
return result;
}
------------------------------------------------------------ --
class UrlHelper
------------------------------------------------------------ --
public static String getContextURLString() {
HttpServletRequest request = ContextProvider.getRequest();
StringBuffer result = new StringBuffer();
result.append( ===> getServerURL() );
result.append( request.getContextPath() );
return result.toString();
}
private static String getServerURL() {
HttpServletRequest request = ContextProvider.getRequest();
String port = URLHelper.createPortPattern( request );
StringBuffer result = new StringBuffer();
String serverName = request.getServerName();
result.append( ===> request.getScheme() ); // <<***
result.append( "://" );
result.append( serverName );
result.append( port );
return result.toString();
}
The line marked with "<<***" is probably the root of the problem, here
is set HTTP instead of HTTPS. Maybe it's problem of Tomcat or problem of
FireFox (not setting some header?).
Does someone have a suggestion how to solve this situation?
I appreciate any idea. Thanks.
> Hi Michael,
>
> I wonder why the Browser widget renders a "http" instead of "https" as
> url. As far as I can see it from the RAP-code (BrowserLCA), only
> relative urls are used. Have you examined this more deeply?
>
> We use the browser widget together with https and didn't run into this
> problem.
>
> The bugs you refer to are about images paths and https - I think this is
> a different problem isn't it?
>
> Regards,
> Stefan.
|
|
|
Re: Problem with RAP Browser component and SSL [message #507454 is a reply to message #507436] |
Wed, 13 January 2010 14:27   |
Ivan Furnadjiev Messages: 2407 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Michal,
I've just checked the browser.setText() method with CVS HEAD ( FF 3.5.7
) and it generate the relative path for javascript setSource function.
Can you confirm that the problem does not exist with CVS HEAD?
Best,
Ivan
On 1/13/2010 3:58 PM, Michal NkD Nikodím wrote:
> When I monitor the communication (in Fiddler2) I can see this code in
> the response:
>
> ...
> var w = wm.newWidget( "w829", "w827", true, null,
> "org.eclipse.swt.browser.Browser" );
> w.setSpace( 63, 279, 10, 112 );
> w.setZIndex( 299 );
> w.setTabIndex( 3 );
> w.setBackgroundColor( null );
> w.setSource(
> " http://proxyserver:port/webapp/org.eclipse.swt.browser/text- 699174304.html"
> );
> ...
>
> So the server generates absolute URL in attribute "source". The
> problem is that client (browser) uses HTTPS for communication with the
> proxy, but the proxy uses non-secure HTTP with Tomcat. It seems that
> RAP uses ContextProvider.getRequest().getScheme() for building the
> URL. Therefore there is HTTP protocol in the generated URL that is
> sent to the client and this URL cannot be handled by the proxy because
> the client can only use HTTPS with the proxy.
>
> It is interesting that this problem is only in FireFox (using version
> 3.5.7) but not in Internet Explorer (tested versions 7 and 8). I tried
> to monitor IE by means of Fiddler2 but in this case the problem was
> the same as in FF.
>
> I went through the sources of BrowserLCA and here is the execution
> path (marked with "===>"):
>
> ------------------------------------------------------------ --
> class BrowserLCA
> ------------------------------------------------------------ --
> public void renderChanges( final Widget widget ) throws IOException {
> Browser browser = ( Browser )widget;
> ControlLCAUtil.writeChanges( browser );
> ===> writeUrl( browser );
> writeExecute( browser );
> WidgetLCAUtil.writeCustomVariant( browser );
> }
>
> private static void writeUrl( final Browser browser )
> throws IOException
> {
> if( hasUrlChanged( browser ) ) {
> JSWriter writer = JSWriter.getWriterFor( browser );
> writer.set( QX_FIELD_SOURCE, ===> getUrl( browser ) );
> }
> }
>
> static String getUrl( final Browser browser ) throws IOException {
> String text = getText( browser );
> String url = browser.getUrl();
> String result;
> if( text != null && !"".equals( text.trim() ) ) {
> ===> result = registerHtml( text );
> } else if( url != null && !"".equals( url.trim() ) ) {
> result = url;
> } else {
> result = registerHtml( BLANK_HTML );
> }
> return result;
> }
>
> private static String registerHtml( final String html ) throws
> IOException {
> String name = createUrlFromHtml( html );
> byte[] bytes = html.getBytes( "UTF-8" );
> InputStream inputStream = new ByteArrayInputStream( bytes );
> ResourceManager.getInstance().register( name, inputStream );
> return ===> ResourceManager.getInstance().getLocation( name );
> }
>
> ------------------------------------------------------------ --
> class RsourceManagerImpl
> ------------------------------------------------------------ --
> public String getLocation( final String name ) {
> ParamCheck.notNull( name, "name" );
> String key = createKey( name );
> String fileName = ( String )repository.get( key );
> Assert.isNotNull( fileName, "No resource registered for key " +
> name );
> return ===> createRequestURL( fileName, findVersion( name ) );
> }
>
> private static String createRequestURL( final String fileName,
> final Integer version )
> {
> String result;
> String newFileName = fileName.replace( '\\', '/' );
> if( isDeliveryMode( DELIVER_FROM_DISK ) ) {
> StringBuffer url = new StringBuffer();
> url.append( ===> URLHelper.getContextURLString() );
> url.append( "/" );
> String escapedFilename = escapeFilename( newFileName );
> url.append( versionedResourceName( escapedFilename, version ) );
> result = url.toString();
> } else {
> StringBuffer url = new StringBuffer();
> url.append( URLHelper.getURLString( false ) );
> URLHelper.appendFirstParam( url, RequestParams.RESOURCE,
> newFileName );
> if( version != null ) {
> URLHelper.appendParam( url,
> RequestParams.RESOURCE_VERSION,
> String.valueOf( version.intValue() ) );
> }
> result = ContextProvider.getResponse().encodeURL( url.toString() );
> }
> return result;
> }
> ------------------------------------------------------------ --
> class UrlHelper
> ------------------------------------------------------------ --
> public static String getContextURLString() {
> HttpServletRequest request = ContextProvider.getRequest();
> StringBuffer result = new StringBuffer();
> result.append( ===> getServerURL() );
> result.append( request.getContextPath() );
> return result.toString();
> }
>
> private static String getServerURL() {
> HttpServletRequest request = ContextProvider.getRequest();
> String port = URLHelper.createPortPattern( request );
> StringBuffer result = new StringBuffer();
> String serverName = request.getServerName();
> result.append( ===> request.getScheme() ); // <<***
> result.append( "://" );
> result.append( serverName );
> result.append( port );
> return result.toString();
> }
>
> The line marked with "<<***" is probably the root of the problem, here
> is set HTTP instead of HTTPS. Maybe it's problem of Tomcat or problem
> of FireFox (not setting some header?).
>
> Does someone have a suggestion how to solve this situation?
> I appreciate any idea. Thanks.
>
>
>
>> Hi Michael,
>>
>> I wonder why the Browser widget renders a "http" instead of "https" as
>> url. As far as I can see it from the RAP-code (BrowserLCA), only
>> relative urls are used. Have you examined this more deeply?
>>
>> We use the browser widget together with https and didn't run into this
>> problem.
>>
>> The bugs you refer to are about images paths and https - I think this is
>> a different problem isn't it?
>>
>> Regards,
>> Stefan.
|
|
| |
Goto Forum:
Current Time: Sat Mar 25 12:30:39 GMT 2023
Powered by FUDForum. Page generated in 0.02208 seconds
|