Java Code Examples for org.apache.struts.action.ActionForward#setPath()

The following examples show how to use org.apache.struts.action.ActionForward#setPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserLocalePrefAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private ActionForward save(ActionMapping mapping, RequestContext ctx,
            User currentUser, DynaActionForm form) {
    String preferredLocale = form.getString("preferredLocale");
    if (preferredLocale != null && preferredLocale.equals("none")) {
        preferredLocale = null;
    }
    currentUser.setTimeZone(UserManager.getTimeZone(
            ((Integer) form.get("timezone")).intValue()));
    currentUser.setPreferredLocale(preferredLocale);
    UserManager.storeUser(currentUser);
    ActionMessages msgs = new ActionMessages();
    msgs.add(ActionMessages.GLOBAL_MESSAGE,
            new ActionMessage("message.preferencesModified"));
    getStrutsDelegate().saveMessages(ctx.getRequest(), msgs);
    if (ctx.getRequest().getParameter("uid") != null) {
        ActionForward display = mapping.findForward("display");
        ActionForward fwd = new ActionForward();
        fwd.setPath(display.getPath() + "?uid=" + currentUser.getId());
        fwd.setRedirect(true);
        return fwd;
    }
    return mapping.findForward("display");
}
 
Example 2
Source File: ThesisLibraryDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected ActionForward forward(ActionMapping mapping, HttpServletRequest request, String name, String parameter) {
    ActionForward existing = mapping.findForward(name);
    ActionForward result = new FenixActionForward(request, existing);

    if (parameter != null) {
        String[] values = request.getParameterValues(parameter);

        if (values == null) {
            return result;
        }

        StringBuilder path = new StringBuilder(existing.getPath());
        for (String value : values) {
            path.append(String.format("&%s=%s", parameter, value));
        }

        result.setPath(path.toString());
    }

    return result;
}
 
Example 3
Source File: NotAllowedActionExceptionHandler.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ActionForward execute(Exception ex, 
           ExceptionConfig exConfig,
           ActionMapping mapping,
           ActionForm formInstance,
           HttpServletRequest request,
           HttpServletResponse response
	) throws ServletException {

       ActionForward actionForward = new ActionForward();
       actionForward.setPath(exConfig.getPath());
       actionForward.setRedirect(true);
       return actionForward;
}
 
Example 4
Source File: IdentityManagementDocumentActionBase.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@Override
public ActionForward performLookup(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response)
		throws Exception {
	ActionForward forward =  super.performLookup(mapping, form, request, response);
	String path = forward.getPath();
	//Making the hack look cleaner!
	forward.setPath(KimCommonUtilsInternal.getPathWithKimContext(path, getActionName()));
	return forward;
}
 
Example 5
Source File: FenixDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ActionForward forwardForDestination(ViewDestination destination) {
    ActionForward forward = new ActionForward();
    forward.setModule(destination.getModule());
    forward.setPath(destination.getPath());
    forward.setRedirect(destination.getRedirect());
    return forward;
}
 
Example 6
Source File: EditMissingCandidacyInformationDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

        final PersonalInformationBean personalInformationBean = getRenderedObject("personalInformationBean");

        final Set<String> messages = personalInformationBean.validate();

        if (!messages.isEmpty()) {
            for (final String each : messages) {
                addActionMessage(request, each);
            }
            return prepareEditInvalid(mapping, form, request, response);
        }

        try {
            personalInformationBean.updatePersonalInformation(true);
        } catch (DomainException e) {
            addActionMessage(request, e.getKey(), e.getArgs());
            return prepareEditInvalid(mapping, form, request, response);
        }

        if (personalInformationBean.getStudent().hasAnyMissingPersonalInformation()) {
            RenderUtils.invalidateViewState();
            return prepareEdit(mapping, form, request, response);
        }

        final ActionForward forward = new ActionForward();
        forward.setPath("/home.do");
        forward.setRedirect(true);
        forward.setModule("/");

        return forward;

    }
 
Example 7
Source File: ViewStudentCurriculumDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ActionForward getOldCurriculumRedirect(final ActionForm actionForm, final Student student) {
    final ActionForward actionForward = new ActionForward();
    actionForward.setPath("/viewStudentCurriculum.do?method=prepareReadByStudentNumber&studentNumber=" + student.getNumber()
            + "&executionDegreeId=" + getExecutionDegreeId(actionForm) + "&degreeCurricularPlanID="
            + getDegreeCurricularPlanId(actionForm));
    return actionForward;
}
 
Example 8
Source File: RefactoredIndividualCandidacyProcessPublicDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ActionForward forward(HttpServletRequest request, String windowLocation) {
    final ActionForward actionForward = new ActionForward();
    actionForward.setName(windowLocation);
    actionForward.setPath(windowLocation);
    actionForward.setRedirect(true);
    return actionForward;
}
 
Example 9
Source File: ActionBase.java    From iaf with Apache License 2.0 5 votes vote down vote up
/**
 * Sets under the session an attribute named forward with an ActionForward to the current
 * request.
 */
