Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ian Strain
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ian Strain
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ian Strain
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic