Signed Applet - Problem reading large local files
Hello,
I am using a signed applet (self-signed) to read files from a clients machine (local file system). Following is the code for buffered reading (the meat):
String thisLine, ret = "";
try{
BufferedReader myInput = new BufferedReader(new FileReader(fn));
while ((thisLine = myInput.readLine()) != null) {
ret += thisLine + "\n";
myInput.close();
catch (Exception e) {
ret = "Cannot load, exception!";
When I read a file <= 512KB, it runs fine/as expected. Now, when I read a file, say for example 1024KB in size, I expect the application to take twice as much time (than 512KB file) and read the file, but instead the applet/browser hangs. As a matter of fact I am not able to read files > 512KB.
So, is there a limit on file size (from local file system) when reading from an applet, or is it to do with the way I am reading it?
Any help, suggestions or comments would be highly appreciated.
Thanks in advance.
Here is how I read a file from my applet:
private String getData(String u) {
URL url = null;
InputStream in = null;
String ret = null;
try {
// the following line wil read a file @ the same location as your class file
// this way your applet does not need any special privileges
// you could change the url to a file if so needed
url = new URL(this.getCodeBase(), u);
URLConnection conn = url.openConnection();
// next line is optional and just tells the http server
// a utf-8 response is accepted
// some servers will return a bad request
conn.setRequestProperty("Accept-Charset","utf-8");
// first try to find out if the server has
// provided us with the charset of the response
// since this doesn't work with the msjvp (version 1.1.2)
// it's commented out
// instead provide a charEncoding yourselve
String charEncoding = "UTF8";
// int i = conn.getHeaderFields().size()-1;
// while(i>-1){
// System.out.print(conn.getHeaderFieldKey(i));
// System.out.print("=");
// System.out.println(conn.getHeaderField(i));
// if(conn.getHeaderField(i).toLowerCase().indexOf("charset")!=-1){
// String charsetLine = conn.getHeaderField(i).toUpperCase();
// if(charsetLine.indexOf("SHIFT_JIS")!=-1){
// charEncoding = "Shift_JIS";
// if(charsetLine.indexOf("EUC-JP")!=-1){
// charEncoding = "EUC-JP";
// i--;
// here is the value for char encoding (as a parameter in the <object html tag)
if(this.getParameter("dataCharset")!=null){
charEncoding=this.getParameter("dataCharset");
// wither you have a file or an url you read from an inputstream
// here is how it's done
// read the whole file and than turn it into a string
in = conn.getInputStream();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int len;
byte[] buf = new byte[1024];
while ((len = in.read(buf)) > 0) {
bos.write(buf, 0, len);
in.close();
// you have the file as a byte array (bos.toByteArray()
// here is how you turn it into a string
ret = new String(bos.toByteArray(),charEncoding);
} catch (Exception e) {
e.printStackTrace(System.out);
return ret;
}
Similar Messages
-
Any news on the problem of large CHC files increasing size of roaming profiles?
Any news on the problem of large CHC files increasing the size of roming profiles? Thank you.
I talked to the product manager. Here's what he said.
This was addressed in our last release. CHC 4.0 changes the location of the locally stored documents so that they are longer included when users synchronize their roaming profiles. The CHC will even move previous files to the new location when users upgrade. -
Problems reading generated pdf-files
Hi all,
I have problems reading generated pdf-files from
Report Builder 6.0.8.11.3
An error-message occurs when opening the pdf with
Adobe Acrobat 5.0.1:
... problem 110 and after moving in an empty pdf-document
the messages:
- too few operands
- an unrecognized token
I think the solution must be very simple, but the docu and
other info resources provide nothing aboutthis issue.
Greetings,
Bernhard<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by the oracle reports team:
hello,
there are no known problems with reading reports PDFs with later Acrobat Readers. maybe your file is somehow corrupt.
regards,
the oracle reports team<HR></BLOCKQUOTE>
I had to install a local printer, the network printer is not appropriate here. After that, everything is fine :-)),
Greetings,
Bernhard
null -
Problem reading camera raw files after I reinstalled LR4.
Now can't read Nikon 5200 camera raw (nef) files in Develop Mode. Could do so before. Any suggestions?
Thank you all!!!! I was successful in updating!!!!! Appreciate your assistance!
Date: Sun, 3 Nov 2013 06:35:19 -0800
From: [email protected]
To: [email protected]
Subject: Problem reading camera raw files after I reinstalled LR4.
Re: Problem reading camera raw files after I reinstalled LR4.
created by JimHess in Photoshop Lightroom - View the full discussion
The file that you downloaded is a self-contained running application that installs the update on your computer. After you download that file, you need to double-click on it and follow the prompts to install it. After it has completed you will have Lightroom 4.4 installed and it will be ready to run. If you are on a Windows computer, the installation will replace your 4.1 installation. If you are on a Mac then you will have both versions installed and you will have to be sure you start the right one.
Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5810683#5810683
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5810683#5810683
To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5810683#5810683. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Photoshop Lightroom at Adobe Community
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746. -
Problem reading attached PDF files
<!--[if gte mso 9]><xml>
</xml><![endif]--><!--[if gte mso 9]><xml>
Normal
0
false
false
false
MicrosoftInternetExplorer4
</xml><![endif]--><!--[if gte mso 9]><xml>
</xml><![endif]--><!--[if !mso]>
<object
classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui>
</object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]-->
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->
Hello.
At my work, we use JavaMail (version 1.4.1) in server
programs, processing mails with attached files from customers. Mostly it is
TIFF images, but it can also be PDF
files, and the attached files are extracted and saved for further processing.
Sometimes, we have a problem, reading attached PDF
files. The files get saved, but is of size 0 bytes. If I forward it, however,
using an Outlook client, the forwarded item can be read by our JavaMail program, and files saved OK.
I have tried to forward it using JavaMail, but I cannot
compose the mail parts, that fails, however - of the same reasons: I cannot
read the them in:-)
It looks like it's when the mail is send from a Mac.
Anyway, the part to read is of content type "APPLICATION/APPLEFILE" whereas when it's forwarded, it's content
type is "APPLICATION/OCTET-STREAM"
The way, I read the part, is to check if the part is an
instance of an InputStream, and then saving into a byte array, like this:
h5. Object
obj = part.getContent();
if (obj instanceof
InputStream) {
InputStream
inStream = part.getInputStream();
byte[]
buffer = new byte[BUFFER_SIZE];
int
bytesRead;
BufferedOutputStream
outBufStream = new BufferedOutputStream(new FileOutputStream(attFileName));
while
((bytesRead = inStream.read(buffer)) != -1)
outBufStream.write(buffer,
0, bytesRead);
inStream.close();
h5. outBufStream.close();
Problem
is that .read() method always returns -1 when content type Is APPLICATION/APPLEFILE,
so a file of 0 bytes are created.
Interesting is perhaps, that debugging shows me that the
part instance of the InputStream actually is a
com.sun.mail.util.BASE64DecoderStream when it fails, and a
com.sun.mail.util.QPDecoderStream
when it works OK.
So I have this idea, that I's a certain type of decoder
stream we're missing? We use Java 1.6.0 update 10 and JavaMail 1.4.1. and since
we use java 1.6 we use the JAF framework from that one, I guess?
Hope you guys can help?
Thanks in advance, Per Jensen
[email protected]We have two (MS Exchange) servers (from trace log):
Microsoft Exchange IMAP4rev1-server version 5.5.2650.23
Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7226.0
- the first one is the one, we're using here, but I have tried on the other, newer version too, and it didn't help either.
But I've found out a couple of interesting things:
1: Debugging shows me, that the part instance of the InputStream actually is a com.sun.mail.util.BASE64DecoderStream when it fails, and if I forward the mail via Outlook as described earlier, and it can be read OK, the part is a com.sun.mail.util.QPDecoderStream instance.
2: I can save the WHOLE message to a file, using message.getInputStream(), and when I opens the file I can find the individual attachments - as well as the bodytext, if any - as they are separated with the disposition, mimetype and filename fields, showed as plain text. And the attachments are showed as blocks of characters; I guess it's the ascii character representation of the bytes. Here's a snippet, note the first two sentences. They seemes to be added, somehow, when I dump the message to file(?):
<START OF DUMPED FILE>
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C9A8A2.19479FE4
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
(The body text here)
------_=_NextPart_000_01C9A8A2.19479FE4
Content-Type: application/applefile;
name="first_attachment.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="first_attachment.pdf"
AAUWAAACAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAASgAAABAAAAAJAAAAWgAAACAAAAADAAAA
egAAABAAAAABAAAAigAAI6IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAA1NzE2NSBCTkhhdWcucGRmJVBERi0xLjMKJbe+raoKMSAwIG9iago8PAovVHlwZSAv
Q2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9L
aWRzIFsgNCAwIFIgXQovQ291bnQgMQo+PgplbmRvYmoKMyAwIG9iago8PAovUHJvZHVjZXIgKEhh
...(and so on)
DMgMDAwMDAgbg0KMDAwMDAwNTM1NSAwMDAwMCBuDQowMDAwMDA2NTA5IDAwMDAwIG4NCjAwMDAw
MDc2NjUgMDAwMDAgbg0KdHJhaWxlcgo8PAovUm9vdCAxIDAgUgovSW5mbyAzIDAgUgovU2l6ZSAx
MQo+PgpzdGFydHhyZWYKODgyNAolJUVPRgo=
------_=_NextPart_000_01C9A8A2.19479FE4
Content-Type: application/applefile;
name="second_attachment.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="second_attachment.pdf"
AAUWAAACAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAASgAAABAAAAAJAAAAWgAAACAAAAADAAAA
egAAABAAAAABAAAAigAAI9wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAA1NzE4MSBCTkhhdWcucGRmJVBERi0xLjMKJbe+raoKMSAwIG9iago8PAovVHlwZSAv
Q2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9L
...(and so on)
<END OF DUMPED FILE>I understand that it's base64 encoded and must be decoded, and I have tried to copy/paste the blocks separately, run them through the com.sun.mail.util.BASE64DecoderStream, and saving them as PDF files, which works fine(!).
As the solution seems to be painfull: Parse the mail to find where the attachments starts and stops and saving them as files, I hope you guys can send me on the right track?
PS: The trace log when dumping the file shows everything OK, I think. Here's a bit of the log at the end of dumping the message:
(...)MTUgMDAwMDAgbg0KMDAwMDAwNTg2NyAwMDAwMCBuDQowMDAwMDA3MDIxIDAwMDAwIG4NCjAwMDAw
MDgxNzcgMDAwMDAgbg0KdHJhaWxlcgo8PAovUm9vdCAxIDAgUgovSW5mbyAzIDAgUgovU2l6ZSAx
MQo+PgpzdGFydHhyZWYKOTMzNgolJUVPRgo=
------_=_NextPart_000_01C9A8A2.19479FE4--
A10 OK FETCH fuldført.
A11 FETCH 1 (BODY[TEXT]<40336.16384>)
* 1 FETCH (BODY[TEXT]<40336> {0}
20/03-09 15:18:21,445 3 Done, writing bytes to ByteArrayOutputStream. Size: 40336 bytes (..common.mail.MailUtil.dumpMessageToFile.dumpMessageToFile)
20/03-09 15:18:21,445 3 Done, writing ByteArrayOutputStream to file. (..common.mail.MailUtil.dumpMessageToFile.dumpMessageToFile)
A11 OK FETCH fuldført. -
How to read a local file from Applet Code
Hi
I am developing a application and i want to access a local file from the applet
So pls help me in coding for thisYou can't do that, at least not with an unsigned applet.
Sign your applet and it should work just like normal file access. -
Signed applet : problem signing jar files that are in build path
Hello,
I have a problem while trying to create an ftp applet.
I use org.apache.commons.net.ftp and i build path for commons-net-1.1.4.jar and then i build my classes.
When i create a jar file with my classes and after signing it, it works under eclipse but not on a web page.
I had signed commons-net-1.1.4.jar before to build the path in eclipse but commons-net-1.1.4.jar is not in my jar file.
What is the way to sign applet correctly even if some jar ressources are in eclipse build path.
Thank youYou were right!!!
I'm not sure what to write down in the formsweb.cfg (configuration file) , following the instructions on the on-line help of Developer Forms 10g , in step 9..
The step 9 says...
Because in this release the JACOB code is in an external Jar file and not incorporated into frmwebutil.jar, it needs to be downloaded. To do this, change the WebUtilArchive setting to read: webUtilArchive=/forms/webutil/frmwebutil.jar,/forms/webutil/jacob.jar
The doudt is pointed to the fact that the frmwebutil.jar isn't in the ORACLE_HOME\forms\webutil path but it is ORACLE_HOME\forms\java path.
Also , these paths referenced in webUtilArchive are physical paths in a Unix system or they are logical paths in a url?
Simon -
Can an applet loading from a browser read from local file system?
I have to load my applet from a browser, and the "browse" button on it should be able to select and read certain files in the local file system( or the files located under the server's home directory). Is there a way to address the security issue? I know there are ways to enable an appletviewer to do it, but how about a browser?
You'll need to have a signed applet.
-
Using javascript to call a signed applet's read/write functions problem.
Hi, I wan't to use javascript to call the read/write functions of my signed java applet.
The applet can read/write fine, if its called from inside the applet, but when I make public functions to do the read/write and then call those functions from javascript, i get the old security exception.
Has anyone done this before?
ThanksFrom what I understand is that for example file IO can only be done if the current method
has this privilege and the stack that called the current method had this privilege.
Javascript doesn't have any privilege and calling methods that do file IO directly from
javascript should not work, this bug was fixed in 1.4.2.
The workarround AccessController.doPrivileged(new PrivilegedAction() { might allso be
fixed in later versions since changing the privileges of currently executing code is
someting that should not be possible when the currently executing code is called from
"untrusted" (javascript) code.
http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
second post -
Hi all,
I have a problem with one applet. I just built an applet (JDK 1.2) to download a file to the local machine; so far is OK, I got my digital certificate and I have signed the applet. Now when I test it in IE 5.x or 6.x it shows me the certificate and of course I trust, so it writes to the local hard drive, but when I try to test in Netscape 4.7 or greater; it shows me the certificate, I choose the "Trusted option" but I got the error:
access denied (java.io.FilePermission c:\mwSave.dll write)
I don't have any idea why if my applet is already signed and the certificate is valid I am getting this error... I am using a signed applet to do not use the policy file.... and should work, well I think that....
Any ideas....
Thanks in advance.I have exatly the same problem but not with the class itself. I have the problem with an jar that my class calls.
I use jdk1.4.2. I think it's basicaly the same problem as "lfpgMW".
I'll also whould like an idea...
thanks -
Hello java gurus,
I have a self signed applet which must read and write from mysql DB.
The sign is OK, the popup "warning security" is here but I still have a SQL Exception :
java.security.AccessControlException: access denied (java.util.PropertPermission file.encoding read)
I don't want to change the java policy and I work on plugin 1.4.1_02.
I think the problem is with the certificate cause it should give permission to applet, but it doesn't.
Any help will be very pleasantFrom the plug-in control panel, click certificates
then the Signer CA radio button. These are the
certifying authorities that the client plug-in will
accept as valid for signed code. Obviously, if any
client would just accept self-signed code as trusted,
it wouldn't provide much security. For a purely
internal app, you can generate a cert and install it
on the clients which will accept your own signing as
trustworthy.I think I can deal with this properly if you just clear up one thing for me: when you say 'install it on the clients' do you mean use the Plug-In Control Panel to load the certificate using the "Certificates" tab? From there click the "Signed Applet" radio button and "Import" and browse for the cert file? Or does creating this HTML file and clicking on a link to the certificate do something else? I think I am generating my self-signed certificate correctly and signing my jar correctly, but my applet is failing to initialize. Any further help on this much-maligned topic? :)
Thanks,
B. Rintoul -
Signed applet problem: signer information does not match...
hi all,
i am actually making a upload component using applets that
would need to access the local file system for uploading
files.
I have created a signed applet(i have followed all the steps,
such as those of creating a jar, creating a key/value pair
using keytool and finally signed my jar file using
jarsigner). when i try to access this applet in a browser,
first the security certificate displays(which is fine),but
then when i click on "grant permission", it gives me a error
saying java.lang.SecurityException: signer information of
a(particular class of mine)does not match with that of other
classes in that......(rest is not visible)
i don't understand why this is happening...i have tried to
repeat all the steps..but still continues to give this error.
can anyone help plz...? i am stuck bceauz of this..as the
JFileChooser dialog box doesn't open up..from which i had to
browse and select files..
Thanks in advance
sd76first the security certificate displays(which is fine),but then when i click on "grant
permission"Not sure what you're talking about, when I sing an applet and open it with IE and jre 1.5
I get a window titled "Warning - Security". It askes me if I trust the signed applet and
gives me the options yes, no and allways. But never got the "grant permission dialog".
Here is how I signed the applet and got it to read local file system:
http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
second post -
Problems viewing large tif files in preview
i'm having trouble viewing large tif files in preview. the tif files are on a cdrom - when i click on the file to open it, it opens only the first 250 pages of the file. the file has approximately 3,000 pages. how can i get preview to open the rest of the pages?
thanks for any suggestions.
mac mini Mac OS X (10.4.6)no trick - i didn't create the cdrom but it only has 3 tif files with approximately 3000 pages each, not 3000 large tif files. plus several smaller pdf files, but those aren't giving me any problems.
i don't know whether they're compressed, but i still can't get more than the first 250 pages to open, even after copying the file to my desktop. if anyone has any other ideas, i'd much appreciate it.
mac mini Mac OS X (10.4.6) -
How to make an applet to read the Text file present inside a jar
Hi All,
I have writen one applet named ReadFile.java which reads a text file present in the same directory and does some manipulation of text file contents.
The applet code runs successfully when i run the applet in command prompt like
{color:#ff0000}*java ReadFile*{color}
And i am getting the needed results.
Then i made a jar file with the applet code and text file as
{color:#ff0000}*jar cvf rf.jar ReadFile.class File1.txt*{color}
Then i have inlcuded this applet inside a html file as
{color:#ff0000}*<applet code= "ReadFile.class" width= "500" height= "300" archive = "rf.jar" ></applet>*{color}
after this when i load the html file, the applet code is not executed fully. Its throwing FileNotFoundException: File1.txt.
Applet is not recognizing trhe text file present inside the jar file.
Can any body explain me how to overcome this problem. Any setting needs to be done for making the applet indicate the presence of Text file inside the jar file.what code in your applet gets the text file and reads it? are you using getResource or something similar?
-
Signed Applet problems in Vista + JMF
Hi All,
I'm new to Java Applet programming. I wrote an application which works as a VoIP Client in a webpage (Using JMF). Its working very fine in allmost all Windows XP machines.
But not in Windows Vista machines. In Vista i'm getting the following error :
"No permission to capture from applet" - Since its a Signed applet. The application is digitally signed from a CA. Even though its not working in Vista (IE and Mozilla Firefox also).
I have went through the following link which says IE in Vista will run on protected mode, so Signed Applet will not have all the permission eventhough its signed for "AllPermission".
----- http://java.sun.com/javase/6/webnotes/install/system-configurations.html
And also I'm not able to create a customized jar file for JMF using JMF Customizer. (JMF Customizer is an application which creates a jar file with specified classes). While creating a jar file I'm getting particular class is not available. (In Windows XP, this class is compilled at run time).
Please let me know the following things,
a) Is there any security settings i have to make to run Signed Applet in Windows Vista ?
b) What is Java Policy file? I don't have any policy file - will it affect the application ?
c) Do I need to sign each applet (say i have 5 applets in single jar file) ?
d) In Vista how Mozilla Firefox are running (like IE7's restricted environment or XP compatiable mode) ?
Thanks in Advance,
Karthikeyan RI have exatly the same problem but not with the class itself. I have the problem with an jar that my class calls.
I use jdk1.4.2. I think it's basicaly the same problem as "lfpgMW".
I'll also whould like an idea...
thanks
Maybe you are looking for
-
Dear gurus Please give me over view of vendor return process with excise. if received the goods and posted the excise part II also , then what is the procedure for return the goods to vendor. Regards srini.
-
Headings are getting bookmarked while importing word document to Robohelp 9
HI everyone. Easter wishes in advance. I have a problem while importing word document to Robohelp. Version - MS Word 2010 Robohelp 9 While I import word document to Robohelp after mapping styles, my heading styles are getting tagged as bookmarks in R
-
OS - HPUX 11.0 Oracle APPS 11i I have installed Oracle APPS 11i on HP-UX 11.0 I am using url http://hostname:8801/dev606gi/f60cgi . I will get the Signon Screen only once or twice. After that if I try the URL I just get the Oracle Splash Screen and a
-
With RRI to R/3 Abap report and back to BW with result as Q filter
With a report to report interface, I want to run an ABAP report in R/3. This is no problem. But with the (single) result I want to go back to BW and use this result as variable input for an BW query. Any idea's if this is possible? Thanks...
-
How do I duplicate row or column with formulas?
I've never been a big spreadsheet user but I recall being able to intuitively (the only time ever with a MS product) find a way to duplicate a row or column in Excel so that it would replicate the same formulas as the row/column immediately adjacent