Jsf + pegar ip e mac da maquina que esta fazendo login
3 respostas
G
GustavoTavone
Preciso desenvolver um sistema de login com jsf, que ao usuario autenticar me retorne o ip e o mac da maquina do usuario que esta autenticando.
Ja tentei usar InetAddress, NetworkInterface. Onde ele me retorna o mac e o ip do servidor q esta armazenado minha aplicação.
Como fazer para pegar o mac e o ip da maquina que esta fetuando o login???
Agora o mac já não sei, provavelmente tera que usar um applet ou algum activex para obter esse tipo de informação…
G
Gbzao
Ip
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
String ip = request.getRemoteAddr();
MacAddress
public String getMACAddress(String ip){
String str = "";
String macAddress = "";
try {
Process p = Runtime.getRuntime().exec("nbtstat -A " + ip);
InputStreamReader ir = new InputStreamReader(p.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
for (int i = 1; i < 100; i++) {
str = input.readLine();
if (str != null) {
if (str.indexOf("MAC Address") > 1) {
macAddress = str.substring(str.indexOf("MAC Address") + 14, str.length());
break;
}
}
}
} catch (IOException e) {
e.printStackTrace(System.out);
}
return macAddress;
}
V
vanzella
Gbzao!:
MacAddress
public String getMACAddress(String ip){
String str = "";
String macAddress = "";
try {
Process p = Runtime.getRuntime().exec("nbtstat -A " + ip);
InputStreamReader ir = new InputStreamReader(p.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
for (int i = 1; i < 100; i++) {
str = input.readLine();
if (str != null) {
if (str.indexOf("MAC Address") > 1) {
macAddress = str.substring(str.indexOf("MAC Address") + 14, str.length());
break;
}
}
}
} catch (IOException e) {
e.printStackTrace(System.out);
}
return macAddress;
}
ihhh, não sei não se funciona assim, talvés pra um rede interna, mas externa o buraco é mais em baixo…
bom, mas testa ai, e depois posta pra gente se funcionou…