10

I'm looking for a value that will be unique to each computer that is platform independent. This is for registering machines to an account, so that you cannot login from machines that are not registered. I don't want to use the MAC address since this can easily be changed. I was wondering maybe getting ids from several hardware components and combining them to get a unique id for the machine. However, I was unsure of how to obtain ids from said components, using Java. I did some research and found a way of retrieving the CPU serial number but this would only work for windows as it was just running a temporary visual basic command/script/whatever. Any information is appreciated, thanks.

user1009569
  • 477
  • 6
  • 22
  • 3
    Everything can be easily spoofed for a user-space application. Most commodity hardware doesn't even have unique ID flashed into some sort of read-only memory. –  Feb 06 '14 at 16:46
  • 2
    see the discussion here http://stackoverflow.com/questions/2004666/get-unique-machine-id – Leo Feb 06 '14 at 16:53
  • 1
    Thank you for the responses, I'm still unsure of how i can go about this. – user1009569 Feb 06 '14 at 20:04

1 Answers1

0

You are correct about being able to spoof a MAC address. There are no machineId's you can't spoof one way or another, which is why machine specific identification is generally a bad idea. It is an even worse idea with Java since the whole point of Java is to be abstracted from the hardware. Which really only leaves you with the JVM and network stack to get details from.

So the only two options I can see.

First you could try generating a hash of some combination of the hostname, current classpath(s), system properties, and JVM values. Along that line you might see what values you are getting from System.getenv() or System.getProperties()

The Second way would be to use native runtime API to return system specific values, but you would need to have specific commands to run for each OS type your client is trying to support. Example:

Runtime.getRuntime().exec("some_command_line_prog_that_returns_sys_info");

BrianC
  • 1,793
  • 1
  • 18
  • 26