Accessing Documents
One of the main challenges when integrating the Oxygen XML Author Component applet in your SharePoint site is to avoid authenticating twice when opening a document resource stored in your SharePoint repository.
You have already signed in when you started the SharePoint session, but the applet is not aware of your current session. In this case every time the applet is accessing a document it will ask you to input your credentials again.
As a possible solution, do not execute HTTP requests directly from the Java code, but forward them to the web browser that hosts the applet, because it is aware of the current user session (authentication cookies).
To open documents stored on your SharePoint repository, register your own protocol
handler to
the JVM. We implemented a handler for both http and https protocols
that forwards the HTTP requests to a JavaScript XMLHttpRequest
object. This
way, the browser that executes the JavaScript code is responsible for handling the
authentication to the SharePoint site.
To install this handler, add the following line to your Java Applet code (in our case,
in the
ro.sync.ecss.samples.AuthorComponentSampleApplet
class):
URL.setURLStreamHandlerFactory(new ro.sync.net.protocol.http.handlers.CustomURLStreamHandlerFactory(this));
To enable JavaScript calls from your Java applet code, set the MAYSCRIPT attribute
to
true
in the <applet>
element embedded in you HTML
page:
<applet width="100%" height="600" code="ro.sync.ecss.samples.AuthorComponentSampleApplet" name="authorComponentAppletName" id="authorComponentApplet" MAYSCRIPT="true"> ..... </applet>