web applications - How to get uuid or mac address from client in Java? -



web applications - How to get uuid or mac address from client in Java? -

i'm looking solution java based webapplication uniquely identify client. server in same network clients , thought using mac address solution. problem can't work cookies because can deleted client-side , can't utilize ip because issue new dhcp lease renewal.

so fallback mac address of clients. i'm aware there no java built in feature mac address. there library can handle output of every os? (primary windows , mac) since java application runs on both platforms.

or there other suggestions uniquely identifying client within website , http protocol ? (maybe html5 info stores or else)

i'm using java 1.7 btw.

i won't forcefulness user login or otherwise identify himself , won't programme native app clients smartphone.

i wrote own method solve issue. here if ever needs code find mac address in same network. works me without admin privileges on win 7 , mac os x 10.8.2

pattern macpt = null; private string getmac(string ip) { // find os , set command according os string os = system.getproperty("os.name").tolowercase(); string[] cmd; if (os.contains("win")) { // windows macpt = pattern .compile("[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+"); string[] = { "arp", "-a", ip }; cmd = a; } else { // mac os x, linux macpt = pattern .compile("[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+"); string[] = { "arp", ip }; cmd = a; } seek { // run command process p = runtime.getruntime().exec(cmd); p.waitfor(); // read output bufferedreader bufferedreader reader = new bufferedreader(new inputstreamreader( p.getinputstream())); string line = reader.readline(); // loop trough lines while (line != null) { matcher m = macpt.matcher(line); // when matcher finds line homecoming result if (m.find()) { system.out.println("found"); system.out.println("mac: " + m.group(0)); homecoming m.group(0); } line = reader.readline(); } } grab (ioexception e1) { e1.printstacktrace(); } grab (interruptedexception e) { e.printstacktrace(); } // homecoming empty string if no mac found homecoming ""; }

java web-applications uuid mac-address

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -