Package org.springframework.security.oauth.consumer

Examples of org.springframework.security.oauth.consumer.AccessTokenRequiredException


   * @param ex The exception.
   * @return The resource that needed authorization (never null).
   */
  protected ProtectedResourceDetails checkForResourceThatNeedsAuthorization(Exception ex) throws ServletException, IOException {
    Throwable[] causeChain = getThrowableAnalyzer().determineCauseChain(ex);
    AccessTokenRequiredException ase = (AccessTokenRequiredException) getThrowableAnalyzer().getFirstThrowableOfType(AccessTokenRequiredException.class, causeChain);
    ProtectedResourceDetails resourceThatNeedsAuthorization;
    if (ase != null) {
      resourceThatNeedsAuthorization = ase.getResource();
      if (resourceThatNeedsAuthorization == null) {
        throw new OAuthRequestFailedException(ase.getMessage());
      }
    }
    else {
      // Rethrow ServletExceptions and RuntimeExceptions as-is
      if (ex instanceof ServletException) {
View Full Code Here


      Map<String, OAuthConsumerToken> accessTokens = context.getAccessTokens();

      for (String dependency : accessTokenDeps) {
        if (!accessTokens.containsKey(dependency)) {
          throw new AccessTokenRequiredException(getProtectedResourceDetailsService().loadProtectedResourceDetailsById(dependency));
        }
      }

      chain.doFilter(request, response);
    }
View Full Code Here

    filter.setTokenServices(tokenServices);
    filter.setConsumerSupport(support);
    filter.setRememberMeServices(rememberMeServices);

    doThrow(new AccessTokenRequiredException(resource)).when(filterChain).doFilter(request, response);
    when(tokenServices.getToken("dep1")).thenReturn(null);
    when(request.getParameter("oauth_verifier")).thenReturn(null);
    when(response.encodeRedirectURL("urn:callback")).thenReturn("urn:callback?query");

    OAuthConsumerToken token = new OAuthConsumerToken();
    token.setAccessToken(false);
    token.setResourceId(resource.getId());
    when(support.getUnauthorizedRequestToken("dep1", "urn:callback?query")).thenReturn(token);

    filter.doFilter(request, response, filterChain);

    verify(filterChain).doFilter(request, response);
    verify(tokenServices).storeToken("dep1", token);
    verify(response).sendRedirect("urn:callback?query&dep1");
    verify(request,times(2)).setAttribute(anyString(), anyObject());
    reset(request,response,filterChain);

    doThrow(new AccessTokenRequiredException(resource)).when(filterChain).doFilter(request, response);
    when(tokenServices.getToken("dep1")).thenReturn(token);
    when(request.getParameter(OAuthProviderParameter.oauth_verifier.toString())).thenReturn("verifier");
    OAuthConsumerToken accessToken = new OAuthConsumerToken();
    when(support.getAccessToken(token, "verifier")).thenReturn(accessToken);
    when(response.isCommitted()).thenReturn(false);
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth.consumer.AccessTokenRequiredException

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.