Search in sources :

Example 91 with RedirectView

use of org.springframework.web.servlet.view.RedirectView in project spring-security-oauth by spring-projects.

the class AuthorizationEndpointTests method testAuthorizationCodeWithQueryParams.

@Test
public void testAuthorizationCodeWithQueryParams() throws Exception {
    endpoint.setAuthorizationCodeServices(new StubAuthorizationCodeServices());
    model.put("authorizationRequest", getAuthorizationRequest("foo", "http://anywhere.com?foo=bar", null, null, Collections.singleton("code")));
    View result = endpoint.approveOrDeny(Collections.singletonMap(OAuth2Utils.USER_OAUTH_APPROVAL, "true"), model, sessionStatus, principal);
    assertEquals("http://anywhere.com?foo=bar&code=thecode", ((RedirectView) result).getUrl());
}
Also used : RedirectView(org.springframework.web.servlet.view.RedirectView) ModelAndView(org.springframework.web.servlet.ModelAndView) View(org.springframework.web.servlet.View) Test(org.junit.Test)

Example 92 with RedirectView

use of org.springframework.web.servlet.view.RedirectView in project opennms by OpenNMS.

the class AlarmDetailController method removeJournalMemo.

public ModelAndView removeJournalMemo(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
    int alarmId;
    String alarmIdString = "";
    // Try to parse alarm ID from string to integer
    try {
        alarmIdString = httpServletRequest.getParameter("alarmId");
        alarmId = Integer.parseInt(alarmIdString);
        m_webAlarmRepository.removeReductionKeyMemo(alarmId);
        return new ModelAndView(new RedirectView("detail.htm", true), "id", alarmId);
    } catch (NumberFormatException e) {
        logger.error("Could not parse alarm ID '{}' to integer.", httpServletRequest.getParameter("alarmId"));
        throw new ServletException("Could not parse alarm ID " + httpServletRequest.getParameter("alarmId") + " to integer.");
    }
}
Also used : ServletException(javax.servlet.ServletException) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView)

Example 93 with RedirectView

use of org.springframework.web.servlet.view.RedirectView in project opennms by OpenNMS.

the class AlarmDetailController method saveJournalMemo.

public ModelAndView saveJournalMemo(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
    int alarmId;
    String alarmIdString = "";
    // Try to parse alarm ID from string to integer
    try {
        alarmIdString = httpServletRequest.getParameter("alarmId");
        alarmId = Integer.parseInt(alarmIdString);
        String journalMemoBody = httpServletRequest.getParameter("journalMemoBody");
        m_webAlarmRepository.updateReductionKeyMemo(alarmId, journalMemoBody, httpServletRequest.getRemoteUser());
        return new ModelAndView(new RedirectView("detail.htm", true), "id", alarmId);
    } catch (NumberFormatException e) {
        logger.error("Could not parse alarm ID '{}' to integer.", httpServletRequest.getParameter("alarmId"));
        throw new ServletException("Could not parse alarm ID " + httpServletRequest.getParameter("alarmId") + " to integer.");
    }
}
Also used : ServletException(javax.servlet.ServletException) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView)

Example 94 with RedirectView

use of org.springframework.web.servlet.view.RedirectView in project opennms by OpenNMS.

the class EventController method getRedirectView.

private ModelAndView getRedirectView(HttpServletRequest request) {
    String redirectParms = request.getParameter("redirectParms");
    String redirect = request.getParameter("redirect");
    String viewName;
    if (redirect != null) {
        viewName = redirect;
    } else {
        viewName = (redirectParms == null || "".equals(redirectParms) || "null".equals(redirectParms) ? "/event/list" : "/event/list" + "?" + redirectParms);
    }
    RedirectView redirectView = new RedirectView(viewName);
    return new ModelAndView(redirectView);
}
Also used : RedirectView(org.springframework.web.servlet.view.RedirectView) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 95 with RedirectView

use of org.springframework.web.servlet.view.RedirectView in project libresonic by Libresonic.

the class SetMusicFileInfoController method handleRequestInternal.

@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
    int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
    String action = request.getParameter("action");
    MediaFile mediaFile = mediaFileService.getMediaFile(id);
    if ("comment".equals(action)) {
        mediaFile.setComment(StringUtil.toHtml(request.getParameter("comment")));
        mediaFileService.updateMediaFile(mediaFile);
    }
    String url = "main.view?id=" + id;
    return new ModelAndView(new RedirectView(url));
}
Also used : MediaFile(org.libresonic.player.domain.MediaFile) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RedirectView (org.springframework.web.servlet.view.RedirectView)156 ModelAndView (org.springframework.web.servlet.ModelAndView)99 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)36 HashMap (java.util.HashMap)33 lombok.val (lombok.val)33 Test (org.junit.jupiter.api.Test)30 Test (org.junit.Test)25 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)23 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)23 View (org.springframework.web.servlet.View)19 CasProfile (org.pac4j.cas.profile.CasProfile)14 JEEContext (org.pac4j.core.context.JEEContext)14 Authentication (org.springframework.security.core.Authentication)14 AuthorizationRequest (org.springframework.security.oauth2.provider.AuthorizationRequest)13 MockHttpSession (org.springframework.mock.web.MockHttpSession)12 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)10 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)9 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)8 TokenRequest (org.springframework.security.oauth2.provider.TokenRequest)8 DefaultUserApprovalHandler (org.springframework.security.oauth2.provider.approval.DefaultUserApprovalHandler)8