@RequestMapping(value = "/login", method = RequestMethod.POST) public ModelAndView login( HttpSession session, ModelAndView mav, @RequestParam("uid") UserIdentifier uid, @RequestParam("password") String pw) { Member user = GmbPersistenceManager.get(uid); if (uid.toString() == "") { mav.addObject("failureText", "Bitte geben Sie ihren Nutzernamen ein !"); mav.addObject("uidInput", uid.toString()); mav.setViewName("index"); return mav; } if (user != null) { if (pw == "") { mav.addObject("failureText", "Bitte geben Sie ein Passwort ein !"); mav.addObject("uidInput", uid.toString()); mav.setViewName("index"); return mav; } if (user.verifyPassword(pw)) { GmbPersistenceManager.login(user, session); Capability adminCAP = new Capability("admin"); Capability employeeCAP = new Capability("employee"); Capability customerCAP = new Capability("customer"); if (user.hasCapability(adminCAP)) { mav.setViewName("employee/employee"); } else if (user.hasCapability(employeeCAP)) { mav.setViewName("employee/employee"); } else if (user.hasCapability(customerCAP)) { mav.setViewName("customer/customer"); } else { mav.setViewName("notary/notary"); int latest = Lottery.getInstance().getTipManagement().getWeeklyLottoDrawings().size() - 1; mav.addObject( "draw", Lottery.getInstance().getTipManagement().getWeeklyLottoDrawings().get(latest)); mav.addObject("time", Lottery.getInstance().getTimer().getDateTime()); } mav.addObject("currentUser", user); return mav; } else { mav.setViewName("index"); mav.addObject("failureText", "Das eingegebene Passwort ist falsch !"); mav.addObject("uidInput", user.getIdentifier().toString()); return mav; } } mav.setViewName("index"); return mav; }
public static UserIdentifier decodeUTF8String(UserIdentifier encoded) throws UnsupportedEncodingException { bytes = encoded.toString().getBytes(); String uid = new String(bytes, "UTF-8"); return new UserIdentifier(uid); }
@RequestMapping(value = "/createUser", method = RequestMethod.POST) public ModelAndView createUser( ModelAndView mav, @RequestParam("vname") String vname, @RequestParam("nname") String nname, @RequestParam("uid") UserIdentifier uid, @RequestParam("password") String password, @RequestParam("email") String email, @RequestParam("street") String street, @RequestParam("hNumber") String hNumber, @RequestParam("plz") String plz, @RequestParam("city") String city, @RequestParam("accountNumber") String accountNumber, @RequestParam("bankCode") String bankCode, @RequestParam("age") String age) { if (age.equals(new String("false"))) { mav.setViewName("register"); mav.addObject("vorname", vname); mav.addObject("nachname", nname); mav.addObject("password", password); mav.addObject("uid", uid); mav.addObject("email", email); mav.addObject("street", street); mav.addObject("hNumber", hNumber); mav.addObject("plz", plz); mav.addObject("city", city); mav.addObject("accountNumber", accountNumber); mav.addObject("bankCode", bankCode); mav.addObject("fail", "- Fehler"); mav.addObject( "comment", new String( "Sie müssen mindestens 18 Jahre alt sein um an Gewinnspielen teilnehmen zu können!")); return mav; } // Username schon vorhanden if (GmbPersistenceManager.get(uid) != null) { mav.setViewName("register"); mav.addObject("vorname", vname); mav.addObject("nachname", nname); mav.addObject("password", password); mav.addObject("uid", ""); mav.addObject("email", email); mav.addObject("street", street); mav.addObject("hNumber", hNumber); mav.addObject("plz", plz); mav.addObject("city", city); mav.addObject("accountNumber", accountNumber); mav.addObject("bankCode", bankCode); mav.addObject("uidFail", "fail"); mav.addObject("fail", "- Fehler"); mav.addObject("comment", new String("Die UID wird schon verwendet !")); } else if (this.testeEingabeFehler( vname, nname, uid.getIdentifier(), password, email, street, hNumber, plz, city, accountNumber, bankCode)) { mav.setViewName("register"); mav.addObject("vorname", vname); mav.addObject("nachname", nname); mav.addObject("password", password); mav.addObject("uid", uid.toString()); mav.addObject("email", email); mav.addObject("street", street); mav.addObject("hNumber", hNumber); mav.addObject("plz", plz); mav.addObject("city", city); mav.addObject("accountNumber", accountNumber); mav.addObject("bankCode", bankCode); mav.addObject("fail", "- Fehler"); mav.addObject("comment", new String("Alle Felder fuellen !!!")); } else { Adress adress = GmbFactory.new_Adress(street, hNumber, plz, city); MemberData memberData = GmbFactory.new_MemberData( vname, nname, new DateTime(1970, 10, 16, 0, 0), "0735643", email, adress); RealAccountData rad = GmbFactory.new_RealAccountData(bankCode, accountNumber); LotteryBankAccount lba = GmbFactory.new_LotteryBankAccount(rad); Customer user = new Customer(uid.toString(), password, memberData, lba); Lottery.getInstance().getMemberManagement().addMember(user); lba.setOwner(user); user.getBankAccount().setCredit(new CDecimal(5000)); user.activateAccount(); mav.setViewName("redirect:/"); } return mav; }