/    Sign up×
Community /Pin to ProfileBookmark

Signed applet fails to access the remote file

hi
I have a applet, and this gets invoked by the javascript.
The purpose of the applet is to fetch the values from a txt file which is in remote server.

Earlier, I have the JRE1.4.1… during this version my applet worked fine.
But now when the JRE is updated to the 1.4.2 the same applet is not working.

In some other forum, i read that giving AllPermissions in the policy file will solve this issue.
But giving such permission is not insecure.
and when the applet is tryign to access the file the followign exception is thrown.

java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.53:8080 resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.checkPermission(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.[url]www.protocol.http.HttpURLConnection.getOutputStream[/url](Unknown Source)
at CMI_Saba.doIt(CMI_Saba.java:121)
at CMI_Saba.getCMIgetParam(CMI_Saba.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)

at sun.plugin.com.DispatchImpl.invoke(Unknown Source) java.lang.Exception: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.53:8080 resolve)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)

[sample code:begin]

aicc_conn = aicc_url.openConnection();
……
……
……
aicc_conn.setUseCaches(false);
aicc_conn.setRequestProperty(“Content-length”, String.valueOf(s.length()));
aicc_conn.setRequestProperty(“Content-Type”, “application/x-www-form-urlencoded”);
DataOutputStream dataoutputstream = new DataOutputStream(aicc_conn.getOutputStream());
dataoutputstream.writeBytes(s);
dataoutputstream.flush();
[sample code:end]

CMI_Saba.java:121 ==> DataOutputStream dataoutputstream = new DataOutputStream(aicc_conn.getOutputStream());

Pls give some solution to solve this issue.

THNX’n ADV
Deva

to post a comment
Java

4 Comments(s)

Copy linkTweet thisAlerts:
@Java_WarriorOct 12.2004 — Did you use JDK1.4.2_05 to compile your applet? This is certainly a problem if you're compiling using an old JDK and a new JRE.

If that isn't it, you will have to write a new SecurityManager policy, and have a button that the user clicks agreeing to it. Must you have a signed applet?
Copy linkTweet thisAlerts:
@gdevapitchaiauthorOct 13.2004 — Will problem can be solved by upgrading the JRE version?

My applet is a signed applet.

can u please tell me how to create new security policy in order to solve this problem.

Its urgent.

Thnx
Copy linkTweet thisAlerts:
@gdevapitchaiauthorOct 13.2004 — This is the policy file that i have.

..............

grant codeBase "http://192.168.0.53:8080/jsp-examples/lms.txt" {

permission java.security.AllPermission;

permission java.net.SocketPermission "*", "accept, connect, listen, resolve";

permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete, execute";

permission java.net.SocketPermission "*
", "resolve";

};

..............


My applet is tryign to access the http://192.168.0.53:8080/jsp-examples/lms.txt file

THe applet is called from the js.

Here is the codes..


import java.applet.Applet;

import java.io.*;

import java.net.*
;

public class CMI_Saba extends Applet

{

public String getResponseText()

{

return commText;

}

public String getCMIgetParam()

{

System.out.println("---=== getCMIgetParam ===---n");

String s = "command=GetParam&version=" + aicc_version + "&session_id=" + aicc_sid;

doIt(s);

System.out.println("Response from LMS:");
-


-
-


-
-


-

}

public int setCMIComm(String s, String s1, String s2)

{

try

{

aicc_url = new URL(s);

aicc_sid = URLEncoder.encode(s1);

aicc_version = URLEncoder.encode(s2);

........

}

catch(MalformedURLException exception)

{

}

-
-


-

}


private void doIt(String s)

{

try

{

aicc_conn = aicc_url.openConnection();

aicc_conn.setDoInput(true);

aicc_conn.setDoOutput(true);

aicc_conn.setUseCaches(false);

aicc_conn.setRequestProperty("Content-length", String.valueOf(s.length()));

aicc_conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

DataOutputStream dataoutputstream = new DataOutputStream(aicc_conn.getOutputStream());

dataoutputstream.writeBytes(s);

dataoutputstream.flush();

System.out.println("Passing data to LMS:");

System.out.println("--------------------");

System.out.println(s + "n");

BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(aicc_conn.getInputStream()));

String s1;

for(commText = ""; (s1 = bufferedreader.readLine()) != null; commText += "nr")

commText += s1;

statVal = 0;

dataoutputstream.close();

bufferedreader.close();

}

catch(IOException exception)

{

System.err.println("n** !!! ERROR occured -> " + exception.toString() + " !!! **");

errString = exception.toString();

commText = "2";

statVal = 2;

}

catch(Exception e)

{

System.err.println("n** !!! ERROR occured -> " + e.toString() + " !!! **");

errString = e.toString();

commText = "2";

statVal = 2;

}

}


the java script is

..........

function getCMIAppletHTMLCode() {

//get the applet file

document.write('<APPLET CODE="CMI_Saba" archive="CMI_Saba.jar" ID="AICCApplet" NAME="AICCApplet" WIDTH=1 HEIGHT=1><PARAM NAME="cabbase" VALUE="CMI_Saba.cab"></APPLET>');

}

..........


Pls give me a solution...This is very urgent.
Copy linkTweet thisAlerts:
@ray326Oct 13.2004 — Have you tried grant codeBase "http://192.168.0.53:8080/jsp-examples/*" in that policy file?
×

Success!

Help @gdevapitchai spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...