473,782 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file access in jythonc

I have the following in a jythonc program to be executed in a html
file.

f1 = open("filename" ,"r")

I get message about filePermission read error. Program compiles and
jar file is created. Just the html code gives message.

Any ideas?
Jul 18 '05 #1
13 2191
[John Howard]
I have the following in a jythonc program to be executed in a html
file.

f1 = open("filename" ,"r")

I get message about filePermission read error. Program compiles and
jar file is created. Just the html code gives message.

Any ideas?


I am presuming that when you say "executed in a html file" you mean that
this code is to be embedded in a rendered html page as displayed in a
browser, such as mozilla or ie, which means that your code is an
"applet", and thus allowed to execute only in the "applet sandbox"
inside that browser. Which significantly restricts the access rights of
the applet to access system resources such as local files, for a range
of very good security reasons, described here

http://java.sun.com/docs/books/tutor.../security.html
http://java.sun.com/docs/books/tutor...y1.2/overview/

You can approach the problem by

1. Digitally signing your applet or jar file.
http://www.jguru.com/faq/view.jsp?EID=11475

2. Configuring the your browser to permit file access to local files
(potentially opening a massive security hole in your browser).
http://www.developer.com/java/ent/article.php/630621

HTH,

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Jul 18 '05 #2
Alan Kennedy <al****@hotmail .com> wrote in message news:<MQ******* ***********@new s.indigo.ie>...
[John Howard]
I have the following in a jythonc program to be executed in a html
file.

f1 = open("filename" ,"r")

I get message about filePermission read error. Program compiles and
jar file is created. Just the html code gives message.

Any ideas?


I am presuming that when you say "executed in a html file" you mean that
this code is to be embedded in a rendered html page as displayed in a
browser, such as mozilla or ie, which means that your code is an
"applet", and thus allowed to execute only in the "applet sandbox"
inside that browser. Which significantly restricts the access rights of
the applet to access system resources such as local files, for a range
of very good security reasons, described here

http://java.sun.com/docs/books/tutor.../security.html
http://java.sun.com/docs/books/tutor...y1.2/overview/

You can approach the problem by

1. Digitally signing your applet or jar file.
http://www.jguru.com/faq/view.jsp?EID=11475

2. Configuring the your browser to permit file access to local files
(potentially opening a massive security hole in your browser).
http://www.developer.com/java/ent/article.php/630621

HTH,

Yes, you are correct. I do want to execute in html page. I need read
access only for a file that is already there from another source. It's
unclear to me exactly where the filepermission code goes. In the
jython program? I looked at my ie parameters and saw no place to
change access to files. I did a search in altavista on FilePermission
and it looks like a lot of others also have questions. Can this even
be done with jythonc? It seems to me that being able to do so opens up
many, many possibilities for useful code!
Jul 18 '05 #3
py*******@yahoo .com (John Howard) wrote in message news:<9e******* *************** ***@posting.goo gle.com>...
I have the following in a jythonc program to be executed in a html
file.

f1 = open("filename" ,"r")

I get message about filePermission read error. Program compiles and
jar file is created. Just the html code gives message.

Any ideas?


I've looked up the references below and done several searches of
filepermissions . It seems to me that for jythonc to have any use in
development of "practical" products, programs have to be able to
access local files easily. If not, then this, in my opinion, is going
to be a MAJOR issue for jython!! I love the syntax and ease of
programming in python, but if it cannot be used for useful programs,
why bother?! BTW, how does java handle this? Is the same problem there
also?
Jul 18 '05 #4
> I've looked up the references below and done several searches of
filepermissions . It seems to me that for jythonc to have any use in
development of "practical" products, programs have to be able to
access local files easily. If not, then this, in my opinion, is going
to be a MAJOR issue for jython!! I love the syntax and ease of
programming in python, but if it cannot be used for useful programs,
why bother?! BTW, how does java handle this? Is the same problem there
also?


Don't blame jython for things it hasn't to do with - as Alan said, java puts
restrictions on the things an applet can do. That restrictions can be
relaxed by signing the applet - go search google for stuff like java,
applet, signing, local, file, access.

A common mistake for jython users is to think that there must be special
jython related documentation for their problems - but usually its not, for
the simple reason that there are tons of docs on java out there. Jython
docs only cover the differences. So go look for java solutions to your
problems, and then feel the joy of using java-classes with a language
without checked exceptions and what not that makes coding in java so ...
verbose.
--
Regards,

Diez B. Roggisch
Jul 18 '05 #5
"Diez B. Roggisch" <de*********@we b.de> wrote in message news:<ch******* ******@news.t-online.com>...
I've looked up the references below and done several searches of
filepermissions . It seems to me that for jythonc to have any use in
development of "practical" products, programs have to be able to
access local files easily. If not, then this, in my opinion, is going
to be a MAJOR issue for jython!! I love the syntax and ease of
programming in python, but if it cannot be used for useful programs,
why bother?! BTW, how does java handle this? Is the same problem there
also?


