Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet Security: "netscape.security.*"

 
john Riche
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I'm writing Applets that save Files to disk from data from Url's using "java40.jar" (netscape.security) package? Visual Cafe 3!
Trouble is it took ages to get the IDE to recognise the classes/jar file and I have no idea how to allow other users to use the apllet or configure other machines. (errors below)
Has anyone ran into this with "java40.jar" or other classes?
Here's what I've tried :-
1. Adding the current directory to the "classpath"
2. Adding java40.jar to the "classpath"
3. Unzipping the jar to a subdir netscape\security classes
4. Copying java40.jar to classpath Jaca folders
Erors:
-------
Error: File C:\Wip\PrivilegeManager.class does not contain PrivilegeManager as expected, but netscape.security.PrivilegeManager. Please remove the file, or make sure it appears in the correct subdirectory of
Error: the class path.
Error: C:\wip\JApplet1.java(940): Class PrivilegeManager not found in type declaration
Error: C:\wip\JApplet1.java(940): Undefined variable or class name: PrivilegeManager
Any help appreciated.
Please reply ro
john_riche@hotmail.com

 
Tatiana_Konstantinova
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the full program text. Possible cause may be that Java doesn't allow to write anything to hard disk from applets.
 
john Riche
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is vast here is relevant segments:-

import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
import java.net.*;
import com.sun.java.swing.*;
import java.io.File;
import com.sun.java.swing.preview.filechooser.*;
import java.util.EventListener;
import netscape.security.*; // from java40.jar
//import com.ms.security.*;
public class JApplet1 extends JApplet
{
final private boolean bAppletSecurity = true;
public void JApplet1() //throws Exception
{
try
{ // This trick doesn't work either to enable security
/*SecurityManager sm = System.getSecurityManager();
if (sm!=null)
sm.checkSystemClipboardAccess(); */

//if (bAppletSecurity)
// this runs but doesn't do what we want
//PrivilegeManager.enablePrivilege ("UniversalSystemClipboardAccess");
//PrivilegeManager.enablePrivilege ("UniversalSystemClipboardAccessTarget");

// running these gives -> .ForbiddenTargetException
//PrivilegeManager.enablePrivilege ("checkSystemClipboardAccess");
//PrivilegeManager.enablePrivilege ("checkSystemClipboardAccess");
//PrivilegeManager.enablePrivilege ("checkSystemClipboardAccessTarget");
//if (bAppletSecurity)

}
catch(AppletSecurityException fte)
{
System.out.println("AppletSecuriyException: Clipboard" + "\n");
JOptionPane.showMessageDialog( null,
"AppletSecuriyException: Clipboard: No copy/paste",
"AppletSecuriyException",
JOptionPane.ERROR_MESSAGE );
}
Object selValue = JOptionPane.showInputDialog( null,"Email download \n" +
"LOGIN FIRST: In seperate window!"+
"\n\nEnter the full email 'URL' string to your mailbox",
"Enter Mailbox Url", JOptionPane.QUESTION_MESSAGE, null, null, sDefault);
if (selValue != null)
sMailbox = selValue.toString();
if ((sMailbox == null) | | (sMailbox.length() == 0)) //null check 1st or else DETH!
{
JOptionPane.showMessageDialog( null,
"No Server Entered: So quiting!",
"No Server Entered", JOptionPane.ERROR_MESSAGE );
return;
}
Object selValue1 = JOptionPane.showInputDialog( null,"Email download \n" +
"Enter Directory 'Folder' Path: "+
"\n\nNB: The folder must already exist!! or be created before closing this dialog",
"Enter Path", JOptionPane.QUESTION_MESSAGE, null, null, sDefPath);
if (selValue1 != null)
sDirPath = selValue1.toString();
// Test Dir entered, if valid change deault Dir
if ((sDirPath != null) && (sDirPath.length() > 0)) //null check 1st or else DETH!
{
if (bAppletSecurity)
PrivilegeManager.enablePrivilege ("UniversalFileAccess");
File name = new File(sDirPath);
if ( name.isDirectory())
{
sDefPath = sDirPath;
if (sDefPath.charAt(sDefPath.length()-1) != '\\')
sDefPath = sDefPath + "\\";
}
}
/* Object[] possibleValues = { "First", "Second", "Third" };
Object selectedValue = JOptionPane.showInputDialog(null,
"Choose one", "Input",
JOptionPane.INFORMATION_MESSAGE, null,
null, sDefault);*/

if (find("Hotmail", sMailbox))
{
int iInd = 0;
iInd = search("/cgi-bin/", sMailbox);
if (iInd > -1)
sUrlPrefix = sMailbox.substring(0, iInd);
else
sUrlPrefix = "http://lw7fd.law7.hotmail.msn.com";
sGetMsg = "/cgi-bin/getmsg?";
}
else
{
sGetMsg = JOptionPane.showInputDialog( "Email download \n\n" +
"Enter 'unique string' to help identify the email message links!"+
"\n\n\n (i.e. '/cgi-bin/getmsg?' (default)");
if ((sGetMsg == null) | | (sGetMsg.length() == 0)) //null check 1st or else DETH!
sGetMsg = "";
sUrlPrefix = JOptionPane.showInputDialog( "Email download \n\n" +
"Enter 'Server string' to prefix email message links!" +
"\n\n (Leave blank if HTML contains HTTP:// email links)");
if ((sUrlPrefix == null) | | (sUrlPrefix.length() == 0)) //null check 1st or else DETH!
sUrlPrefix = "";
}
/* if isNum(sMailbox)
{
sServerID = JOptionPane.showInputDialog( "Email download \n\n" +
"Number entered so assuming Hotmail Account!"+
"\n\n\n (Please enter Hotmail 'Server' number where a/c resides? i.e. 7(default)" );
if ((sServerID == null) | | (sServerID.length() == 0)) //null check 1st or else DETH!
sServer = "http://lw7fd.law7.hotmail.msn.com/cgi-bin/HoTMaiL?n=";
else
sServer = "http://lw" + sServerID +"fd.law" + sServerID + ".hotmail.msn.com/cgi-bin/HoTMaiL?n=";
sUrlPrefix = sServer.substring(0,search("/cgi-bin/", sServer));
sServer = sServer + sMailbox + "&fti=yes&_lang=EN";
sGetMsg = "/cgi-bin/getmsg?";
}
else
{
sGetMsg = JOptionPane.showInputDialog( "Email download \n\n" +
"Enter 'unique string' to help identify the email message links!"+
"\n\n\n (i.e. '/cgi-bin/getmsg?' (default)" +
"\n\n Add 'http://server-name.com/getmsg?' if absent from links in HTML" +);
if ((sGetMsg == null) | | (sGetMsg.length() == 0)) //null check 1st or else DETH!
sGetMsg = "/cgi-bin/getmsg?";
//sYahoo="http://lw4fd.law4.hotmail.msn.com/cgi-bin/HoTMaiL?n=26780&fti=yes&_lang=EN";
}*/
String sQuery="";
String s1="";
String s2="";

//s1 = "http://lw7fd.law7.hotmail.msn.com/cgi-bin/HoTMaiL?n=";
//s2 = "&fti=yes&_lang=EN";
//sServer = "lw7fd.law7.hotmail.msn.com";
//sMailbox = s1 + sMailbox + s2;
//aHTML = urlArray(sYahoo);
//sYahoo = "http://lw7fd.law7.hotmail.msn.com/cgi-bin/getmsg?curmbox=F000000001&a=866670099866586774&msg=MSG972576734.13&start=1319346&len=2561&msgread=1&mfs=1290";
// NB: Clicking cancel on dialog causes null pointer? unless NULL is used!!?
/* if ((sYahoo != null) && (sYahoo.length() > 0)) //null check 1st or else DETH!
{
// NB Yahoo search requires spaces between words ion search page field to operate correctly!
// so we can insist on that also, no +metro+storage -> +metro +storage
sQuery = sYahoo;
sYahoo = sYahoo.trim();
sYahoo = replace(sYahoo,"+", "%2b");
// set this correct!!
sYahoo = replace(sYahoo,"\"", "%22");
sYahoo = replace(sYahoo," ", "+");
if (sYahoo.charAt(0) == '+')
sYahoo = sYahoo.substring(1,sYahoo.length()); // remove 1st 'unwanted' +, substring -1 off index
sYahoo = "http://google.yahoo.com/bin/query?p=" + sYahoo;
}*/
/* JOptionPane.showMessageDialog( null,
sYahoo,


Originally posted by john Riche:
Hi
I'm writing Applets that save Files to disk from data from Url's using "java40.jar" (netscape.security) package? Visual Cafe 3!
Trouble is it took ages to get the IDE to recognise the classes/jar file and I have no idea how to allow other users to use the apllet or configure other machines. (errors below)
Has anyone ran into this with "java40.jar" or other classes?
Here's what I've tried :-
1. Adding the current directory to the "classpath"
2. Adding java40.jar to the "classpath"
3. Unzipping the jar to a subdir netscape\security classes
4. Copying java40.jar to classpath Jaca folders
Erors:
-------
Error: File C:\Wip\PrivilegeManager.class does not contain PrivilegeManager as expected, but netscape.security.PrivilegeManager. Please remove the file, or make sure it appears in the correct subdirectory of
Error: the class path.
Error: C:\wip\JApplet1.java(940): Class PrivilegeManager not found in type declaration
Error: C:\wip\JApplet1.java(940): Undefined variable or class name: PrivilegeManager
Any help appreciated.
Please reply ro
john_riche@hotmail.com

 
Tatiana_Konstantinova
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that it's simply restricted to use PrivilegeManager and to write any data to the files or to create any new files from an applet, you can do it only from an application.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic