Package com.adito.navigation.forms

Examples of com.adito.navigation.forms.ProfileSelectionForm


     */
    public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        // Get the property profile selected
        User user = getSessionInfo(request).getUser();
        ProfileSelectionForm profileSelectionForm = (ProfileSelectionForm) form;
        PropertyProfile profile = ProfilesFactory.getInstance().getPropertyProfile(
                        profileSelectionForm.getSelectedPropertyProfile());
        if (profile == null) {
            profile = ProfilesFactory.getInstance().getPropertyProfile(user.getPrincipalName(), "Default",
                            user.getRealm().getResourceId());
            if (profile == null) {
                throw new Exception("No default profile.");
            }
        }

        // Make the selected profile the one in use for this session
        if (log.isInfoEnabled())
          log.info("Switching user " + user.getPrincipalName() + " to profile " + profile.getResourceName());
        request.getSession().setAttribute(Constants.SELECTED_PROFILE, profile);
        String originalRequest = (String) request.getSession().getAttribute(Constants.ORIGINAL_REQUEST);

        // Optionally set the users default property profile
        if (profileSelectionForm.getMakeDefault()) {
            Property.setProperty(new UserAttributeKey(user, User.USER_STARTUP_PROFILE), String.valueOf(profile.getResourceId()), getSessionInfo(request));
        }

        // Reset the navigation and timeouts, they may be different in this new
        // profile
        CoreUtil.resetMainNavigation(request.getSession());
        LogonControllerFactory.getInstance().resetSessionTimeout(user, profile, request.getSession());

        // The new profile may have 'Automatically launch VPN client' enabled so
        // launch the VPN client
        if (!DefaultAgentManager.getInstance().hasActiveAgent(LogonControllerFactory.getInstance().getSessionInfo(request))
                        && Property.getPropertyBoolean(new ProfilePropertyKey(profile.getResourceId(), user.getPrincipalName(),
                                        "client.autoStart", user.getRealm().getResourceId()))) {
            request.getSession().removeAttribute(Constants.ORIGINAL_REQUEST);
            request.getSession().setAttribute(Constants.REQ_ATTR_LAUNCH_AGENT_REFERER, originalRequest);
            return mapping.findForward("launchAgent");
        }

        /*
         * Its possible the profile selection page is being displayed as the
         * result of the 'Select profile on logon' option. If so we will have
         * the original request URL that we should forward to, otherwise just
         * return to the referer.
         */
        else if (originalRequest != null) {
            request.getSession().removeAttribute(Constants.ORIGINAL_REQUEST);
            return new ActionForward(originalRequest, true);
        } else {
            if (profileSelectionForm.getReferer() != null) {
                ActionForward fwd = new ActionForward(profileSelectionForm.getReferer(), true);
                return fwd;
            } else {
                String referer = CoreUtil.getReferer(request);
                return referer == null ? mapping.findForward("home") : new ActionForward(referer, true);
            }
View Full Code Here


    /* (non-Javadoc)
     * @see com.adito.core.actions.AuthenticatedAction#onExecute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        ProfileSelectionForm profileSelectionForm = (ProfileSelectionForm) form;
        if (LogonControllerFactory.getInstance().hasClientLoggedOn(request, response) != LogonController.LOGGED_ON) {
            throw new Exception("You must be logged on to select a property.");
        }
        List propertyProfiles = null;
        int selectedPropertyProfile = 0;
        User user = LogonControllerFactory.getInstance().getUser(request);
        if (user != null) {
            propertyProfiles = (List)request.getSession().getAttribute(Constants.PROFILES);
            String selectedProfile = Property.getProperty(new UserAttributeKey(user, User.USER_STARTUP_PROFILE));
            if(selectedProfile.equals(ProfilesListDataSource.SELECT_ON_LOGIN)) {
              selectedPropertyProfile = 0;
            }
            else {
              try {
                selectedPropertyProfile = Integer.parseInt(selectedProfile);
              }
              catch(NumberFormatException nfe) {
                selectedPropertyProfile = 0;
              }
            }
        } else {
            throw new Exception("Not logged on.");
        }
        profileSelectionForm.setReferer(CoreUtil.getReferer(request));
        profileSelectionForm.setPropertyProfiles(propertyProfiles);
        profileSelectionForm.setSelectedPropertyProfile(selectedPropertyProfile);
        return mapping.findForward("success");
    }
View Full Code Here

TOP

Related Classes of com.adito.navigation.forms.ProfileSelectionForm

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.