Solved

IE's version of the netscape Capabilities classes?

Posted on 2000-05-05
7
199 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
Comment Utility
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
Comment Utility
0
 

Expert Comment

by:Blob
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Expert Comment

by:Blob
Comment Utility
oops  not a comment  ;)
0
 

Expert Comment

by:Blob
Comment Utility
Blob changed the proposed answer to a comment
0
 

Accepted Solution

by:
Blob earned 100 total points
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

763 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

6 Experts available now in Live!

Get 1:1 Help Now