Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / March 2005

Tip: Looking for answers? Try searching our database.

JDBC and oracle signed applet problem.

Thread view: 
Paul Rosser - 17 Aug 2004 04:59 GMT
I have written a applet that reads and writes data from a database. I
initially wrote the application to connect to a MYSQL database and
everything ran fine. I then changed the className and connect strings
for oracle and tested it with 'all permissions' on. works fine.

I then packaged the oracle class files in with the signed java applet
and tested.
With 'all permissions' set in the Policy file it works fine. With this
removed I can still connect to the mysql database but the oracle
database is returning the error.

Error loading Driver: java.security.AccessControlException: access
denied (java.net.SocketPermission database server resolve)

I would have thought by signing the jar file I would have got around
this sort of error. What am I missing?

Here is an extract of code.

================================================================
classPath = "jar:"+String.valueOf(getCodeBase()+"Contacts/Contacts.jar!/");
if (sDBtype.indexOf("mysql")==0) {
       className = "com.mysql.jdbc.Driver";
   } else if (sDBtype.indexOf("oracle")==0) {
       className = "oracle.jdbc.driver.OracleDriver";
   } else if (sDBtype.indexOf("odbc")==0) {
       className = "sun.jdbc.odbc.JdbcOdbcDriver";
   } else {
       System.out.println ("Unknown database type "+sDBtype+". Please
use either mysql, oracle or odbc");
   }
   URL classURL = new URL(classPath);
   URLClassLoader loader = new URLClassLoader(new URL[] {classURL});
   Class c = Class.forName(className, true, loader);
   Class.forName(className, true, loader).newInstance();
   Driver drv = (Driver)c.newInstance ();
   DriverManager.registerDriver(new DriverShim(drv));
   timer("3");
} catch (Exception e) {
   System.out.println("Error loading Driver: "+e);
}
if (sDBtype.indexOf("mysql")==0) {
   db=new Database("jdbc:mysql://"+sDBhost+":"+sDBport+"/"+sDBdatabase,sDBusername,sDBpassword);
} else if (sDBtype.indexOf("oracle")==0) {
   db=new Database("jdbc:oracle:thin:@"+sDBhost+":"+sDBport+":"+sDBdatabase,sDBusername,sDBpassword);
} else if (sDBtype.indexOf("odbc")==0) {
   db=new Database("jdbc:odbc:"+sDBdatabase,sDBusername,sDBpassword);
}
========================================================
KC Wong - 17 Aug 2004 07:12 GMT
> Error loading Driver: java.security.AccessControlException: access
> denied (java.net.SocketPermission database server resolve)

If you put the error message in Google Groups, you'll find a lot of posts
about it...

Most of them end the discussion with:
1. Applets are restricted to connect to the server that host it
2. You need to sign the applet to do that

I haven't got the time to try it (haven't done these things lately... have
done it before but forgot the details), but I have a few thoughts:

1. Cache. You might be running a cached version of your class. Try clearing
IE's and your plug-in's cache.
2. JavaScript. IIRC starting from 1.3, applets invoked from unsigned
JavaScript will take on the JavaScript's security context - thus many
operations are not allowed. Is your applet's method invoked from JavaScript?
There're signed JavaScript, but IE does not support it. There're some
resources on the web about it though... Google for it.
Paul Rosser - 17 Aug 2004 14:13 GMT
Understand. However the Applet has been archived into a jar file and signed.

Signing does work as the SQL works but not the Oracle.

Paul

> > Error loading Driver: java.security.AccessControlException: access
> > denied (java.net.SocketPermission database server resolve)
[quoted text clipped - 16 lines]
> There're signed JavaScript, but IE does not support it. There're some
> resources on the web about it though... Google for it.
Paul Rosser - 17 Aug 2004 14:14 GMT
Understand. However the Applet has been archived into a jar file and signed.

Signing does work as the SQL works but not the Oracle.

Paul

> > Error loading Driver: java.security.AccessControlException: access
> > denied (java.net.SocketPermission database server resolve)
[quoted text clipped - 16 lines]
> There're signed JavaScript, but IE does not support it. There're some
> resources on the web about it though... Google for it.
Alba Garrah Garrah - 11 Mar 2005 21:55 GMT
did you find a solution for this problem I am having the same problem.
Alba


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.