Java Reference
In-Depth Information
L ISTING 5.4 Continued
keyStore.closeRecordStore();
} catch (RecordStoreException rse) {
System.out.println(“MIDLicenseManager-save() “+rse);
}
}
/**
* create an URL
*/
private String createURL(){
return SERVER_URL + scramble(licenseId) + “&license-pwd=”
+ scramble(passwd);
}
}
In the constructor (beginning at line 31), the repository where the (encrypted) license data is
stored is retrieved from the device's persistent memory. In case it is not yet present, it is cre-
ated from scratch.
T IP
For development purposes, MIDlet emulators have a command for clearing up the
persistent memory. You can use it to test out this example more than one time.
The registration procedure begins with the register method (lines 80-103), which prompts
the user for the license data. Users would obtain these codes after purchasing the software
license from a Web site, by a sales representative, and so on. After filling in the form, when
the user activates the “ok” command, the commandAction method at line 140 is invoked. A
progress bar is shown to the user while trying to connect with the server. The connection is
handled by the connect method at lines 108-135. Then, accordingly with the connection
results, the persistent data are updated (at line 160), and proper explanatory messages are
shown to the user.
5
By means of the isLicensed method at lines 58-60, the client MIDlet can query the
MIDLicenseManager instance, and can dynamically enable more features available only to reg-
istered copies.
Search WWH ::




Custom Search