Examples of OAuth2Request


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

  abstract AuthorizationCodeServices getAuthorizationCodeServices();

  @Test
  public void testCreateAuthorizationCode() {
    OAuth2Request storedOAuth2Request = RequestTokenFactory.createOAuth2Request("id", false);
    OAuth2Authentication expectedAuthentication = new OAuth2Authentication(storedOAuth2Request,
        new TestAuthentication("test2", false));
    String code = getAuthorizationCodeServices().createAuthorizationCode(expectedAuthentication);
    assertNotNull(code);
View Full Code Here

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

    assertEquals(expectedAuthentication, actualAuthentication);
  }

  @Test
  public void testConsumeRemovesCode() {
    OAuth2Request storedOAuth2Request = RequestTokenFactory.createOAuth2Request("id", false);
    OAuth2Authentication expectedAuthentication = new OAuth2Authentication(storedOAuth2Request,
        new TestAuthentication("test2", false));
    String code = getAuthorizationCodeServices().createAuthorizationCode(expectedAuthentication);
    assertNotNull(code);
View Full Code Here

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

  public void testScopesWithOr() throws Exception {
    AuthorizationRequest request = new AuthorizationRequest("foo", Collections.singleton("read"));
    request.setResourceIdsAndAuthoritiesFromClientDetails(new BaseClientDetails("foo", "bar", "",
        "client_credentials", "ROLE_USER"));
    request.setApproved(true);
    OAuth2Request clientAuthentication = request.createOAuth2Request();
    Authentication userAuthentication = new UsernamePasswordAuthenticationToken("user", "pass",
        AuthorityUtils.createAuthorityList("ROLE_USER"));
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    FilterInvocation invocation = new FilterInvocation("/foo", "GET");
    EvaluationContext context = handler.createEvaluationContext(oAuth2Authentication, invocation);
View Full Code Here

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

  public void testOauthClient() throws Exception {
    AuthorizationRequest request = new AuthorizationRequest("foo", Collections.singleton("read"));
    request.setResourceIdsAndAuthoritiesFromClientDetails(new BaseClientDetails("foo", "", "",
        "client_credentials", "ROLE_CLIENT"));

    OAuth2Request clientAuthentication = RequestTokenFactory
        .createOAuth2Request(request.getRequestParameters(), request.getClientId(), request.getAuthorities(),
            request.isApproved(), request.getScope(), request.getResourceIds(), request.getRedirectUri(),
            request.getResponseTypes(), request.getExtensions());

    Authentication userAuthentication = null;
View Full Code Here

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

  }

  @Test
  public void testDenyIfOAuth2AndExplictlyDenied() throws Exception {

    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    assertEquals(
        AccessDecisionVoter.ACCESS_DENIED,
        voter.vote(oAuth2Authentication, null,
View Full Code Here

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

    assertTrue((Boolean) expression.getValue(handler.createEvaluationContext(oAuth2Authentication, invocation)));
  }

  @Test
  public void testScopes() throws Exception {
    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false,
        Collections.singleton("read"));
    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    FilterInvocation invocation = new FilterInvocation("/foo", "GET");
    Expression expression = handler.getExpressionParser().parseExpression("#oauth2.hasAnyScope('read')");
View Full Code Here

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

            Collections.<ConfigAttribute> singleton(new SecurityConfig("DENY_OAUTH"))));
  }

  @Test
  public void testAccessGrantedIfScopesPresent() throws Exception {
    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    assertEquals(
        AccessDecisionVoter.ACCESS_GRANTED,
        voter.vote(oAuth2Authentication, null,
View Full Code Here

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

  @Test(expected = AccessDeniedException.class)
  public void testInsufficientScope() throws Exception {
    AuthorizationRequest request = new AuthorizationRequest("foo", Collections.singleton("read"));
    request.setResourceIdsAndAuthoritiesFromClientDetails(new BaseClientDetails("foo", "bar", "",
        "client_credentials", "ROLE_USER"));
    OAuth2Request clientAuthentication = request.createOAuth2Request();
    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    OAuth2SecurityExpressionMethods root = new OAuth2SecurityExpressionMethods(oAuth2Authentication);
    boolean hasAnyScope = root.hasAnyScope("foo");
    root.throwOnError(hasAnyScope);
View Full Code Here

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

  }

  @Test
  public void testAccessGrantedIfScopesPresentWithPrefix() throws Exception {
    voter.setScopePrefix("scope=");
    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    assertEquals(
        AccessDecisionVoter.ACCESS_GRANTED,
        voter.vote(oAuth2Authentication, null,
View Full Code Here

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

            Collections.<ConfigAttribute> singleton(new SecurityConfig("scope=read"))));
  }

  @Test
  public void testAccessDeniedIfWrongScopesPresent() throws Exception {
    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    voter.setThrowException(false);
    assertEquals(
        AccessDecisionVoter.ACCESS_DENIED,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.