Hello !!
OK ! Thanks for the help. I've been testing this, and it's possible to simulate URL's
with local files.
For example, with URL testURL = new URL("file:/testfile.obj"); this works in navigator
with the Sun's OBJ Fileloader.
The second problem with portfolio is that portfolio.properties cannot be read, so the
.obj loading fails.
Has somebody been able to test PORTFOLIO Loader from an applet ?
Many thanks !!
Dani
This is really a general applet permissions problem, as opposed to anything
Portfolio specific. The first problem is happening because it's trying to
read portfolio.properties from your local disk.
The second problem is that you should be using URLs instead of doing
anything with Files (if this is an applet). Doing:
ModelLoader loader = new ModelLoader();
Scene model1 = loader.load(new
URL("http:/havefun.ncsa.uiuc.edu/~srp/astro.wrl"));
should work.
At 10:24 AM 1/26/01 +0100, Daniel Moscoso wrote:
>Hi again !!
>
>The code that reads the portfolio.properties file is the standard one used
>by NCSA Portfolio loader:
>
> BranchGroup mainScene = createSceneGraph();
> ViewingPlatform vp = u.getViewingPlatform();
> transformGroup vpTrans = vp.getViewPlatformTransform();
>
> GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
>
> template.setStereo(template.PREFERRED);
>
> GraphicsConfiguration gcfg =
>
>GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template);
> canvas = new RecordableCanvas3D(gcfg);
>
> PortfolioApplication portApp = new PortfolioApplication();
> portApp.configure(canvas,mainScene,vpTrans);
>
>This fails with an AccessControlException: access denied
>(java.io.FilePermission 'portfolio.properties' read)
>
>The code to read the.obj file (testfile.obj) is the following. I've tried
>with different options:
>
> URL fileURL = new java.net.URL(getCodeBase().toString() +
> "testfile.obj");
> or
> URL fileURL = new java.net.URL(getCodeBase(), "testfile.obj");
>
> and afterwards, load it using the code of Portfolio:
>
> File objFile = new File(fileURL.getFile());
> PlayWriter.loadFile(objFile.getName());
> Scene scene = modelLoader.load(fileURL);
>
>This fails with an AccessControlException: access denied
>(java.io.PropertyPermission '*' read, write).
>
>Is something wrong in this code? If it is, what's the correct way ?
>
>Many thanks !!
>
>Dani
>
>
>Dani,
>
>If you send me a test sample. I can look at it. or atleast provide full
>syntax lines. so I can see what u r doing
>
>Ahmed
>
>-----Original Message-----
>From: Daniel Moscoso [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, January 25, 2001 10:09 AM
>To: [EMAIL PROTECTED]
>Subject: Re: [JAVA3D] Configuring java.policy for testing fileloaders in
>local from an applet.
>
>
>Thanks for your help !!
>
>I have more questions:
>
>- If DisplayApplet.html starts DisplayApplet.class, how can I read the
>portfolio.properties file ? (Read by portfolio classes).
>
>- I tried to read the .obj file like an URL (new URLgetCodeBase(),
>"./testfile.obj") and I got an AccessControlExpression. Was this the
>correct way to read it ?
>
>Many thanks !!
>
>Dani
>
>
>Dani,
>
>You will have to do something similar
>
> new URL(getCodeBase(), "DisplayApplet.html");
>
>Because you cannot access the local drives. You only have the access to
>where your applet was loaded from, and getCodeBase() will give you that
>path. This will work if both the applet and the file you are trying to
>access are in the same directory. I have never done it with files being in
>different directories, but thats possible too.
>
>Ahmed
>
>-----Original Message-----
>From: Daniel Moscoso [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, January 24, 2001 1:20 AM
>To: [EMAIL PROTECTED]
>Subject: [JAVA3D] Configuring java.policy for testing fileloaders in
>local from an applet.
>
>
>Hi all !
>
>I'm writting an application that uses the NCSA Portfolio loader. It's
>working fine from the command line but gives security exceptions if I try
>to run it as an applet with a navigator. I also tried to configure the
>java.policy file to grant all permission, or FilePermission, for the files
>but it doesn't work.
>
>For example, the applet is located at C:\Java\Source\Test. Its name is
>DisplayApplet.class. The HTML file that opens it is DisplayApplet.html.
>This applet has to read the 'portfolio.properties' file, and afterwards an
>obj file. I have configured the policy.file with several entries:
>
> Codebase: 'file://C:/Java/Source/test/-' or
> 'file://C:/Java/Source/test/DisplayApplet.html'
> Permission entries: File Permission: AllPermission or
> FilePermission TargetName: portfolio.properties or the .obj
> file Entries: read
>
>But nothing of this works. I save the java.policy file in the directory
>where the JRE is installed: C:\Program Files\JavaSoft\JRE\1.3\lib\security.
>
>What am I doing wrong ? Or the only way to test fileloaders in an applet
>is to make signed jar files ?
>How can I test them ?
>
>I'm expecting your help.
>Thanks in advanced !!
>
>Dani
>
>
>
>--
>
>Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
>Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
>irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
>vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
>Weitergabe dieser Mail ist nicht gestattet.
>
>This e-mail may contain confidential and/or privileged information. If you
>are not the intended recipient (or have received this e-mail in error)
>please notify the sender immediately and destroy this e-mail. Any
>unauthorised copying, disclosure or distribution of the material in this
>e-mail is strictly forbidden.
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA3D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA3D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
>
>
>
>
>
>--
>
>Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
>Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
>irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
>vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
>Weitergabe dieser Mail ist nicht gestattet.
>
>This e-mail may contain confidential and/or privileged information. If you
>are not the intended recipient (or have received this e-mail in error)
>please notify the sender immediately and destroy this e-mail. Any
>unauthorised copying, disclosure or distribution of the material in this
>e-mail is strictly forbidden.
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA3D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA3D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
>
>
>
>
>
>--
>
>Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
>Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
>irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
>vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
>Weitergabe dieser Mail ist nicht gestattet.
>
>This e-mail may contain confidential and/or privileged information. If you
>are not the intended recipient (or have received this e-mail in error)
>please notify the sender immediately and destroy this e-mail. Any
>unauthorised copying, disclosure or distribution of the material in this
>e-mail is strictly forbidden.
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA3D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
--
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn
Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das
unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the
intended recipient (or have received this e-mail in error) please notify the sender
immediately and destroy this e-mail. Any unauthorised copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".