• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 866
  • Last Modified:

get machine id?

Hi, I need a way to make sure that only clients on some particular PC have access to certain resources reside at the server. Is there a way to identify the machine id of each PC, so that i can control PC01 have access and PC02 doesn't?

Tks
0
InNoCenT_Ch1ld
Asked:
InNoCenT_Ch1ld
  • 7
  • 5
  • 2
  • +1
3 Solutions
 
InNoCenT_Ch1ldAuthor Commented:
Or if there's a better way to do so, plz let me know.
0
 
objectsCommented:
you could use the mac address

http://mindprod.com/jgloss/mac.html
0
 
gksinghietCommented:
If you are using servlets, you can use getRemoteAddr() and getRemoteHost() of ServletRequest to retrieve the IP address and hostname of the client machine, respectively:
public String ServletRequest.getRemoteAddr()
public String ServletRequest.getRemoteHost()
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
InNoCenT_Ch1ldAuthor Commented:
mac address might be the one i wanted, but the example shows only in c/c++..

gksinghiet, i'm not familiar with network, but my IT staff says that the ip address can be easily change..
0
 
objectsCommented:
> mac address might be the one i wanted, but the example shows only in c/c++..

yes you'll need native code to get it requiring JNI or Runtime.exec()

Implementation here:
http://jug.safehaus.org/
0
 
InNoCenT_Ch1ldAuthor Commented:
objects, sorry, i miss the example at the first page... i click on the link toooooo quick
0
 
CEHJCommented:
You could use the HD serial number in a signed applet:


import java.io.*;

/**
 *      Gets the HD serial number
 *
 * @author             CEHJ
 * @created            25 March 2004
 */
public class VolumeSerialNumberGetter {
      StringBuffer collector;


      public static void main(String[] args) {
            new VolumeSerialNumberGetter().run(args);
      }


      public void run(String[] args) {

            try {

                  if (args.length < 1) {
                        //System.out.println("Usage: java CommandRunner <command string>");
                        args = new String[] { "cmd.exe",      "/c",      "dir", "|",      "find", "/i",      "Serial Number is" };
                  }
                  Process pro = Runtime.getRuntime().exec(args);
                  InputStream error = pro.getErrorStream();
                  InputStream output = pro.getInputStream();

                  collector = new StringBuffer();
                  ProcessStreamReader collectingReader = new ProcessStreamReader(output);
                  Thread out = new Thread(collectingReader);
                  out.start();
                  out.join();
                  String volumeNumber = collector.toString();
                  volumeNumber = volumeNumber.substring(volumeNumber.lastIndexOf(' '));
                  System.out.println(volumeNumber.trim());
            }
            catch (java.io.IOException e) {
                  e.printStackTrace();
            }
            catch (java.lang.InterruptedException e) {
                  e.printStackTrace();
            }

      }

      class ProcessStreamReader implements Runnable {

            InputStream is;

            public ProcessStreamReader(InputStream is) {
                  this.is = is;
            }

            public void run() {
                  try {
                        BufferedReader in = new BufferedReader(new InputStreamReader(is));
                        String temp = null;
                        while ((temp = in.readLine()) != null) {
                              collector.append(temp);
                        }
                        is.close();
                  }
                  catch (Exception e) {
                        e.printStackTrace();
                  }
            }
      }

}


0
 
InNoCenT_Ch1ldAuthor Commented:
i'll leave this question open for a while before i close. tks
0
 
InNoCenT_Ch1ldAuthor Commented:
CEHJ, i'm actually developing a simple application for data processing, and not applet...
0
 
CEHJCommented:
Is it servlet/web based?
0
 
InNoCenT_Ch1ldAuthor Commented:
>>Is it servlet/web based?

I was thinking to develop it as client-server application (not servlet/web) for internal use..
but there's a possibilities that i need to do it as servlet/jsp... haven't decide, but definitely no applet..

i just want to know how before i do it.
0
 
CEHJCommented:
>>I was thinking to develop it as client-server application

Well that's even easier then. You can use the code as is
0
 
InNoCenT_Ch1ldAuthor Commented:
but is this HD serial number unique? and do you mind telling me what it is actually?

tks in advanced ;-)
0
 
CEHJCommented:
>>but is this HD serial number unique?

Let's put it this way: its probability of being unique is higher than the IP address

>>and do you mind telling me what it is actually?

The serial number of the hard drive
0
 
CEHJCommented:
:-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 7
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now