Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Wierd Sun plug-in problem...

0 views
Skip to first unread message

FBeleski

unread,
Aug 4, 2002, 2:06:55 PM8/4/02
to
I wrote an applet that resides on my_domain.com and connects to
other_domain.com.

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

--

FBeleski

unread,
Aug 5, 2002, 8:24:15 AM8/5/02
to
I found what seems to be the problem, just don't know how to fix it...

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...

VK

unread,
Aug 5, 2002, 10:47:52 AM8/5/02
to
Well, nothing wierd in it, it's normal secure bahaviour.

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...

FBeleski

unread,
Aug 5, 2002, 2:19:59 PM8/5/02
to
Well, this page
http://java.sun.com/products/plugin/1.3/enhancements/security.html says:

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...

0 new messages