final Map<String, Object> attributeMap = (Map<String, Object>) sessao.getAttribute("ORIGINAL_ATTRIBUTE_MAP"); for (final Entry<String, Object> entry : attributeMap.entrySet()) { request.setAttribute(entry.getKey(), entry.getValue()); }
attributeMap = (Map<String, Object>) sessao.getAttribute("ORIGINAL_ATTRIBUTE_MAP"); parameterMap = (Map<String, Object>) sessao.getAttribute("ORIGINAL_PARAMETER_MAP");      actionForward.setPath(module + "/redirect.do");
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,            HttpServletResponse response) throws Exception {        IUserView userView = null;        ActionForward forwardToReturn;        try {            DynaActionForm authenticationForm = (DynaActionForm) form;            ActionMappingForAuthentication authenticationMapping = (ActionMappingForAuthentication) mapping;			final String username = (String) authenticationForm.get("username");			final String password = (String) authenticationForm.get("password");			final String application = authenticationMapping.getApplication();			final String requestURL = request.getRequestURL().toString();            Object argsAutenticacao[] = { username, password, application, requestURL };            userView = (IUserView) ServiceManagerServiceFactory.executeService(null, "Autenticacao",                    argsAutenticacao);        } catch (ExcepcaoAutenticacao e) {            ActionErrors actionErrors = new ActionErrors();            actionErrors.add("invalidAuthentication", new ActionError("errors.invalidAuthentication"));            saveErrors(request, actionErrors);            return mapping.getInputForward();        }                if (userView.getRoles().isEmpty()) {            ActionErrors actionErrors = new ActionErrors();            actionErrors.add("errors.noAuthorization", new ActionError("errors.noAuthorization"));            saveErrors(request, actionErrors);            return mapping.getInputForward();        }        // Invalidate existing session if it exists        HttpSession sessao = request.getSession(false);        HttpServletRequest originalRequest = null;        ActionForward actionForward = null;        if (sessao != null) {        	originalRequest = (HttpServletRequest) sessao.getAttribute("ORIGINAL_REQUEST");        	System.out.println("ORIGINAL_REQUEST" + originalRequest);        	if (originalRequest != null) {        		System.out.println("ORIGINAL_REQUEST uri: " + originalRequest.getRequestURI());                actionForward = new ActionForward();                actionForward.setContextRelative(false);                actionForward.setRedirect(false);            	System.out.println("Original URI reconstruction: " + sessao.getAttribute("ORIGINAL_URI"));            	final String originalURI = (String) sessao.getAttribute("ORIGINAL_URI");            	actionForward.setPath(originalURI.substring(APP_CONTEXT_LENGTH));            	// Set request attributes            	final Map<String, Object> attributeMap = (Map<String, Object>) sessao.getAttribute("ORIGINAL_ATTRIBUTE_MAP");            	for (final Entry<String, Object> entry : attributeMap.entrySet()) {            		request.setAttribute(entry.getKey(), entry.getValue());            	}        	}            sessao.invalidate();        }        // Create a new session for this user        sessao = request.getSession(true);        // Store the UserView into the session and return        sessao.setAttribute(SessionConstants.U_VIEW, userView);        sessao.setAttribute(SessionConstants.SESSION_IS_VALID, new Boolean(true));        if (originalRequest != null) {            return actionForward;        }        Collection userRoles = userView.getRoles();        int numberOfSubApplications = getNumberOfSubApplications(userRoles);        forwardToReturn = mapping.findForward("sucess");        Iterator iterator = userRoles.iterator();        InfoRole firstInfoRole = null;        while (iterator.hasNext()) {            firstInfoRole = (InfoRole) iterator.next();            break;        }        InfoRole firstTimeStudentInfoRole = new InfoRole();        firstTimeStudentInfoRole.setRoleType(RoleType.FIRST_TIME_STUDENT);        if (userRoles.contains(firstTimeStudentInfoRole)) {            //ActionErrors actionErrors = new ActionErrors();            //actionErrors.add("invalidAuthentication", new            // ActionError("errors.invalidAuthentication"));            //saveErrors(request, actionErrors);            //return mapping.getInputForward();            //TODO impose a period time limit            InfoRole infoRole = getRole(RoleType.FIRST_TIME_STUDENT, userRoles);            forwardToReturn = buildRoleForward(infoRole);        } else {            InfoRole personInfoRole = new InfoRole();            personInfoRole.setRoleType(RoleType.PERSON);            if (numberOfSubApplications == 1 || !userRoles.contains(personInfoRole)) {                forwardToReturn = buildRoleForward(firstInfoRole);            }        }        return forwardToReturn;    }