use of org.springframework.web.servlet.view.RedirectView in project spring-security-oauth by spring-projects.
the class AuthorizationEndpointTests method testApproveOrDeny.
@Test
public void testApproveOrDeny() throws Exception {
AuthorizationRequest request = getAuthorizationRequest("foo", "http://anywhere.com", null, null, Collections.singleton("code"));
request.setApproved(true);
Map<String, String> approvalParameters = new HashMap<String, String>();
approvalParameters.put("user_oauth_approval", "true");
model.put("authorizationRequest", request);
View result = endpoint.approveOrDeny(approvalParameters, model, sessionStatus, principal);
assertTrue("Wrong view: " + result, ((RedirectView) result).getUrl().startsWith("http://anywhere.com"));
}
use of org.springframework.web.servlet.view.RedirectView in project spring-security-oauth by spring-projects.
the class AuthorizationEndpointTests method testAuthorizationCodeWithTrickyQueryParams.
@Test
public void testAuthorizationCodeWithTrickyQueryParams() throws Exception {
endpoint.setAuthorizationCodeServices(new StubAuthorizationCodeServices());
model.put("authorizationRequest", getAuthorizationRequest("foo", "http://anywhere.com?foo=b =&bar=f $", null, null, Collections.singleton("code")));
View result = endpoint.approveOrDeny(Collections.singletonMap(OAuth2Utils.USER_OAUTH_APPROVAL, "true"), model, sessionStatus, principal);
String url = ((RedirectView) result).getUrl();
assertEquals("http://anywhere.com?foo=b%20=&bar=f%20$&code=thecode", url);
MultiValueMap<String, String> params = UriComponentsBuilder.fromHttpUrl(url).build().getQueryParams();
assertEquals("[b%20=]", params.get("foo").toString());
assertEquals("[f%20$]", params.get("bar").toString());
}
use of org.springframework.web.servlet.view.RedirectView in project spring-security-oauth by spring-projects.
the class AuthorizationEndpointTests method testImplicitWithAdditionalInfo.
@Test
public void testImplicitWithAdditionalInfo() throws Exception {
endpoint.setTokenGranter(new TokenGranter() {
public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken("FOO");
token.setAdditionalInformation(Collections.<String, Object>singletonMap("foo", "bar"));
return token;
}
});
endpoint.setUserApprovalHandler(new DefaultUserApprovalHandler() {
public boolean isApproved(AuthorizationRequest authorizationRequest, Authentication userAuthentication) {
return true;
}
});
AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate", "myscope", Collections.singleton("token"));
ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus, principal);
String url = ((RedirectView) result.getView()).getUrl();
assertTrue("Wrong url: " + result, url.contains("foo=bar"));
}
use of org.springframework.web.servlet.view.RedirectView in project cas by apereo.
the class CasWebAppConfiguration method rootController.
@Bean
protected Controller rootController() {
return new ParameterizableViewController() {
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final String queryString = request.getQueryString();
final String url = request.getContextPath() + "/login" + (queryString != null ? '?' + queryString : StringUtils.EMPTY);
return new ModelAndView(new RedirectView(response.encodeURL(url)));
}
};
}
use of org.springframework.web.servlet.view.RedirectView in project cas by apereo.
the class CasApplicationContextConfiguration method rootController.
@Bean
protected Controller rootController() {
return new ParameterizableViewController() {
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final String queryString = request.getQueryString();
final String url = request.getContextPath() + "/login" + (queryString != null ? '?' + queryString : StringUtils.EMPTY);
return new ModelAndView(new RedirectView(response.encodeURL(url)));
}
};
}
Aggregations