473,416 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Problem with access to signed javascript file

Hello,

I'm trying to load and write file on local disc drive using signed
javascript file. But I have experienced problem running this url:

jar:http://www.domain.com/secure-scripts...!/thepage.html
(sample)

in browser (Firefox) which simply won't work. I can't access to
html file embedded in jar file. My sample applet IO.java together
with IO.html was properly signed with valid certificate (real one,
no test certificate) by using signtool as is written here:

http://www.mozilla.org/projects/secu...d-scripts.html .

Is there someone who can help me or experienced same problems
with running embeded html file in signed jar file? Your help
is very appreciated. Thank you.


Expand|Select|Wrap|Line Numbers
  1. Sample IO.java:
  2.  
  3. import java.applet.*;
  4. import java.awt.*;
  5. import java.io.*;
  6.  
  7. import java.util.regex.*;
  8. import java.util.Map;
  9. import java.util.ArrayList;
  10.  
  11. @SuppressWarnings("deprecation")
  12. public class IO extends Applet {
  13.     private ArrayList<String[]> envvars = new ArrayList<String[]>();    
  14.     public static String newLine = System.getProperty("line.separator");    
  15.  
  16.     public boolean boolSwitch = true;
  17.  
  18.     public void init() {
  19.         Map<String, String> env = System.getenv();
  20.         for (String envName : env.keySet()) {
  21.             String[] tmpfield;
  22.             tmpfield = new String[2];
  23.             tmpfield[0] = envName;
  24.             tmpfield[1] = env.get(envName);
  25.             envvars.add(tmpfield);
  26.         }    
  27.     }    
  28.  
  29.     public void write(String path, String data) {
  30.         try {
  31.             path = expEnvironment(path);
  32.             File file = new File(path);
  33.             DataOutputStream dos = new DataOutputStream(
  34.                 new BufferedOutputStream(
  35.                     new FileOutputStream(file)));
  36.             dos.writeBytes(data);
  37.             dos.close();                    
  38.         }
  39.         catch (SecurityException se) {
  40.             System.err.println(se.getMessage());
  41.         }
  42.         catch (IOException ioe) {
  43.             System.err.println(ioe.getMessage());
  44.         }
  45.     }
  46.  
  47.     public String load(String path) {
  48.         String tmpStr = new String();
  49.         try {
  50.             path = expEnvironment(path);
  51.             File file = new File(path);
  52.             DataInputStream dis = new DataInputStream(
  53.                 new BufferedInputStream(
  54.                     new FileInputStream(file)));
  55.             do {
  56.                 tmpStr = tmpStr.concat(dis.readLine());
  57.                 if (dis.available() != 0) {
  58.                     tmpStr = tmpStr.concat(newLine);
  59.                 }
  60.             } while (dis.available() != 0);
  61.             dis.close();                    
  62.         }
  63.         catch (SecurityException se) {
  64.             System.err.println(se.getMessage());
  65.         }
  66.         catch (IOException ioe) {
  67.             System.err.println(ioe.getMessage());
  68.         }
  69.         return tmpStr;
  70.     }
  71.  
  72.     public void paint(Graphics g) {
  73.     }
  74.  
  75.     private String expEnvironment(String path) {
  76.         String envPer = new String();
  77.         String env = new String();
  78.         Pattern pattern = Pattern.compile("%\\w+%");
  79.         Matcher matcher = pattern.matcher(path);
  80.         while (matcher.find()) {
  81.             envPer = matcher.group();
  82.             env = envPer.replace("%", "");
  83.             for (int i = 0; i < envvars.size(); i++) {
  84.                 if (env.equalsIgnoreCase(envvars.get(i)[0])) {
  85.                     path = path.replace(envPer, envvars.get(i)[1]);
  86.                 }
  87.             }
  88.         }
  89.         return path;
  90.     }    
  91. }
