It's signed with a Thawte certificate and one of the functions I wrote works
while another one doesn't!
Here is the source code for check_server:
it does read a page to check if the server is OK and returns an index for
the server
mb[0] is http://server0.other_domain.com
mb[1] is http://server1.other_domain.com
private int m_check_serv()
{
int i, j;
BufferedReader in;
URLConnection c;
String dado, linha;
URL u;
for(i = 0; i < 2; i++)
{
try
{
linha = mb[i] + "/check_server.htm";
u = new URL(linha);
try
{
c = u.openConnection();
try
{
in = new BufferedReader(new InputStreamReader(c.getInputStream()));
dado = in.readLine();
in.close();
// check it
j = dado.indexOf("SERVER OK");
if(j != -1)
{
System.out.println("ok " + mb[i] + " " + dado);
return i;
}
else
{
System.out.println("fail " + mb[i] + " " + dado);
}
}
catch(IOException ioe)
{
System.out.println("IOE fail " + mb[i]);
}
}
catch(IOException ioe)
{
System.out.println("IOE fail " + mb[i]);
}
}
catch(MalformedURLException e)
{
System.out.println(" MURL fail " + mb[i]);
}
}
return -1;
}
This function works fine, running in a separate thread that checks the
servers every 30 seconds....
Also, this function is called from init() without a problem...
The second function is invoked by another function, a public one called from
the page, running on the main thread.
//===========================================================
// request
//===========================================================
private void monta()
{
int i;
double rr;
BufferedReader in;
URLConnection c;
String checa, linha;
NumberFormat fmt;
DecimalFormatSymbols dfs;
URL u, u2;
do
{
System.out.println("waiting for a server...");
} while(server < 0);
// format for the data to be sent
fmt = NumberFormat.getNumberInstance();
dfs = ((DecimalFormat)fmt).getDecimalFormatSymbols();
dfs.setDecimalSeparator('.');
((DecimalFormat)fmt).setDecimalFormatSymbols(dfs);
((DecimalFormat)fmt).applyPattern("#0.00000000");
limites = "";
try
{
linha = mb[server] + "/monps/jmonps.asp?cx=" + cx + "&cy=" + cy + "&r="
+ raio + "&u=" + sref;
}
u = new URL(linha);
try
{
while(true)
{
c = u.openConnection();
try
{
=======> HERE IS WHERE THE ERROR HAPPENS <========
in = new BufferedReader(new InputStreamReader(c.getInputStream()));
limites = in.readLine();
in.close();
// if the data is ok, break the loop;
break;
}
catch(IOException ioe)
{
System.out.println("monta 12");
return;
}
}
}
catch(IOException ioe)
{
System.out.println("monta 13");
return;
}
}
catch(MalformedURLException e)
{
System.out.println("monta 14");
return;
}
}
Here is the output from Java console:
java.security.PrivilegedActionException:
java.lang.reflect.InvocationTargetException
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.liveconnect.SecureInvocation$2.run(SecureInvocation.java:144)
at java.security.AccessController.doPrivileged(Native Method)
at
sun.plugin.liveconnect.SecureInvocation.CallMethod(SecureInvocation.java:123
)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
sun.plugin.liveconnect.PrivilegedCallMethodAction.run(SecureInvocation.java:
505)
... 4 more
Caused by: java.security.AccessControlException: access denied
(java.net.SocketPermission server0.other_domain.com resolve)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:270)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1042)
at
sun.plugin.net.protocol.http.HttpURLConnection.checkPermission(HttpURLConnec
tion.java:193)
at
sun.plugin.net.protocol.http.HttpURLConnection.connect(HttpURLConnection.jav
a:144)
at
sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(HttpURLConnect
ion.java:361)
at myClass.monta(MyClass.java:408)
at MyClass.m_zoom(MyClass.java:1238)
... 9 more
So, it looks like some sort of security problem but I can't figure what is
wrong.
Why one function works fine and the other one doesn't?
Thanks for any help...
FB
--
Functions called from within the applet have no security problems and can
access all sites...
Calling an applet function from JavaScript on the HTML page causes the
security exception...
FB
--
"FBeleski" <no_...@domain.com> wrote in message
news:n6e39.19766$PH5....@t01.sjc1.webusenet.com...
You may to:
1. Use trusted JavaScript .js file from signed jar (works for Netscape only
I believe, did not play too much with this toy yet).
2. Set glob vars in your JavaScript as flags and check them in loop from
your applet.
FBeleski <no_...@domain.com> wrote in message
news:n6e39.19766$PH5....@t01.sjc1.webusenet.com...
JavaScript-to-Java Communication
In JavaScript-to-Java communication, a call from JavaScript to an applet is
allowed only if one or both of the following is true:
The origin (URL) of the page is the same as the origin of the applet;
JavaScript is signed and UniversalBrowserRead permission is enabled for
JavaScript.
Without 1 or 2 being true, no call will be allowed from JavaScript to Java.
Given that a call is allowed, then there are two possibilities: JavaScript
will have default or all permissions.
In my case, the page and the applet are on the same server....
FB
--
"VK" <school...@yahoo.com> wrote in message
news:sew39.25419$Kl6.1...@bgtnsc04-news.ops.worldnet.att.net...