Access files from a Java applet

I am using a java applet to select a gml file and validate it using the xsd schema.

String selectedPath; FileDialog selectFileDialog; private String ShowFileDialog(String title, String extension) { selectFileDialog.setFile(extension); selectFileDialog.setTitle(title); selectFileDialog.setVisible(true); if (selectFileDialog.getFile() == null) return null; return selectFileDialog.getDirectory() + selectFileDialog.getFile(); } public void SelectFile(){ selectedPath = ShowFileDialog("Select file", "*.gml"); } public void ProcessFile(){ InputStream inputStream = new FileInputStream(new File(selectedPath)); InputSource inputSource = new InputSource(inputStream); //... sending file to sax parser } 

The GUI consists of only two java.awt buttons that invoke these functions.

Manifest.mf file includes

Permissions: All Permissions

I also signed the jar file due to permission issues. Therefore, it works without any doubt.

But the problem is that when I run these (public) functions from javascript, it throws an exception below

 //This functions is working properly, shows FileDialog and selecting file document.applets[0].SelectFile(); //This function throws exception. //Instead of clicking this button i can click java gui button and execute function properly document.applets[0].ProcessFile(); access denied ("java.io.FilePermission" "blablafile.gml" "read") 

I ask because I do not want to use java gui elements, I have to fire these events from pure HTML elements.

+4
source share

Source: https://habr.com/ru/post/1433501/


All Articles