Don't blame jython for things it hasn't to do with - as Alan said, java puts
restrictions on the things an applet can do. That restrictions can be
relaxed by signing the applet - go search google for stuff like java,
applet, signing, local, file, access.

A common mistake for jython users is to think that there must be special
jython related documentation for their problems - but usually its not, for
the simple reason that there are tons of docs on java out there. Jython
docs only cover the differences. So go look for java solutions to your
problems, and then feel the joy of using java-classes with a language
without checked exceptions and what not that makes coding in java so ...
verbose.


So...are you saying it can be done? That is, a IE can access a local
file (assuming it's there, of course) using a jythonc product?
Question is -- HOW???
Jul 18 '05 #6
> So...are you saying it can be done? That is, a IE can access a local
file (assuming it's there, of course) using a jythonc product?
Question is -- HOW???


As I said - search google for JAVA APPLETS ACCESSING LOCAL FILES - then you
can do that using jython. As a matter of fact, the whole process has to do
with signing jars - nobody cares if these contain classes generated by
javac, jikes, jythonc or carefully handwritten jvm bytecode....

--
Regards,

Diez B. Roggisch
Jul 18 '05 #7
John Howard wrote:
"Diez B. Roggisch" <de*********@we b.de> wrote in message news:<ch******* ******@news.t-online.com>...

I've looked up the references below and done several searches of
filepermissi ons. It seems to me that for jythonc to have any use in
developmen t of "practical" products, programs have to be able to
access local files easily. If not, then this, in my opinion, is going

<snip>
Hello,

The reason that you cannot access local files is for security
reasons. If you could access local files; then what would stop an
applet running the (Jython) command :

os.remove("kern al32.dll")

As the previous responder stated, you will need to understand the
java security model, beneath is a link to the Java Security Tutorial :

http://java.sun.com/docs/books/tutorial/security1.2/

I know that it is a pain the the arse to deal with but imagine what
a disaster it would be if the security wasn't there!

Cheers,

Neil

--

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : be**@cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com

Jul 18 '05 #8
"Diez B. Roggisch" <de*********@we b.de> wrote in message news:<ch******* ******@news.t-online.com>...
So...are you saying it can be done? That is, a IE can access a local
file (assuming it's there, of course) using a jythonc product?
Question is -- HOW???


As I said - search google for JAVA APPLETS ACCESSING LOCAL FILES - then you
can do that using jython. As a matter of fact, the whole process has to do
with signing jars - nobody cares if these contain classes generated by
javac, jikes, jythonc or carefully handwritten jvm bytecode....


So does that mean that a jre does not have to be on the local pc? The
local pc does not have to set policies, etc. If that is true, then all
I've said about jython I take back. It is truly useful!
Jul 18 '05 #9
[John Howard]
So does that mean that a jre does not have to be on the local pc?
No: there *must* be a JRE on the local PC: how could the java/jython run
at all without an execution environment?

The JRE on the local PC is the very thing that is preventing you from
reading files from local drives.

If you want to, you can permit any and all applet to load files from
your local drive. In Internet Explorer, select
"Tools->Options"->Security->Custom Level->Microsoft VM->Java
Permissions->Custom->Java Custom Settings.

In that control panel you can disable all of the protections that your
browser puts in place to protect you from hostile applets on the
Internet at large. Feel free to dismantle those security barriers, at
your own risk: by doing so you're opening the contents of your hard-disk
to the world. I Hope you're not storing any private or sensitive
information on there.
The local pc does not have to set policies, etc.


No, that's precisely where you set policies. Where else could they be set?

Alternatively, as others have pointed out multiple times, you can
digitally sign your applets so that they can be recognized and thus
given more permissions than unknown applets.

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1121
by: Henri Sivonen | last post by:
I have a Jython script that uses Java classes and runs fine using jython. It also compiles using jythonc. However, when I try to run the compiled program with the same CLASSPATH, I get an ImportError upon first Java import. How can I fix this? -- Henri Sivonen hsivonen@iki.fi
9
7162
by: BOOGIEMAN | last post by:
Just how to make *.exe file from python code ?? I typed this : a, b = 0, 1 while b < 1000: print b, a, b = b, a+b and saved it as pyt.txt
1
1650
by: Mitch Amiano | last post by:
I'm getting started working with Jython (hope this is an ok group for the question), and ran into a stumbling block using the jythonc tool. It is a fairly simple Jython script which uses the Apache Batik SVG library, imports the SVG Canvas, and puts up a simple Swing interface to let the user load and display an SVG file. (I translated the script from a Batik Java example.) The script runs fine under jython, but so far I've been unable...
0
3940
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.