Search in sources :

Example 11 with ServletWebRequest

use of org.springframework.web.context.request.ServletWebRequest in project BroadleafCommerce by BroadleafCommerce.

the class TranslationFilter method doFilterUnlessIgnored.

@Override
public void doFilterUnlessIgnored(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
    try {
        translationRequestProcessor.process(new ServletWebRequest((HttpServletRequest) request, (HttpServletResponse) response));
        filterChain.doFilter(request, response);
    } finally {
        translationRequestProcessor.postProcess(new ServletWebRequest((HttpServletRequest) request, (HttpServletResponse) response));
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest)

Example 12 with ServletWebRequest

use of org.springframework.web.context.request.ServletWebRequest in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafLoginController method processForgotPassword.

/**
 * Looks up the passed in username and sends an email to the address on file with a
 * reset password token.
 *
 * Returns error codes for invalid username.
 *
 * @param username
 * @param request
 * @param model
 * @return the return view
 */
public String processForgotPassword(String username, HttpServletRequest request, Model model) {
    GenericResponse errorResponse = customerService.sendForgotPasswordNotification(username, getResetPasswordUrl(request));
    if (errorResponse.getHasErrors()) {
        String errorCode = errorResponse.getErrorCodesList().get(0);
        model.addAttribute("errorCode", errorCode);
        return getForgotPasswordView();
    } else {
        if (BLCRequestUtils.isOKtoUseSession(new ServletWebRequest(request))) {
            request.getSession(true).setAttribute(CHANGE_PASSWORD_USERNAME_REQUEST_ATTR, username);
        }
        return getForgotPasswordSuccessView();
    }
}
Also used : GenericResponse(org.broadleafcommerce.common.service.GenericResponse) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest)

Example 13 with ServletWebRequest

use of org.springframework.web.context.request.ServletWebRequest in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafLoginController method processForcedPasswordChange.

public String processForcedPasswordChange(String username, HttpServletRequest request, Model model) {
    final String resetPasswordUrl = getResetPasswordUrl(request);
    final GenericResponse errorResponse = customerService.sendForcedPasswordChangeNotification(username, resetPasswordUrl);
    if (errorResponse.getHasErrors()) {
        final String errorCode = errorResponse.getErrorCodesList().get(0);
        model.addAttribute("errorCode", errorCode);
        return getForcedPasswordChangeView();
    } else {
        if (BLCRequestUtils.isOKtoUseSession(new ServletWebRequest(request))) {
            request.getSession(true).setAttribute(CHANGE_PASSWORD_USERNAME_REQUEST_ATTR, username);
        }
        return getForcedPasswordChangeSuccessView();
    }
}
Also used : GenericResponse(org.broadleafcommerce.common.service.GenericResponse) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest)

Example 14 with ServletWebRequest

use of org.springframework.web.context.request.ServletWebRequest in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafLoginController method initResetPasswordForm.

/**
 * Initializes the reset password by ensuring that the passed in token URL
 * parameter initializes the hidden form field.
 *
 * Also, if the reset password request is in the same session as the
 * forgotPassword request, the username will auto-populate
 *
 * @param request
 * @return the return view
 */
public ResetPasswordForm initResetPasswordForm(HttpServletRequest request) {
    final ResetPasswordForm resetPasswordForm = new ResetPasswordForm();
    final String token = request.getParameter("token");
    String username = null;
    if (BLCRequestUtils.isOKtoUseSession(new ServletWebRequest(request))) {
        username = (String) request.getSession(true).getAttribute(CHANGE_PASSWORD_USERNAME_REQUEST_ATTR);
    }
    resetPasswordForm.setToken(token);
    resetPasswordForm.setUsername(username);
    return resetPasswordForm;
}
Also used : ServletWebRequest(org.springframework.web.context.request.ServletWebRequest)

Example 15 with ServletWebRequest

use of org.springframework.web.context.request.ServletWebRequest in project BroadleafCommerce by BroadleafCommerce.

the class CookieRuleFilter method doFilterInternalUnlessIgnored.

@Override
protected void doFilterInternalUnlessIgnored(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
    ServletWebRequest request = new ServletWebRequest(httpServletRequest, httpServletResponse);
    try {
        processor.process(request);
        filterChain.doFilter(httpServletRequest, httpServletResponse);
    } finally {
        processor.postProcess(request);
    }
}
Also used : ServletWebRequest(org.springframework.web.context.request.ServletWebRequest)

Aggregations

ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)224 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)80 Test (org.junit.jupiter.api.Test)79 MethodParameter (org.springframework.core.MethodParameter)50 BeforeEach (org.junit.jupiter.api.BeforeEach)41 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)32 ModelAndViewContainer (org.springframework.web.method.support.ModelAndViewContainer)30 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)28 Method (java.lang.reflect.Method)21 Test (org.junit.Test)21 MockMultipartHttpServletRequest (org.springframework.web.testfixture.servlet.MockMultipartHttpServletRequest)21 MockMultipartFile (org.springframework.web.testfixture.servlet.MockMultipartFile)18 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)14 TestBean (org.springframework.beans.testfixture.beans.TestBean)14 RequestParam (org.springframework.web.bind.annotation.RequestParam)14 MockPart (org.springframework.web.testfixture.servlet.MockPart)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 MultipartFile (org.springframework.web.multipart.MultipartFile)13 SynthesizingMethodParameter (org.springframework.core.annotation.SynthesizingMethodParameter)11 IOException (java.io.IOException)10