Solved

IE's version of the netscape Capabilities classes?

Posted on 2000-05-05
7
202 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:sforbes
  • 4
  • 2
7 Comments
 
LVL 7

Expert Comment

by:Ravindra76
ID: 2782415
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
 
LVL 7

Expert Comment

by:Ravindra76
ID: 2782428
0
 

Expert Comment

by:Blob
ID: 2799364
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:Blob
ID: 2799450
oops  not a comment  ;)
0
 

Expert Comment

by:Blob
ID: 2799454
Blob changed the proposed answer to a comment
0
 

Accepted Solution

by:
Blob earned 100 total points
ID: 2799456
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
 

Author Comment

by:sforbes
ID: 2800399
I am accepting this answer here in this question, but please see my other question because the overall thing is still not working.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now