Examples of OAuth2AccessDeniedException


Examples of org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException

      throw new InvalidTokenException("Invalid token: " + token);
    }

    Collection<String> resourceIds = auth.getOAuth2Request().getResourceIds();
    if (resourceId != null && resourceIds != null && !resourceIds.isEmpty() && !resourceIds.contains(resourceId)) {
      throw new OAuth2AccessDeniedException("Invalid token does not contain resource id (" + resourceId + ")");
    }

    checkClientDetails(auth);

    if (authentication.getDetails() instanceof OAuth2AuthenticationDetails) {
View Full Code Here

Examples of org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException

      ClientDetails client;
      try {
        client = clientDetailsService.loadClientByClientId(auth.getOAuth2Request().getClientId());
      }
      catch (ClientRegistrationException e) {
        throw new OAuth2AccessDeniedException("Invalid token contains invalid client id");
      }
      Set<String> allowed = client.getScope();
      for (String scope : auth.getOAuth2Request().getScope()) {
        if (!allowed.contains(scope)) {
          throw new OAuth2AccessDeniedException("Invalid token contains disallowed scope (" + scope
              + ") for this client");
        }
      }
    }
  }
View Full Code Here

Examples of org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException

      if (tokenProvider.supportsResource(details)) {
        return tokenProvider.obtainAccessToken(details, request);
      }
    }

    throw new OAuth2AccessDeniedException("Unable to obtain a new access token for resource '" + details.getId()
        + "'. The provider manager is not configured to support it.", details);
  }
View Full Code Here

Examples of org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException

    for (AccessTokenProvider tokenProvider : chain) {
      if (tokenProvider.supportsRefresh(resource)) {
        return tokenProvider.refreshAccessToken(resource, refreshToken, request);
      }
    }
    throw new OAuth2AccessDeniedException("Unable to obtain a new access token for resource '" + resource.getId()
        + "'. The provider manager is not configured to support it.", resource);
  }
View Full Code Here

Examples of org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException

    catch (OAuth2AccessDeniedException e) {
      rethrow = e;
    }
    catch (InvalidTokenException e) {
      // Don't reveal the token value in case it is logged
      rethrow = new OAuth2AccessDeniedException("Invalid token for client=" + getClientId());
    }
    if (accessToken != null && retryBadAccessTokens) {
      context.setAccessToken(null);
      try {
        return super.doExecute(url, method, requestCallback, responseExtractor);
      }
      catch (InvalidTokenException e) {
        // Don't reveal the token value in case it is logged
        rethrow = new OAuth2AccessDeniedException("Invalid token for client=" + getClientId());
      }
    }
    throw rethrow;
  }
View Full Code Here

Examples of org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException

      return getRestTemplate().execute(getAccessTokenUri(resource, form), getHttpMethod(),
          getRequestCallback(resource, form, headers), extractor , form.toSingleValueMap());

    }
    catch (OAuth2Exception oe) {
      throw new OAuth2AccessDeniedException("Access token denied.", resource, oe);
    }
    catch (RestClientException rce) {
      throw new OAuth2AccessDeniedException("Error requesting access token.", resource, rce);
    }

  }
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.