16
Well, currently I’m working on my project filesio, a platform for distributing large files via web interface instead of FTP.
One of the core abilities of my application is to provide widgets for third-party sites, allowing my users to include download-links to their files in their own web pages. These widgets are simple iframes that load content from my domain.
However, when implementing my app I struggled with the problem that Microsoft Internet Explorer per default blocks cookies set from within an iframe (of course, all other browsers don’t do this).
Lucklily, I found a really ..hm…interesting solution for this problem:
You can make IE trust your page by setting a special HTTP header. Well, the funny thing is: everyone can to this without any autorization, so what did the guys of Microsoft think when elaborating this “security feature”??
Nevertheless, you can read about the rescuing p3p HTTP header here and there.
I adopted the solution to JSF with Seam and implemented a custom filter that simply adds the mentioned header to every HTTPServletResponse. The code is as follows:
-
public class ResponseFilter extends AbstractFilter {
-
-
@Override
-
public void doFilter(final ServletRequest request, final ServletResponse response,
-
-
HttpServletResponse resp = (HttpServletResponse) response;
-
-
//add the mysterious header
-
resp.addHeader(“p3p”,“CP=\”IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\”“);
-
-
chain.doFilter(request, resp);
-
}
-
-
-
}
Finally, you can activate this filter either by using the @Filter annotation of Seam or in your web.xml. I preferred the second way, because this allows to apply the filter only on these views that actually need to return the header. In my case, this was my widget called widget.seam.
-
<filter>
-
<filter-name>P3P Response Filter</filter-name>
-
<filter-class>de.jw.filesio.webapp.filters.ResponseFilter</filter-class>
-
</filter>
-
<filter-mapping>
-
<filter-name>P3P Response Filter</filter-name>
-
<url-pattern>widget.seam</url-pattern>
-
</filter-mapping>
-
Related:
Download Files with Download Dialog
Seam, Spring and jBPM integration HowTo
Jazoon 08 (Java Conference in Zurich) - Ajax Push
Are you interested in reading more from CodingClues?
Then subscribe to new postings
via RSS or
via
E-Mail.
Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)