IE's version of the netscape Capabilities classes?

I have been having trouble with Netscape's Capabailities classes (See my other question)  so I want to try the MS Solution.

Is there a way to cause a security request dialog to come up in IE to request permssion to load and execute code from a dll using JNI in a signed applet?

I
sforbesAsked:
Who is Participating?
 
BlobConnect With a Mentor Commented:
SORRY....


Hi,
                       for IE-Applets  put the DLL in the search-Path, sign the Applet with the needed Permissions and use it, no Problem.

                       for Netscape-Applets create a Env.-Var. LD_LIBRARY_PATH put the DLL in the right Directory and use the dll.

                       to get the Permissions i try this (it Works):

                       if (AppletContextInfo.isNetscapeNavigator()) <----- My Class....
                       try {
                       PrivilegeManager.enablePrivilege("30Capabilities");
                       PrivilegeManager.enablePrivilege("UniversalFileAccess");
                       } catch (Exception exc){
                       System.out.println(" dont get Privilege ");
                       }
                       if (AppletContextInfo.isMicrosoftInternetExplorer())<----- My Class...
                       try {
                       if (Class.forName("com.ms.security.PolicyEngine") != null) {
                            PolicyEngine.assertPermission(PermissionID.FILEIO);
                            PolicyEngine.assertPermission(PermissionID.NETIO);
                            PolicyEngine.assertPermission(PermissionID.PROPERTY);
                            PolicyEngine.assertPermission(PermissionID.UI);
                       }
                          } catch (Throwable cnfe) {
                       System.out.println(" dont get Permisions ");
                          }

                       Greetimgs
                       Christo
0
 
Ravindra76Commented:
Anything to local PC could be accessed via a JNI wrapper to your C++ code, once the applet has been
signed(your browser gives authority)
From: hkfung  Title: "DLL Loading in JAVA"  
Status: Answered.This question is locked until hkfung evaluates the answer.
Points: 50 Points (Easy)  Date: Tuesday, November 16 1999 - 04:23PM CST  
 
I have a DLL in win32 and i need to execute its function from JAVA. I dont not have the codes
 to the DLL.

Please provide sample codes with some explaination.
 
 
Proposed Answer
 
 From: mbormann
 Date: Tuesday, November 16 1999 - 05:11PM CST  
 


Text below...

 
 
 
   Question History  
 

 Proposed Answer
 
 From: mbormann
 Date: Tuesday, November 16 1999 - 05:11PM CST  
 
first off if u have any problem pls ask.
u can read the following good links

look
http://www.experts-exchange.com/bin/Q.10211064 

but i think that this will solve ur problem.

http://www.experts-exchange.com/bin/Q.10081643 

copying text from there to here so u save 10 points.
:-)
 
Previously Asked Java Programming Question
 
From: angelany  Title: "Writing Java code using native methods in dll file"  
Points: 10 Points  Date: Thursday, September 17 1998 - 08:35AM PDT  
 
Hi,

I am working on WindowsNT 4.0 and need to write Java code that invokes a computation core
already implemented in C,
but the core is only available as a dll file, no source
code.

I read about JNI on Sun's Java tutorial, but that would
require re-writing original C functions such that the signature matche the header file
declaratoins. This
header file is generated by "javah -jni MyFile.java" and
its signature is fixed. And since I don't have the option
to touch the core dll implementation, I can't make the
match.

How can this be done?

Any help is appreciated.

Angelany
 
 
Accepted Answer
 
 From: msmolyak
 Date: Thursday, September 17 1998 - 09:45AM PDT  
 


Text below...
 
 
 
   Question History  
 
Accepted Answer
 
 From: msmolyak
 Date: Thursday, September 17 1998 - 09:45AM PDT  
 
You can do it as long as you have an API to the third party DLL. All you have to do is to
create your own DLL which contains native implementations of Java methods where C or C++
routines will have signatures generated by javah. All those routines would do is to invoke
 the appropriate functions in the target DLL with known API. I did it earlier for ODBC  
(where ODBC driver manager was the third party DLL) and we created our own DLL calling the
 ODBC methods.
 
 

Comment
 
 From: angelany
 Date: Thursday, September 17 1998 - 10:26AM PDT  
 
msmolyak,

Thanks for your answer. There are still a few things that I
don't quite understand. Would you please elaborate a little more?

Suppose I have these files:
test.dll -- the core dll file
TestMain.java -- the test application in Java, it calls class and methods in "Rate.java"
Rate.java -- the Java file that contains definition of native methods
Rate.h  -- generated by "javah -jni Rate.java"
Rate.c  -- generated by "javah -stubs Rate.java"

