Package org.springframework.security.oauth2.client

Examples of org.springframework.security.oauth2.client.DefaultOAuth2ClientContext


    }

  }

  private OAuth2RestTemplate createRestTemplate(OAuth2ProtectedResourceDetails resource, AccessTokenRequest request) {
    OAuth2ClientContext context = new DefaultOAuth2ClientContext(request);
    OAuth2RestTemplate client = new OAuth2RestTemplate(resource, context);
    client.setRequestFactory(new SimpleClientHttpRequestFactory() {
      @Override
      protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
        super.prepareConnection(connection, httpMethod);
View Full Code Here


    resource.setScope(Arrays.asList("trust"));

    ClientCredentialsAccessTokenProvider provider = new ClientCredentialsAccessTokenProvider();
    OAuth2AccessToken accessToken = provider.obtainAccessToken(resource, new DefaultAccessTokenRequest());

    OAuth2RestTemplate template = new OAuth2RestTemplate(resource, new DefaultOAuth2ClientContext(accessToken));
    String result = template.getForObject(serverRunning.getUrl("/sparklr2/photos/trusted/message"), String.class);
    assertEquals("Hello, Trusted Client", result);

  }
View Full Code Here

    assertTrue(existingToken.isExpired());

    AccessTokenRequest request = new DefaultAccessTokenRequest();
    request.setExistingToken(existingToken);

    OAuth2RestTemplate template = new OAuth2RestTemplate(resource, new DefaultOAuth2ClientContext(request));
    String result = template.getForObject(serverRunning.getUrl("/sparklr2/photos/user/message"), String.class);
    assertEquals("Hello, Trusted User marissa", result);

    assertFalse("Tokens match so there was no refresh", existingToken.equals(template.getAccessToken()));
View Full Code Here

  private OAuth2RestOperations template;
 
  @Before
  public void init() {
    template = new OAuth2RestTemplate(resource, new DefaultOAuth2ClientContext());
  }
View Full Code Here

  }

  @Bean
  @Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
  public OAuth2RestOperations restTemplate() {
    OAuth2RestTemplate template = new OAuth2RestTemplate(resource(), new DefaultOAuth2ClientContext(accessTokenRequest));
    AccessTokenProviderChain provider = new AccessTokenProviderChain(Arrays.asList(new AuthorizationCodeAccessTokenProvider()));
    provider.setClientTokenServices(clientTokenServices());
    return template;
  }
View Full Code Here

    public OAuth2RestOperations restTemplate() {
      AuthorizationCodeResourceDetails resource = new AuthorizationCodeResourceDetails();
      resource.setClientId("client");
      resource.setAccessTokenUri("http://example.com/token");
      resource.setUserAuthorizationUri("http://example.com/authorize");
      return new OAuth2RestTemplate(resource, new DefaultOAuth2ClientContext(accessTokenRequest));
    }
View Full Code Here

    }

    @Bean
    @Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
    public OAuth2RestTemplate facebookRestTemplate() {
      OAuth2RestTemplate template = new OAuth2RestTemplate(facebook(), new DefaultOAuth2ClientContext(
          accessTokenRequest));
      MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
      converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON,
          MediaType.valueOf("text/javascript")));
      template.setMessageConverters(Arrays.<HttpMessageConverter<?>> asList(converter));
View Full Code Here

    }

    @Bean
    @Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
    public OAuth2RestTemplate sparklrRestTemplate() {
      return new OAuth2RestTemplate(sparklr(), new DefaultOAuth2ClientContext(accessTokenRequest));
    }
View Full Code Here

    }

    @Bean
    @Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
    public OAuth2RestTemplate sparklrRedirectRestTemplate() {
      return new OAuth2RestTemplate(sparklrRedirect(), new DefaultOAuth2ClientContext(accessTokenRequest));
    }
View Full Code Here

      return new OAuth2RestTemplate(sparklrRedirect(), new DefaultOAuth2ClientContext(accessTokenRequest));
    }

    @Bean
    public OAuth2RestTemplate trustedClientRestTemplate() {
      return new OAuth2RestTemplate(trusted(), new DefaultOAuth2ClientContext());
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.client.DefaultOAuth2ClientContext

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.