public ActionForward setDefaultActionForward(HttpServletRequest request) {
    HttpSession session = request.getSession();
    // store the request uri with query parameters in an actionforward
    String reqUri=getFullRequestUri(request);
    ActionForward forward = new ActionForward();

    forward.setPath(reqUri);
    log.info("default forward set to :" + reqUri);
    session.setAttribute("forward", forward);
    return forward;
}
 
Example 10
Source File: IdentityManagementDocumentActionBase.java    From rice with Educational Community License v2.0 4 votes vote down vote up
protected ActionForward getBasePathForward(HttpServletRequest request, ActionForward forward){
ActionForward newDest = new ActionForward();
      KimCommonUtilsInternal.copyProperties(newDest, forward);
      newDest.setPath(getApplicationBaseUrl());
      return newDest;
  }
 
Example 11
Source File: StudentEnrolmentsDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ActionForward editEnrolment(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
                                          final HttpServletResponse response) {

    final EditEnrolmentBean enrolmentBean = getRenderedObject();
    final Enrolment enrolment = enrolmentBean.getEnrolment();

    final Double newWeight = enrolmentBean.getWeight();
    final EctsConversionTable newEctsConversionTable = enrolmentBean.getEctsConversionTable();
    final Grade newNormalizedGrade = enrolmentBean.getNormalizedGrade();

    Double oldWeight = enrolment.getWeigth();

    RenderUtils.invalidateViewState();
    
    FenixFramework.atomic(() -> {
        if (newEctsConversionTable instanceof EmptyConversionTable) {
            if (newNormalizedGrade.isEmpty()) {
                // use default table
                enrolment.setEctsConversionTable(null);
                enrolment.setEctsGrade(null);
            } else {
                enrolment.setEctsGrade(newNormalizedGrade);
                enrolment.setEctsConversionTable(newEctsConversionTable);
            }
        } else {
            // default to the selected table
            enrolment.setEctsGrade(null);
            enrolment.setEctsConversionTable(newEctsConversionTable);
        }

        enrolment.setWeigth(newWeight);
    });

    LOGGER.info("Changed enrolment {} of student {} by user {}", enrolmentBean.getEnrolment().getExternalId(),
                enrolmentBean.getEnrolment().getStudent().getPerson().getUsername(), Authenticate.getUser().getUsername());
    LOGGER.info("\t newEctsConversionTable: {}", newEctsConversionTable == null ? "-" : newEctsConversionTable
                                                                                            .getPresentationName().getContent());
    LOGGER.info("\t newEctsGrade: {}", newNormalizedGrade == null ? "-" : newNormalizedGrade.getValue());
    if (!oldWeight.equals(newWeight)) {
        LOGGER.info("\t oldWeight: {} newWeight: {}", oldWeight.toString(), newWeight.toString());
    }


    final UriBuilder builder = UriBuilder.fromPath("/academicAdministration/studentEnrolments.do");
    builder.queryParam("method", "prepare");
    final String scpID = request.getParameter("scpID");
    final String executionPeriodId = request.getParameter("executionPeriodId");

    if (!Strings.isNullOrEmpty(scpID)) {
        builder.queryParam("scpID", scpID);
    }

    if (!Strings.isNullOrEmpty(executionPeriodId)) {
        builder.queryParam("executionPeriodId", executionPeriodId);
    }

    final String redirectTo = GenericChecksumRewriter.injectChecksumInUrl(request.getContextPath(), builder.toString(), request.getSession(false));
    
    final ActionForward actionForward = new ActionForward();
    actionForward.setModule("/");
    actionForward.setPath(redirectTo);
    actionForward.setRedirect(true);

    return actionForward;
}
 
Example 12
Source File: FileDisclosure.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 3 votes vote down vote up
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{
    try{
        String returnURL = request.getParameter("returnURL");
        
        /******Struts ActionForward vulnerable code tests******/
        ActionForward forward = new ActionForward(returnURL); //BAD

        ActionForward forward2 = new ActionForward(returnURL, true); //BAD

        ActionForward forward3 = new ActionForward("name", returnURL, true); //BAD

        ActionForward forward4 = new ActionForward("name", returnURL, true, true); //BAD

        ActionForward forward5 = new ActionForward();
        forward5.setPath(returnURL); //BAD

        //false positive test - returnURL moved from path to name (safe argument)
        ActionForward forward6 = new ActionForward(returnURL, "path", true); //OK
        
        /******Spring ModelAndView vulnerable code tests******/
        ModelAndView mv = new ModelAndView(returnURL); //BAD
                   
        ModelAndView mv2 = new ModelAndView(returnURL, new HashMap()); //BAD

        ModelAndView mv3 = new ModelAndView(returnURL, "modelName", new Object()); //BAD

        ModelAndView mv4 = new ModelAndView();
        mv4.setViewName(returnURL); //BAD
        
        //false positive test - returnURL moved from viewName to modelName (safe argument)
        ModelAndView mv5 = new ModelAndView("viewName", returnURL, new Object()); //OK

    }catch(Exception e){
     System.out.println(e);
   }
}