473,545 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with access to signed javascript file

5 New Member
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 3868
pronerd
392 Recognized Expert Contributor
@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
JohnLorac
5 New Member
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.getEle mentById("text" ).value = document.applet s[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
3785
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 went to Edit->Preferences->Software Security Device->Change Password and set my password. Then I copied the updated cert7.db and key3.db to my folder...
1
3001
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 errorrrrrrrrrrrr. Im just going crazy. Error: Access denied!
3
2094
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 happening here ?, Thanks in advanced. Esteban.
5
7368
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 Run-time error. When I run it on an XP machine it crashes, but on an NT box it just generates an unknown error, handled by the error handler. I have...
8
3354
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 process this .txt file. Goal: I am working on a vba script to:
10
2392
by: chanma | last post by:
code1:var x=0xf0000000; alert(x); output:4026531840 code2:var b=0xf<<28; alert(b); output:-268435456
8
7851
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 this?
1
1450
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" language=javascript></script> and <script src="jar://localhost/output.jar!/DnDTest.js" language=javascript></script>, but it still doesn't recognize the JS...
2
4756
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 says 'Cannot save the digital signature at this time' and suggests that I 'package and sign' the file from the Microsoft Office Button / Publish /...
0
7682
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. ...
0
7935
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...
0
7780
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...
0
6009
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5351
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...
0
5069
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
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

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.