Sample IO.html:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <applet archive="IO.jar" code="IO.class" name="io" width="0" height="0"></applet>
  3. <script type="text/javascript">
  4.  
  5. function saveText() {
  6.     var strFile = document.getElementById("file").value;;
  7.     var strText = document.getElementById("text").value;
  8.     document.applets[0].write(strFile, strText);
  9. }
  10.  
  11. function loadText() {
  12.     var strFile = document.getElementById("file").value;;
  13.     document.getElementById("text").value = document.applets[0].load(strFile);
  14. }
  15.  
  16. </script>
  17. <input type="text" id="file" value="c:\\test.txt" /><br />
  18. <textarea rows="25" cols="100" id="text">text</textarea><br />
  19. <input type="button" value="Save" onclick="saveText()" />
  20. <input type="button" value="Load" onclick="loadText()" />
  21. </html>
Apr 24 '09 #1
2 3854
pronerd
392 Expert 256MB
@JohnLorac
The description starts off talking about accessing a JavaScript file, but the URL is for a JAR file. Which is it you are trying to use? They are completely different un-related technologies. Are you trying to load a Java Applet in the page?



@JohnLorac
Meaning what exactly? Is there an error, is something happening that should not, or something not happening that should be?



@JohnLorac
Is something actually accessing it. I see where what I assume is supposed to be an applet being loaded in the page, but do not see where there is an attempt to access its contents.
Apr 29 '09 #2
Thank you for your reply.

@pronerd
I'm trying to open html file embedded in Java applet file. And then from this page control Java Applet itself. I think there is a logical error in my example, because of refence to JAR file in html file. But, basically what I need is to control Java Applet functions from html file with using javascript.

@pronerd
Originally I was trying to open html file with embedded Java Applet and then control it with javascript. But this doesn't work because I was trying to access signed (trusted) content from unsigned html file. So, I signed html file with Java class file and tries somehow access Java Applet functions from this html file. But when I put that weird link accessing html file embedded in JAR file into browser html file won't open :(. So, what is not working is that link to html file embedded in JAR file.

@pronerd
Here is the attempt to access its contents:
document.getElementById("text").value = document.applets[0].load(strFile);

But this will propably won't work because of invalid JAR reference in html file:
<applet archive="IO.jar" code="IO.class" name="io" width="0" height="0"></applet>

Inside IO.jar is this IO.html which is trying to access IO.class. (IO.class and IO.html are together inside IO.jar) I assume archive="IO.jar" is wrong reference.
But first real problem for me is that this "jar:http://www.domain.com/secure-scripts...!/thepage.html" link won't open.

Hopes it is little clearer now ;).
Apr 30 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Sruli Ganor | last post by:
Hi Netscape gurus, I'ne just installed Netscape 7.0 to my Windows PC and I'm trying to sign JavaScripts, but get errors right on the beginning. Can anyone tell me what am I doing wrong? I...
1
by: sean | last post by:
var strPath = "c:\myXml.xml"; var objDom = new ActiveXObject("Msxml2.DOMDocument"); alert('step 1'); objDom.load(strPath); alert('step 2'); ................ AFTER step 1 I'm getting an...
3
by: eft0 | last post by:
I have a big problem after I install SP2 in XP Box, some functions - window.resizeBy() - in my code, give a error like this: Access Denied. Some similar experience ?, any ideas what's...
5
by: Colin Anderson | last post by:
I discovered, with great excitement, this article http://www.davison.uk.net/vb2notes.asp when researching methods for emailing from Access via Notes. Unfortunatly, when I run this I get a...
8
by: mytfein | last post by:
Hi Everyone, Background: Another department intends to ftp a .txt file from the mainframe, for me to process. The objective is to write a vb script that would be scheduled to run daily to...
10
by: chanma | last post by:
code1:var x=0xf0000000; alert(x); output:4026531840 code2:var b=0xf<<28; alert(b); output:-268435456
8
by: David Gravereaux | last post by:
Hi, I'm using chunked transfer-coding to send an "unending" page, but IE _NEVER_ fires onresize events until the page is finished. Unfortunately, the page never is "finished". How do I handle...
1
by: lavie | last post by:
I have a signed JAR which contains an HTML page and a .JS file full of various Javascripts. I am attempting to call some of the JS from the HTML. I have tried both <script src="DnDTest.js"...
2
by: Terry Chapman | last post by:
I have a 2003 Access .mda add-in which I can sign using my Thawte digital certificate. I am now migrating this add-in to Access 2007 and when I try to add my Thawte digital signature Access 2007...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.