signed app|File.exists fails

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cpanon
    New Member
    • Sep 2007
    • 5

    #1

    signed app|File.exists fails

    Hello
    I have a signed applet and I still cant access the local file system with File.exists. The code is stumble-stupid:
    File f = new File("someLocal Path");
    if (f.exists) {...}

    The cert is is stored in the Java Console. What more do I have to do? Also what is the best way, after asking nicely, to store personalized data on a browsers local file system from an applet:just establish some path for the users data? Cant use user.home so is it just ad hoc? Any help appreciated. I am really stuck.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Originally posted by cpanon
    Hello
    I have a signed applet and I still cant access the local file system with File.exists. The code is stumble-stupid:
    File f = new File("someLocal Path");
    if (f.exists) {...}

    The cert is is stored in the Java Console. What more do I have to do? Also what is the best way, after asking nicely, to store personalized data on a browsers local file system from an applet:just establish some path for the users data? Cant use user.home so is it just ad hoc? Any help appreciated. I am really stuck.
    Are you getting any error messages when you try running your code snip?

    Comment

    • cpanon
      New Member
      • Sep 2007
      • 5

      #3
      Originally posted by RedSon
      Are you getting any error messages when you try running your code snip?
      Hi RedSon
      Thanks No errors other than the permission denied. However since then,
      empirically I found a partial answer. If I try to access the local file in any method other than start() it fails with Caused by: java.security.A ccessControlExc eption: access denied (java.io.FilePe rmission...
      Should I have expected that? How can I get around it? I have this object as a member of another object that my applet creates and calls. Any ideas? tia.

      Comment

      • RedSon
        Recognized Expert Expert
        • Jan 2007
        • 4980

        #4
        Originally posted by cpanon
        Hi RedSon
        Thanks No errors other than the permission denied. However since then,
        empirically I found a partial answer. If I try to access the local file in any method other than start() it fails with Caused by: java.security.A ccessControlExc eption: access denied (java.io.FilePe rmission...
        Should I have expected that? How can I get around it? I have this object as a member of another object that my applet creates and calls. Any ideas? tia.
        I'm surprised that you think it is a certificate issue. I would assume that it is more of an issue with the file system. Either the file does not exist or you do not have write permissions in that directory. I know it's bad practice but you can try running your software with administrative rights to see if it is a problem with your permissions.

        Comment

        • cpanon
          New Member
          • Sep 2007
          • 5

          #5
          Originally posted by RedSon
          I'm surprised that you think it is a certificate issue. I would assume that it is more of an issue with the file system. Either the file does not exist or you do not have write permissions in that directory. I know it's bad practice but you can try running your software with administrative rights to see if it is a problem with your permissions.
          Hi RedSon
          It is something more subtle than that. I am logged in as Administrator. Furthermore I found some code , and it runs just fine and I can open the same file with it form the very same page that the other applet gives an error. If it is a signed app, and I access the file from start() w/o errors, why cant I call a method on my applet object, that calls an object that then calls the final object that actually does the local file access. Obviously, I am accessing that final object when I create everything in the start(), but failing when that method is used anyother time

          Comment

          • RedSon
            Recognized Expert Expert
            • Jan 2007
            • 4980

            #6
            Originally posted by cpanon
            Hi RedSon
            It is something more subtle than that. I am logged in as Administrator. Furthermore I found some code , and it runs just fine and I can open the same file with it form the very same page that the other applet gives an error. If it is a signed app, and I access the file from start() w/o errors, why cant I call a method on my applet object, that calls an object that then calls the final object that actually does the local file access. Obviously, I am accessing that final object when I create everything in the start(), but failing when that method is used anyother time
            Not sure what the problem is then. It could be your server permissions, it could be a cert, it could be a million things. Java is not my primary competency.

            Comment

            • BigDaddyLH
              Recognized Expert Top Contributor
              • Dec 2007
              • 1216

              #7
              Sun's Java forums include one dedicated to signed applets. You may have better luck looking there:



              I can't help you because I don't touch applets.

              Comment

              • cpanon
                New Member
                • Sep 2007
                • 5

                #8
                Originally posted by BigDaddyLH
                Sun's Java forums include one dedicated to signed applets. You may have better luck looking there:



                I can't help you because I don't touch applets.
                Hi BD
                Thanks for the the tip. I tried a post to their applet, I should be spanked for cross posting, grin. I think it may be something that requires getClass.getRes ourceAsStream. The file I am trying to open is within the jar but opening it up on the local file system. I may just change the code and open it up from the jar directly, it just forces me to break the "write once..." I still have to get it working before I get all fancy and CS elegant. I will update this post with the final results.

                Comment

                • BigDaddyLH
                  Recognized Expert Top Contributor
                  • Dec 2007
                  • 1216

                  #9
                  By the way, you never wrote why you needed to access the local file system, which is usually a big mistake for an applet. You never wrote what your goal is. If you did that, forum members may be able to suggest alternatives.

                  Comment

                  • chaarmann
                    Recognized Expert Contributor
                    • Nov 2007
                    • 785

                    #10
                    Originally posted by cpanon
                    Hi RedSon
                    Thanks No errors other than the permission denied. However since then,
                    empirically I found a partial answer. If I try to access the local file in any method other than start() it fails with Caused by: java.security.A ccessControlExc eption: access denied (java.io.FilePe rmission...
                    Should I have expected that? How can I get around it? I have this object as a member of another object that my applet creates and calls. Any ideas? tia.
                    a java applet inside your browser runs in a "sandbox". So it's natural that you don't have permission to access files on the client system. If it would allow it, it would be an open door for all hackers. They could read all your personal files and passwords stored on your system.

                    Comment

                    • BigDaddyLH
                      Recognized Expert Top Contributor
                      • Dec 2007
                      • 1216

                      #11
                      Originally posted by chaarmann
                      a java applet inside your browser runs in a "sandbox". So it's natural that you don't have permission to access files on the client system. If it would allow it, it would be an open door for all hackers. They could read all your personal files and passwords stored on your system.
                      True, but if you are writing applets for intranet, it's reasonable. (I'm betting the OP doesn't know all the options. Perhaps he thinks Swing implies applet.)

                      Still waiting for the context of the original question...

                      Comment

                      Working...