protected boolean onLoginGUILogme() { try { showForm("FirstForm", null); String values[] = Splitter.Split(new String(record.getRecord(1)), "-"); showForm("FirstForm", null); if (values[0].equals(username.getText()) && values[1].equals(password.getText())) { showForm("FirstForm", null); } else { showForm("Htmlpasrecover", null); } values = null; } catch (Exception e) { System.out.println(e); } boolean val = super.onLoginGUILogme(); return val; }
protected boolean onPersonalinfoDone() { TextField t = (TextField) findByName("thispass", perosnl); TextField t2 = (TextField) findByName("nowpass", perosnl); TextField l = (TextField) findByName("path11", perosnl); int indecate = 0; Label l2 = (Label) findByName("Label32", perosnl); if (!t2.getText().equals("")) { if (t.getText().equals(password.getText())) { checkpass = t2.getText(); } else { l2.setText("error password miss match"); indecate = 1; } } if (l.getText() != null) { imgpath = l.getText(); } if (indecate == 0) { Myprofile.show(); // showForm("MyProfile", null); } boolean val = super.onPersonalinfoDone(); return val; }
private boolean authentication() throws SaveException, RecordStoreException { titleLbl.setText("Authenticating..."); String username = usernameTxt.getText().trim().toLowerCase(); String password = passwordTxt.getText().trim().toLowerCase(); // TODO crytped password + encoding HTTPWebAPI api = new HTTPWebAPI(); String apikey = api.getAPIKey(username, password); log.debug("API key: " + apikey); if (apikey.length() == 40) { titleLbl.setText("Saving API key..."); midlet.getPreferences().setAPIKey(apikey); midlet.getPreferences().setUsername(usernameTxt.getText().trim()); midlet.getPreferences().save(); titleLbl.setText("API key saved"); return true; } else { return false; } }
/** Similar to getText() but works properly with password fields */ private String getTextFieldString(TextField ta) { String text = (String) ta.getText(); String displayText = ""; if ((ta.getConstraint() & TextArea.PASSWORD) != 0) { // show the last character in a password field if (ta.isPendingCommit()) { if (text.length() > 0) { for (int j = 0; j < text.length() - 1; j++) { displayText += "*"; } displayText += text.charAt(text.length() - 1); } } else { for (int j = 0; j < text.length(); j++) { displayText += "*"; } } } else { displayText = text; } return displayText; }
protected boolean onMyProfileSaveAll() { String pass = null; byte arr[] = null; if (checkpass.equals("+")) { try { pass = new String(record.getRecord(1)); pass = Splitter.Split(pass, "-")[1]; } catch (Exception e) { } } else { pass = checkpass; } if (!imgpath.equals("+")) { try { record.setRecord(2, imgpath.getBytes(), 0, imgpath.getBytes().length); } catch (RecordStoreException ex) { ex.printStackTrace(); } } try { String userpass[] = Splitter.Split(new String(record.getRecord(1)), "-"); byte userpsss[] = (userpass[0] + "-" + pass).getBytes(); record.setRecord(1, userpsss, 0, userpsss.length); String record4 = name.getText() + "-" + index.getText() + "-" + tel.getText() + "-" + addr.getText() + "-" + email.getText() + "-" + group.getText(); byte reco4[] = record4.getBytes(); record.setRecord(4, reco4, 0, reco4.length); String id = (Splitter.Split(new String(record.getRecord(3)), "-")[1]); if (id.equals("0")) { HttpCon con2 = new HttpCon(record4 + "-" + pass, PropertyClass.ServerUrl + "addaUser"); con2.SetContype(true, true, true); Thread t = new Thread(con2); synchronized (t) { t.start(); t.wait(); } String[] newid = Splitter.Split((new String(record.getRecord(3))), "-"); userpsss = null; userpsss = (newid[0] + "-" + con2.getValue().toString() + "-" + newid[2]).getBytes(); record.setRecord(3, userpsss, 0, userpsss.length); } else { HttpCon con12 = new HttpCon(record4 + ("-" + pass + "-" + id), PropertyClass.ServerUrl + "UpdateUser"); con12.SetContype(true, true, true); Thread t = new Thread(con12); synchronized (t) { t.start(); t.wait(); } } } catch (Exception e) { System.out.println(e); } pass = null; arr = null; boolean val = super.onMyProfileSaveAll(); return val; }