Examples of OAuth2AccessToken


Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

    this.keyGenerator = keyGenerator;
  }

  public OAuth2AccessToken getAccessToken(OAuth2ProtectedResourceDetails resource, Authentication authentication) {

    OAuth2AccessToken accessToken = null;

    try {
      accessToken = jdbcTemplate.queryForObject(selectAccessTokenSql, new RowMapper<OAuth2AccessToken>() {
        public OAuth2AccessToken mapRow(ResultSet rs, int rowNum) throws SQLException {
          return SerializationUtils.deserialize(rs.getBytes(2));
View Full Code Here

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

  }

  @Override
  protected ClientHttpRequest createRequest(URI uri, HttpMethod method) throws IOException {

    OAuth2AccessToken accessToken = getAccessToken();

    AuthenticationScheme authenticationScheme = resource.getAuthenticationScheme();
    if (AuthenticationScheme.query.equals(authenticationScheme)
        || AuthenticationScheme.form.equals(authenticationScheme)) {
      uri = appendQueryParameter(uri, accessToken);
View Full Code Here

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

  }

  @Override
  protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor) throws RestClientException {
    OAuth2AccessToken accessToken = context.getAccessToken();
    RuntimeException rethrow = null;
    try {
      return super.doExecute(url, method, requestCallback, responseExtractor);
    }
    catch (AccessTokenRequiredException e) {
View Full Code Here

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

   *
   * @return an access token
   */
  public OAuth2AccessToken getAccessToken() throws UserRedirectRequiredException {

    OAuth2AccessToken accessToken = context.getAccessToken();

    if (accessToken == null || accessToken.isExpired()) {
      try {
        accessToken = acquireAccessToken(context);
      }
      catch (UserRedirectRequiredException e) {
        context.setAccessToken(null); // No point hanging onto it now
View Full Code Here

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

    String stateKey = accessTokenRequest.getStateKey();
    if (stateKey != null) {
      accessTokenRequest.setPreservedState(oauth2Context.removePreservedState(stateKey));
    }

    OAuth2AccessToken existingToken = oauth2Context.getAccessToken();
    if (existingToken != null) {
      accessTokenRequest.setExistingToken(existingToken);
    }

    OAuth2AccessToken accessToken = null;
    accessToken = accessTokenProvider.obtainAccessToken(resource, accessTokenRequest);
    if (accessToken == null || accessToken.getValue() == null) {
      throw new IllegalStateException(
          "Access token provider returned a null access token, which is illegal according to the contract.");
    }
    oauth2Context.setAccessToken(accessToken);
    return accessToken;
View Full Code Here

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

  @Test
  public void testAttemptedTokenAcquisitionWithNoRedirect() throws Exception {
    AuthorizationCodeAccessTokenProvider provider = new AuthorizationCodeAccessTokenProvider();
    try {
      OAuth2AccessToken token = provider.obtainAccessToken(resource,
          new DefaultAccessTokenRequest());
      fail("Expected UserRedirectRequiredException");
      assertNotNull(token);
    } catch (UserRedirectRequiredException e) {
      String message = e.getMessage();
View Full Code Here

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

    resource.setClientId("my-client-with-registered-redirect");
    resource.setId("sparklr");
    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

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

   * tests the basic provider
   */
  @Test
  @OAuth2ContextConfiguration(ClientCredentials.class)
  public void testPostForToken() throws Exception {
    OAuth2AccessToken token = context.getAccessToken();
    assertNull(token.getRefreshToken());
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

   * tests that the registered scopes are used as defaults
   */
  @Test
  @OAuth2ContextConfiguration(NoScopeClientCredentials.class)
  public void testPostForTokenWithNoScopes() throws Exception {
    OAuth2AccessToken token = context.getAccessToken();
    assertFalse("Wrong scope: " + token.getScope(), token.getScope().isEmpty());
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.OAuth2AccessToken

   * tests the basic provider
   */
  @Test
  @OAuth2ContextConfiguration(ClientCredentials.class)
  public void testPostForToken() throws Exception {
    OAuth2AccessToken token = context.getAccessToken();
    assertNull(token.getRefreshToken());
  }
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.