Package org.apache.roller.ui.authoring.struts.formbeans

Examples of org.apache.roller.ui.authoring.struts.formbeans.UserFormEx


            ActionMapping       mapping,
            ActionForm          actionForm,
            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException {
        UserFormEx userForm = (UserFormEx)actionForm;
        userForm.setAdminCreated(true);
        return registerUser(mapping, actionForm, request, response);
    }
View Full Code Here


            throws IOException, ServletException {
        ActionForward forward = mapping.findForward("registerUser.page");
        ActionErrors errors = new ActionErrors();
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        try {
            UserFormEx userForm = (UserFormEx)actionForm;
           
            userForm.setLocale(Locale.getDefault().toString());
            userForm.setTimeZone(TimeZone.getDefault().getID());
            userForm.setDataFromSSO(false);
           
            // Let's see if there's any user-authentication available from Acegi
            // and retrieve custom user data to pre-populate form.
            boolean usingSSO = RollerConfig.getBooleanProperty("users.sso.enabled");
            if(usingSSO) {           
              UserData fromSSO = CustomUserRegistry.getUserDetailsFromAuthentication();
              if(fromSSO != null) {
                userForm.copyFrom(fromSSO, request.getLocale());
                userForm.setDataFromSSO(true);
              }
            }
           
            userForm.setPasswordText(null);
            userForm.setPasswordConfirm(null);
            request.setAttribute("model", new BasePageModel(
                    "newUser.addNewUser", request, response, mapping));
        } catch (Exception e) {
            errors.add(ActionErrors.GLOBAL_ERROR,
                    new ActionError("error.editing.user", e.toString()));
View Full Code Here

            ActionMapping       mapping,
            ActionForm          actionForm,
            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException {
        UserFormEx form = (UserFormEx)actionForm;
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        ServletContext ctx = rreq.getServletContext();
        RollerContext rollerContext = RollerContext.getRollerContext();
       
        boolean reg_allowed =
                RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");
       
        if ( !reg_allowed && !request.isUserInRole("admin")) {
            throw new ServletException("New users disabled!");
        }
       
        ActionMessages msgs = new ActionMessages();
        ActionMessages errors = validate(form, new ActionErrors());
        if (!errors.isEmpty()) {
            saveErrors(request, errors);
        } else try {
            // Add new user
            UserManager mgr = RollerFactory.getRoller().getUserManager();
           
            UserData ud = new UserData();
            form.copyTo(ud, request.getLocale()); // doesn't copy password
            ud.setId(null);
            ud.setDateCreated(new java.util.Date());
            ud.setEnabled(Boolean.TRUE);
           
            // If user set both password and passwordConfirm then reset password
            if (    !StringUtils.isEmpty(form.getPasswordText())
            && !StringUtils.isEmpty(form.getPasswordConfirm())) {
                ud.resetPassword(RollerFactory.getRoller(),
                        form.getPasswordText(), form.getPasswordConfirm());
            }
           
            // save new user
            mgr.addUser(ud);
            RollerFactory.getRoller().flush();
           
            if (form.getAdminCreated()) {
                // User created for admin, so return to new user page with empty form
                msgs.add(ActionMessages.GLOBAL_MESSAGE,
                        new ActionMessage("newUser.created"));
                saveMessages(request, msgs);
                form.reset(mapping, request);
                return createUser(mapping, actionForm, request, response);
            } else {
                // User registered, so go to welcome page
                request.setAttribute("contextURL",
                        RollerRuntimeConfig.getAbsoluteContextURL());
               
                // Invalidate session, otherwise new user who was originally authenticated
                // via LDAP/SSO will remain logged in with a but without a valid Roller role.
                request.getSession().invalidate();
               
                return mapping.findForward("welcome.page");
            }
                      
        } catch (RollerException e) {
            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(e.getMessage()));
            saveErrors(request,errors);
            mLogger.error("ERROR in addUser", e);
            form.setUserName("");
        }
       
        if (form.getAdminCreated()) {
            return mapping.findForward("createUser");
        } else {
            // Error occured, send user back to new user form
            return mapping.findForward("registerUser");
        }
View Full Code Here

            throws IOException, ServletException {
        ActionForward forward = mapping.findForward("yourProfile.page");
        try {
            RollerSession rollerSession = RollerSession.getRollerSession(request);
            UserData ud = rollerSession.getAuthenticatedUser();
            UserFormEx form = (UserFormEx)actionForm;
            form.copyFrom(ud, request.getLocale());
            form.setPasswordText(null);
            form.setPasswordConfirm(null);
            form.setLocale(ud.getLocale());
            form.setTimeZone(ud.getTimeZone());
            request.setAttribute("model", new BasePageModel(
                    "yourProfile.title", request, response, mapping));
        } catch (Exception e) {
            mLogger.error("ERROR in action",e);
            throw new ServletException(e);
View Full Code Here

            ActionMapping       mapping,
            ActionForm          actionForm,
            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException {
        UserFormEx form = (UserFormEx)actionForm;
        ActionForward forward = mapping.findForward("yourProfile.page");
        ActionMessages msgs = new ActionMessages();
        try {
            ActionMessages errors = validate(form, new ActionErrors());
            if (errors.size() == 0) {
                // We ONLY modify the user currently logged in
                RollerSession rollerSession = RollerSession.getRollerSession(request);
                UserData data = rollerSession.getAuthenticatedUser();
               
                // We want to be VERY selective about what data gets updated
                data.setFullName(form.getFullName());
                data.setEmailAddress(form.getEmailAddress());
                data.setLocale(form.getLocale());
                data.setTimeZone(form.getTimeZone());
               
                // If user set both password and passwordConfirm then reset password
                if (    !StringUtils.isEmpty(form.getPasswordText())
                && !StringUtils.isEmpty(form.getPasswordConfirm())) {
                    try {
                        data.resetPassword(RollerFactory.getRoller(),
                                form.getPasswordText(),
                                form.getPasswordConfirm());
                    } catch (RollerException e) {
                        msgs.add(ActionMessages.GLOBAL_MESSAGE,
                                new ActionMessage("yourProfile.passwordResetError"));
                    }
                }
View Full Code Here

            ActionMapping       mapping,
            ActionForm          actionForm,
            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException {
        UserFormEx userForm = (UserFormEx)actionForm;
        userForm.setAdminCreated(true);
        return registerUser(mapping, actionForm, request, response);
    }
View Full Code Here

            throws IOException, ServletException {
        ActionForward forward = mapping.findForward("registerUser.page");
        ActionErrors errors = new ActionErrors();
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        try {
            UserFormEx userForm = (UserFormEx)actionForm;
           
            userForm.setLocale(Locale.getDefault().toString());
            userForm.setTimeZone(TimeZone.getDefault().getID());
            userForm.setDataFromSSO(false);
           
            // Let's see if there's any user-authentication available from Acegi
            // and retrieve custom user data to pre-populate form.
            boolean usingSSO = RollerConfig.getBooleanProperty("users.sso.enabled");
            if(usingSSO) {           
              UserData fromSSO = CustomUserRegistry.getUserDetailsFromAuthentication();
              if(fromSSO != null) {
                userForm.copyFrom(fromSSO, request.getLocale());
                userForm.setDataFromSSO(true);
              }
            }
           
            userForm.setPasswordText(null);
            userForm.setPasswordConfirm(null);
            request.setAttribute("model", new BasePageModel(
                    "newUser.addNewUser", request, response, mapping));
        } catch (Exception e) {
            errors.add(ActionErrors.GLOBAL_ERROR,
                    new ActionError("error.editing.user", e.toString()));
View Full Code Here

            ActionMapping       mapping,
            ActionForm          actionForm,
            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException {
        UserFormEx form = (UserFormEx)actionForm;
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        ServletContext ctx = rreq.getServletContext();
        RollerContext rollerContext = RollerContext.getRollerContext();
       
        boolean reg_allowed =
                RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");
       
        if ( !reg_allowed && !request.isUserInRole("admin")) {
            throw new ServletException("New users disabled!");
        }
       
        ActionMessages msgs = new ActionMessages();
        ActionMessages errors = validate(form, new ActionErrors());
        if (!errors.isEmpty()) {
            saveErrors(request, errors);
        } else try {
            // Add new user
            UserManager mgr = RollerFactory.getRoller().getUserManager();
           
            UserData ud = new UserData();
            form.copyTo(ud, request.getLocale()); // doesn't copy password
            ud.setId(null);
            ud.setDateCreated(new java.util.Date());
            ud.setEnabled(Boolean.TRUE);
           
            // If user set both password and passwordConfirm then reset password
            if (    !StringUtils.isEmpty(form.getPasswordText())
            && !StringUtils.isEmpty(form.getPasswordConfirm())) {
                ud.resetPassword(RollerFactory.getRoller(),
                        form.getPasswordText(), form.getPasswordConfirm());
            }
           
            // save new user
            mgr.addUser(ud);
            RollerFactory.getRoller().flush();
           
            if (form.getAdminCreated()) {
                // User created for admin, so return to new user page with empty form
                msgs.add(ActionMessages.GLOBAL_MESSAGE,
                        new ActionMessage("newUser.created"));
                saveMessages(request, msgs);
                form.reset(mapping, request);
                return createUser(mapping, actionForm, request, response);
            } else {
                // User registered, so go to welcome page
                request.setAttribute("contextURL",
                        RollerRuntimeConfig.getAbsoluteContextURL());
                return mapping.findForward("welcome.page");
            }
        } catch (RollerException e) {
            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(e.getMessage()));
            saveErrors(request,errors);
            mLogger.error("ERROR in addUser", e);
            form.setUserName("");
        }
       
        if (form.getAdminCreated()) {
            return mapping.findForward("createUser");
        } else {
            // Error occured, send user back to new user form
            return mapping.findForward("registerUser");
        }
View Full Code Here

            throws IOException, ServletException {
        ActionForward forward = mapping.findForward("yourProfile.page");
        try {
            RollerSession rollerSession = RollerSession.getRollerSession(request);
            UserData ud = rollerSession.getAuthenticatedUser();
            UserFormEx form = (UserFormEx)actionForm;
            form.copyFrom(ud, request.getLocale());
            form.setPasswordText(null);
            form.setPasswordConfirm(null);
            form.setLocale(ud.getLocale());
            form.setTimeZone(ud.getTimeZone());
            request.setAttribute("model", new BasePageModel(
                    "yourProfile.title", request, response, mapping));
        } catch (Exception e) {
            mLogger.error("ERROR in action",e);
            throw new ServletException(e);
View Full Code Here

            ActionMapping       mapping,
            ActionForm          actionForm,
            HttpServletRequest  request,
            HttpServletResponse response)
            throws IOException, ServletException {
        UserFormEx form = (UserFormEx)actionForm;
        ActionForward forward = mapping.findForward("yourProfile.page");
        ActionMessages msgs = new ActionMessages();
        try {
            ActionMessages errors = validate(form, new ActionErrors());
            if (errors.size() == 0) {
                // We ONLY modify the user currently logged in
                RollerSession rollerSession = RollerSession.getRollerSession(request);
                UserData data = rollerSession.getAuthenticatedUser();
               
                // We want to be VERY selective about what data gets updated
                data.setFullName(form.getFullName());
                data.setEmailAddress(form.getEmailAddress());
                data.setLocale(form.getLocale());
                data.setTimeZone(form.getTimeZone());
               
                // If user set both password and passwordConfirm then reset password
                if (    !StringUtils.isEmpty(form.getPasswordText())
                && !StringUtils.isEmpty(form.getPasswordConfirm())) {
                    try {
                        data.resetPassword(RollerFactory.getRoller(),
                                form.getPasswordText(),
                                form.getPasswordConfirm());
                    } catch (RollerException e) {
                        msgs.add(ActionMessages.GLOBAL_MESSAGE,
                                new ActionMessage("yourProfile.passwordResetError"));
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.roller.ui.authoring.struts.formbeans.UserFormEx

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.