Now, should I write a code called something like "RateImp.c"
to implement all the signatures in "Rate.h"? How are the Java
specific types handled? How does the "Rate.c" come into play?

Thanks.

Angelany
 
 

Comment
 
 From: msmolyak
 Date: Thursday, September 17 1998 - 10:33AM PDT  
 
First of all you do need stubs if you are using JNI, stubs were needed for the old native
 interface. Thus you just take Rate.h and create a C file (e.g., RateImp.c) where you will
 implement the methods according to their signatures. You do not need your Rate.c
 
 

Comment
 
 From: angelany
 Date: Friday, September 18 1998 - 09:48AM PDT  
 
Hi msmolyan,

I still have trouble passing data types to and from Java.
Could you please give an example on passing an object and
a string? Thanks a lot.

Angelany
 
 

Comment
 
 From: msmolyak
 Date: Friday, September 18 1998 - 10:41AM PDT  
 
Here is an example. The first two parameters (JNIEnv and jobject) are present in all teh calls. The first is the environment, the second is pointer to the invoker object. In this example I pass file name as a parameter and convert it from Java string to C string. Then I invoke a C function using that string.

Go to the JNI Spec and tutorial on Javasoft's Web site, a lot of useful info.

/**
 * This function opens specified configuration file for reading or writing.
 */
JNIEXPORT void JNICALL Java_com_excalib_rw_CfgObjectAdapter_openConfigFiles
  (JNIEnv * env, jobject obj, jstring jFileName)
{
char *cfgFileName;

// Convert Java string to C string
cfgFileName = (*env)->GetStringUTFChars(env, jFileName, (jboolean)NULL);

// Call RetrievalWare API function openning configuration file.
cq_open_conquest_cfg(cfgFileName, FILE_OPEN_FOR_READ);

}
 
 

 Comment
 
 From: mbormann
 Date: Tuesday, November 16 1999 - 05:18PM CST  
 
Oops forgot to paste URL's

Apart from the JNI tutorial from Sun at
http://java.sun.com/docs/books/tutorial/native1.1/index.html 

,see from a PAQ at EE ,again pasting from there to here.
from http://www.experts-exchange.com/bin/Q.10203703 

See these
http://www.math.tau.ac.il/system/java/jdk1.0.2/tutorial/native1.1/ 

This is one of the Best and I used it at Start and also now....
http://home.pacifier.com/~mmead/cs510jip/jni/ 

http://www.itlibrary.com/reference/library/1575212986/htm/ch32.htm 

look at CodeGuru's Links to other good sites.
http://codeguru.developer.com/java/JNI/index.shtml 
 
http://www.cs.pdx.edu/~antoy/Courses/Advanced/units/jni/ 

http://www.swtech.com/java/native/ 

this one is repeating everything they tell but for beginners it looks good.
  http://herzberg1.ca.sandia.gov/JavaCourse/Java_1_1-Week5.html 
 
 
   
 

 
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
BlobCommented:
Hi,
for IE-Applets  put the DLL in the search-Path, sign the Applet with the needed Permissions and use it, no Problem.

for Netscape-Applets create a Env.-Var. LD_LIBRARY_PATH put the DLL in the right Directory and use the dll.

to get the Permissions i try this (it Works):

if (AppletContextInfo.isNetscapeNavigator()) <----- My Class....
            try {
                  PrivilegeManager.enablePrivilege("30Capabilities");
                  PrivilegeManager.enablePrivilege("UniversalFileAccess");
            } catch (Exception exc){
                  System.out.println(" dont get Privilege ");
            }
            if (AppletContextInfo.isMicrosoftInternetExplorer())<----- My Class...
            try {
                   if (Class.forName("com.ms.security.PolicyEngine") != null) {
                                  PolicyEngine.assertPermission(PermissionID.FILEIO);
                                  PolicyEngine.assertPermission(PermissionID.NETIO);
                                  PolicyEngine.assertPermission(PermissionID.PROPERTY);
                                  PolicyEngine.assertPermission(PermissionID.UI);
                    }
              } catch (Throwable cnfe) {
                        System.out.println(" dont get Permisions ");      
              }

Greetimgs
Christo
0
 
BlobCommented:
oops  not a comment  ;)
0
 
BlobCommented:
Blob changed the proposed answer to a comment
0
 
sforbesAuthor Commented:
I am accepting this answer here in this question, but please see my other question because the overall thing is still not working.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.