public void pageBeginRender(PageEvent event) { User user = getUser(); if (user == null) { user = getCoreContext().newUser(); user.setSipPassword(RandomStringUtils.randomAlphanumeric(SIP_PASSWORD_LEN)); user.setVoicemailPin(RandomStringUtils.random(VOICEMAIL_PIN_LEN, false, true)); user.setPin(RandomStringUtils.randomAlphabetic(PASSWORD_LEN)); setUser(user); UserForm.initializePin(getComponent(USER_FORM).getComponent("pin"), this, user); UserForm.initializeVoicemailPin( getComponent(USER_FORM).getComponent("voicemail_pin"), this, user); } }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the // page from the origin server // response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under // any circumstance // response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale" // response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility /* if (this.userIsLoggedIn(request)) { //ActionMessages errors_mesg = new ActionMessages(); //errors_mesg.add("submitError", new ActionMessage("errors.login.sessionended")); //this.saveErrors(request, errors_mesg); //return mapping.findForward("sessionEnded"); } */ // request.getSession().invalidate(); boolean action_perform = false; String action_target; UserLogin u = new UserLogin(); ActionMessages errors_mesg = new ActionMessages(); UserForm uf = (UserForm) form; if (form != null) { u.setUsername(uf.getUsername()); u.setPassword(uf.getPassword()); action_perform = u.doLogin(); } if (action_perform == false) { errors_mesg.add("submitError", new ActionMessage("errors.login.fail")); saveErrors(request, errors_mesg); action_target = "failure"; } else { System.out.println("userDetails :: " + uf); request.getSession().setAttribute("userDetails", uf); HttpSession session = request.getSession(); session.setAttribute("logined", "true"); session.setAttribute("context", new java.util.Date()); action_target = "success"; } return mapping.findForward(action_target); }
private void saveSettings() throws InvalidAttributeValueException { if (userForm.getNickname().isEmpty()) throw new InvalidAttributeValueException("Přezdívka musí být vyplněna"); else if (userForm.getUsername().isEmpty()) throw new InvalidAttributeValueException("Uživatelské jméno musí být vyplněno"); settings.setUserProperty("nickname", userForm.getNickname()); settings.setUserProperty("altnickname", userForm.getAltNickname()); settings.setUserProperty("username", userForm.getUsername()); settings.setUserProperty("realname", userForm.getRealname()); settings.setUserProperty("email", userForm.getEmail()); settings.setEventEnabled("log-chat", eventsForm.isLogChatChecked()); settings.setEventEnabled("rejoin-after-kick", eventsForm.isRejoinChecked()); settings.setEventEnabled("clickable-links", eventsForm.isClickableLinksChecked()); settings.setEventEnabled("ask-for-quit", eventsForm.isAskForQuitChecked()); settings.setViewEnabled("display-topic", viewForm.isDisplayTopicChecked()); settings.setViewEnabled("timestamp-enabled", viewForm.isTimestampEnabled()); settings.setViewTimestampFormat(viewForm.getTimestampFormat()); settings.setBlockedNicknames(blockedForm.getBlockedNicknames()); settings.store(); }
private void reloadSettings() { userForm.setNickname(settings.getUserProperty("nickname")); userForm.setAltNickname(settings.getUserProperty("altnickname")); userForm.setUsername(settings.getUserProperty("username")); userForm.setRealname(settings.getUserProperty("realname")); userForm.setEmail(settings.getUserProperty("email")); eventsForm.setLogChatChecked(settings.isEventEnabled("log-chat")); eventsForm.setRejoinChecked(settings.isEventEnabled("rejoin-after-kick")); eventsForm.setClickableLinksChecked(settings.isEventEnabled("clickable-links")); eventsForm.setAskForQuitChecked(settings.isEventEnabled("ask-for-quit")); viewForm.setDisplayTopicChecked(settings.isViewEnabled("display-topic")); viewForm.setTimestampEnabled(settings.isViewEnabled("timestamp-enabled")); viewForm.setTimestampFormat(settings.getViewTimestampFormat()); blockedForm.setBlockedNicknames(settings.getBlockedNicknames()); }
/** * This is the action called from the Struts framework. * * @param mapping The ActionMapping used to select this instance. * @param form The optional ActionForm bean for this request. * @param request The HTTP Request we are processing. * @param response The HTTP Response we are processing. * @throws java.lang.Exception * @return */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserForm registerationForm = (UserForm) form; ActionMessages errors = new ActionMessages(); String username = registerationForm.getUsername(); String password = registerationForm.getPassword(); String confirmPasswod = registerationForm.getConfirmPassword(); String email = registerationForm.getEmail(); if (!password.equals(confirmPasswod)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.password.mismatch")); saveErrors(request, errors); return mapping.getInputForward(); } UserManager mgr = new DummyUserManagerImpl(); User user = new User(); user.setEmail(email); user.setUsername(username); user.setPassword(password); try { mgr.registerUser(user); } catch (Exception e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.register.failed")); saveErrors(request, errors); return mapping.getInputForward(); } request.setAttribute("username", username); request.setAttribute("password", password); return mapping.findForward(SUCCESS); }
private void assertUserId(String userId, boolean expected) { String email = "*****@*****.**"; UserForm form = new UserForm(userId, email); assertThat(form.isValid(), is(expected)); }