File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes How do you uniquely identify a user of a midlet on a server? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "How do you uniquely identify a user of a midlet on a server?" Watch "How do you uniquely identify a user of a midlet on a server?" New topic
Author

How do you uniquely identify a user of a midlet on a server?

Ian Strain
Ranch Hand

Joined: Jun 30, 2004
Posts: 49
I've created a midlet that downloads an image to the users phones. I want to be able to identify the user so I can give him a new image every time he uses the midlet. Is there a way of identifing the user on the server or can I send a userID from the midlet to the server?


"its bad luck to be superstitious....."
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You could generate a unique identifier into the midlet's RMS space when the midlet is first run and then have the midlet send that identifier every time it connects to the server.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Ian Strain
Ranch Hand

Joined: Jun 30, 2004
Posts: 49
I could, but would it be unique? How could you create code that generates a completely unique id and not check it against other id's? Can you send a unique id from the server and then store it in the RMS? That way the servlet can generate a random number and check it against other ids.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
It depends on the ISPs, you can get an unique ID from the http header on the server for ATT, sprintPCS, ChinaMobile users, but not cingular, TMobile...
[ August 03, 2004: Message edited by: Roseanne Zhang ]
Ian Strain
Ranch Hand

Joined: Jun 30, 2004
Posts: 49
How about this: in the jad file have a user defined key of userID. When the user accesses the server to download the game, edit the jad file in a servlet to change the userID key to a unique number. Then when the user plays the game have the midlet access this key and use it to identify the user when downloading an image.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Good idea, and we have something similar to that. However, some sony-erricsson phone does not use a jad file...

What a chanllenging wireless world!
Ian Strain
Ranch Hand

Joined: Jun 30, 2004
Posts: 49
You said it!! Since I've started I could have built a mansion with all the walls that where thrown up in front of me.

So how do you access the user defined keys?
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Can you put the key in the JAR manifest file and generate the JAR file on the fly from the servlet? Scalability should not be a problem unless you have many people downloading it at the same time -- then you need to look at operator hosted solutions.


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Ian Strain
Ranch Hand

Joined: Jun 30, 2004
Posts: 49
I'm able to access the user defined key now.

Jad file:
MIDlet-Vendor: Unknown
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-1.0
userID: <change>

midlet
String userID = midlet.getAppProperty("userID");

I'm working on changing <change> to a unique ID now. Any ideas?
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Oh, to generate a unique key from the servlet is easy:

1. Make a string with random and unique information. For example, you can combine the current time and user name in the string.

2. Use any of the secure hash algorithm (e.g., SHA1) in the Java crypto API to generate a hash for that string.

The hash is your unique ID for this user, this download.
Ian Strain
Ranch Hand

Joined: Jun 30, 2004
Posts: 49
Yea thats the easy part!! But what about opening the .jad file so you can put in the unique id in the userID key
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Ian Strain:
I'm working on changing <change> to a unique ID now. Any ideas?
You could use a UUID generator like JUG or roll your own. You can get very reliable uniqueness by combining large enough pieces of the generating machine's IP address (MAC address is better if you have access to it), the generating machine's system time, a running counter, and perhaps a random number.

Then again, if you would happen to be using J2SE 1.5 (sorry, I meant Java 2 v5.0... :roll: ), you could use java.util.UUID.
Dave Butler
Greenhorn

Joined: Jul 19, 2004
Posts: 9
Use a servlet to write the JAD - then you can put whatever you like in the UID attribute

Best Regards

Dave
Ian Strain
Ranch Hand

Joined: Jun 30, 2004
Posts: 49
Done that. But hey guess what, sony ericsson phones don't download the jad files. Very nice of them! Got round it by creating a class on the server containing an unique id then adding it to the jar file.
 
 
subject: How do you uniquely identify a user of a midlet on a server?