1
My applet is signed and all his methods are public.
This error message appears for all browsers I have tested.
Follows the codes:
Main java.
public class Main extends Applet {
private String ip;
private String macLocal;
private String md5;
private InetAddress ipLocal;
@Override
public void init() {
super.init(); //To change body of generated methods, choose Tools | Templates.
}
public String returnIp(){
try {
ipLocal = InetAddress.getLocalHost();
ip = ipLocal.getHostAddress();
} catch (UnknownHostException ex) {
Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
}
return ip;
}
public String returnMac(){
try {
ipLocal = InetAddress.getLocalHost();
NetworkInterface network = NetworkInterface.getByInetAddress(ipLocal);
byte[] mac = network.getHardwareAddress();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
macLocal = sb.toString();
} catch (SocketException ex) {
Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnknownHostException ex) {
Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
}
return macLocal;
}
public String returnMD5(){
try {
MessageDigest m=MessageDigest.getInstance("MD5");
String ipMaisMac = new StringBuffer(retornaIp()).reverse().toString() + new StringBuffer(retornaMac()).reverse().toString() ;
m.update(ipMaisMac.getBytes(),0,ipMaisMac.length());
BigInteger i = new BigInteger(1, m.digest());
md5 = String.format("%1$032X", i);
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
}
return md5;
}
js encryption.
function encript() {
var applet = document.getElementById("principal-object")
alert(typeof(applet));
if(typeof(applet) == "undefined") {
alert("Undefined")
} else {
document.getElementById("token").value = applet.returnMD5();
document.getElementById("local_ip").value = applet.returnIp();
document.getElementById("tolocal_macken").value = applet.returnMac();
}
}
index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="encript.js"></script>
</head>
<body onload="encript()">
<form action="login.php">
Login:
<input type="text" name="login" value="" /> Password:
<input type="password" name="password" value="" />
<input type="hidden" name="local_ip" id="local_ip" value="00" />
<input type="hidden" name="local_mac" id="local_mac" value="00" />
<input type="hidden" name="token" id="token" value="00" />
<button>Login!</button>
</form>
<object id="principal-object" width="256" height="256">
<param name="archive" value="Encript.jar" />
<param name="code" value="br.com.encript.applets.Main" />
<param name="mayscript" value="true" />
</object>
</body>
</html>
I don’t understand much, but it seems a cast error. Don’t have to convert first to type
Main
and then call the function?– Piovezan