Package org.springframework.security.oauth2.provider

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest


      parameters.put(OAuth2Utils.SCOPE, scope);
    }
    if (responseTypes != null) {
      parameters.put(OAuth2Utils.RESPONSE_TYPE, OAuth2Utils.formatParameterList(responseTypes));
    }
    return new AuthorizationRequest(parameters, Collections.<String, String> emptyMap(),
        parameters.get(OAuth2Utils.CLIENT_ID),
        OAuth2Utils.parseParameterList(parameters.get(OAuth2Utils.SCOPE)), null, null, false,
        parameters.get(OAuth2Utils.STATE), parameters.get(OAuth2Utils.REDIRECT_URI),
        OAuth2Utils.parseParameterList(parameters.get(OAuth2Utils.RESPONSE_TYPE)));
  }
View Full Code Here


      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 view: " + result, url.startsWith("http://anywhere.com"));
    assertTrue("Wrong state: " + result, url.contains("&state=mystate"));
    assertTrue("Wrong token: " + result, url.contains("access_token="));
View Full Code Here

      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 scope: " + result, url.contains("&scope=read"));
  }
View Full Code Here

    endpoint.setUserApprovalHandler(new DefaultUserApprovalHandler() {
      public boolean isApproved(AuthorizationRequest authorizationRequest, Authentication userAuthentication) {
        return true;
      }
    });
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com?foo=bar",
        "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"));
  }
View Full Code Here

          Authentication userAuthentication) {
        return authorizationRequest;
      }
    });
    client.setScope(Collections.singleton("read"));
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        null, Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    String url = ((RedirectView) result.getView()).getUrl();
    assertTrue("Wrong scope: " + result, url.contains("&scope=read%20write"));
  }
View Full Code Here

          Authentication userAuthentication) {
        return authorizationRequest;
      }
    });
    client.setScope(Collections.singleton("smallscope"));
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        "bigscope", Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    String url = ((RedirectView) result.getView()).getUrl();
    assertTrue("Wrong view: " + result, url.startsWith("http://anywhere.com"));
  }
View Full Code Here

    endpoint.setTokenGranter(new TokenGranter() {
      public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
        return null;
      }
    });
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        "myscope", Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    assertEquals("forward:/oauth/confirm_access", result.getViewName());
  }
View Full Code Here

    endpoint.setTokenGranter(new TokenGranter() {
      public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
        return null;
      }
    });
    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 view: " + result, url.startsWith("http://anywhere.com"));
    assertTrue("No error: " + result, url.contains("#error="));
View Full Code Here

  }

  @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"));
View Full Code Here

  public void testRedirectUriOptionalForAuthorization() throws Exception {
    ModelAndView result = endpoint.authorize(model,
        getAuthorizationRequest("foo", null, null, "read", Collections.singleton("code"))
            .getRequestParameters(), sessionStatus, principal);
    // RedirectUri parameter should be null (SECOAUTH-333), however the resolvedRedirectUri not
    AuthorizationRequest authorizationRequest = (AuthorizationRequest) result.getModelMap().get(
        "authorizationRequest");
    assertNull(authorizationRequest.getRequestParameters().get(OAuth2Utils.REDIRECT_URI));
    assertEquals("http://anywhere.com", authorizationRequest.getRedirectUri());
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.provider.AuthorizationRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.