Fix for issues 567 and also remove multiple calls to beef.browser.hasJava() from /beef/core/main/client/net/local.js

This commit is contained in:
Keith Lee
2012-03-07 01:41:27 +08:00
parent 95f7e92011
commit 97672966df
5 changed files with 70 additions and 13 deletions

View File

@@ -499,11 +499,33 @@ beef.browser = {
*
* @example: if(beef.browser.hasJava()) { ... }
*/
hasJava: function() {
if(!this.type().IE && window.navigator.javaEnabled && window.navigator.javaEnabled()) {
return true;
//If chrome detected, return false. Do not run java applet
if(beef.browser.isC()){
return false;
}
else{
//Create java applet here and test for execution
var applet_archive = 'http://'+beef.net.host+ ':' + beef.net.port + '/demos/checkJava.jar';
var applet_id = 'checkJava';
var applet_name = 'checkJava';
var output;
beef.dom.attachApplet(applet_id, 'Microsoft_Corporation', 'checkJava' ,
null, applet_archive, null);
output = document.Microsoft_Corporation.getInfo();
beef.dom.detachApplet('checkJava');
if(output=1){
return true;
}
else{
return false;
}
}
}
return false;
},
/**

View File

@@ -21,6 +21,8 @@
beef.net.local = {
sock: false,
checkJava: false,
hasJava: false,
/**
* Initializes the java socket. We have to use this method because
@@ -29,16 +31,30 @@ beef.net.local = {
* is invalid:
* sock: new java.net.Socket();
*/
initializeSocket: function() {
if(! beef.browser.hasJava()) return -1;
try {
this.sock = new java.net.Socket();
} catch(e) {
return -1;
if(this.checkJava){
if(!beef.browser.hasJava()) {
this.checkJava=True;
this.hasJava=False;
return -1;
}else{
this.checkJava=True;
this.hasJava=True;
return 1;
}
}
else{
if(!this.hasJava) return -1;
else{
try {
this.sock = new java.net.Socket();
} catch(e) {
return -1;
}
return 1;
}
}
return 1;
},
/**
@@ -47,7 +63,7 @@ beef.net.local = {
* @error: return -1 if the internal ip cannot be retrieved.
*/
getLocalAddress: function() {
if(! beef.browser.hasJava()) return false;
if(!this.hasJava) return false;
this.initializeSocket();
@@ -65,7 +81,7 @@ beef.net.local = {
* @error: return -1 if the hostname cannot be retrieved.
*/
getLocalHostname: function() {
if(! beef.browser.hasJava()) return false;
if(!this.hasJava) return false;
this.initializeSocket();
@@ -79,4 +95,4 @@ beef.net.local = {
};
beef.regCmp('beef.net.local');
beef.regCmp('beef.net.local');

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,19 @@
import java.io.*;
import java.util.*;
import java.net.*;
import java.applet.*;
// Keith Lee
// Twitter: @keith55
// http://milo2012.wordpress.com
// keith.lee2012[at]gmail.com
public class checkJava extends Applet{
public static int results = 0;
public void init() {
}
public int getInfo() {
results = 1;
return results;
}
}