Java Reference
In-Depth Information
L ISTING 5.4 Continued
private MIDlet midlet;
private String licenseId = “”;
private String passwd = “”;
private Form form;
private TextField idTextField;
private TextField pwdTextField;
private final static String SERVER_URL = “http://localhost:8080/license/
midp?license-id=”;
private boolean successfullyRegistered = false;
private Displayable returnDisplayable;
/**
*
*/
public MIDLicenseManager(MIDlet m) {
midlet = m;
// Create a new record store for keys for this midlet suite
try {
keyStore = RecordStore.openRecordStore(“keys”, true);
int items = keyStore.getNumRecords();
System.out.println(“items=”+items);
if (items > 0) {
String roughLicenseId = new String(keyStore.getRecord(1));
if (roughLicenseId!=null)
licenseId = unscramble(roughLicenseId);
String roughPasswd = new String(keyStore.getRecord(2));
if (roughPasswd!=null)
passwd = unscramble(roughPasswd);
} else {
// the recordstore has to be initialized
String n = “”;
keyStore.addRecord(n.getBytes(), 0, n.getBytes().length);
keyStore.addRecord(n.getBytes(), 0, n.getBytes().length);
}
} catch (RecordStoreException rse) {
System.out.println(“MIDLicenseManager() “+rse);
}
}
5
/**
*
*/
public boolean isLicensed() {
return (licenseId != “”);
}
Search WWH ::




Custom Search