Package org.springframework.security.oauth2.common

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


  @Test
  public void readAccessTokenNoExpires() throws IOException {
    accessToken.setRefreshToken(null);
    accessToken.setExpiration(null);
    when(inputMessage.getBody()).thenReturn(createInputStream(OAUTH_ACCESSTOKEN_NOEXPIRES));
    OAuth2AccessToken token = converter.read(OAuth2AccessToken.class, inputMessage);
    assertTokenEquals(accessToken,token);
  }
View Full Code Here


  @Test
  public void testSunnyDay() {
    ResourceOwnerPasswordTokenGranter granter = new ResourceOwnerPasswordTokenGranter(authenticationManager,
        providerTokenServices, clientDetailsService, requestFactory);
    OAuth2AccessToken token = granter.grant("password", tokenRequest);
    OAuth2Authentication authentication = providerTokenServices.loadAuthentication(token.getValue());
    assertTrue(authentication.isAuthenticated());
  }
View Full Code Here

  @Test
  public void testPasswordRemoved() {
    ResourceOwnerPasswordTokenGranter granter = new ResourceOwnerPasswordTokenGranter(authenticationManager,
        providerTokenServices, clientDetailsService, requestFactory);
    OAuth2AccessToken token = granter.grant("password", tokenRequest);
    OAuth2Authentication authentication = providerTokenServices.loadAuthentication(token.getValue());
    assertNotNull(authentication.getOAuth2Request().getRequestParameters().get("username"));
    assertNull(authentication.getOAuth2Request().getRequestParameters().get("password"));
  }
View Full Code Here

  /**
   * tests appendQueryParameter
   */
  @Test
  public void testAppendQueryParameter() throws Exception {
    OAuth2AccessToken token = new DefaultOAuth2AccessToken("12345");
    URI appended = restTemplate.appendQueryParameter(URI.create("https://graph.facebook.com/search?type=checkin"),
        token);
    assertEquals("https://graph.facebook.com/search?type=checkin&bearer_token=12345", appended.toString());
  }
View Full Code Here

  /**
   * tests appendQueryParameter
   */
  @Test
  public void testAppendQueryParameterWithNoExistingParameters() throws Exception {
    OAuth2AccessToken token = new DefaultOAuth2AccessToken("12345");
    URI appended = restTemplate.appendQueryParameter(URI.create("https://graph.facebook.com/search"), token);
    assertEquals("https://graph.facebook.com/search?bearer_token=12345", appended.toString());
  }
View Full Code Here

        return authentication;
      }
    };
    ResourceOwnerPasswordTokenGranter granter = new ResourceOwnerPasswordTokenGranter(authenticationManager,
        providerTokenServices, clientDetailsService, requestFactory);
    OAuth2AccessToken token = granter.grant("password", tokenRequest);
    OAuth2Authentication authentication = providerTokenServices.loadAuthentication(token.getValue());
    assertTrue(authentication.isAuthenticated());
    assertNull(authentication.getUserAuthentication().getDetails());
  }
View Full Code Here

  /**
   * tests encoding of access token value
   */
  @Test
  public void testDoubleEncodingOfParameterValue() throws Exception {
    OAuth2AccessToken token = new DefaultOAuth2AccessToken("1/qIxxx");
    URI appended = restTemplate.appendQueryParameter(URI.create("https://graph.facebook.com/search"), token);
    assertEquals("https://graph.facebook.com/search?bearer_token=1%2FqIxxx", appended.toString());
  }
View Full Code Here

  /**
   * tests no double encoding of existing query parameter
   */
  @Test
  public void testNonEncodingOfUriTemplate() throws Exception {
    OAuth2AccessToken token = new DefaultOAuth2AccessToken("12345");
    UriTemplate uriTemplate = new UriTemplate("https://graph.facebook.com/fql?q={q}");
    URI expanded = uriTemplate.expand("[q: fql]");
    URI appended = restTemplate.appendQueryParameter(expanded, token);
    assertEquals("https://graph.facebook.com/fql?q=%5Bq:%20fql%5D&bearer_token=12345", appended.toString());
  }
View Full Code Here

  /**
   * tests URI with fragment value
   */
  @Test
  public void testFragmentUri() throws Exception {
    OAuth2AccessToken token = new DefaultOAuth2AccessToken("1234");
    URI appended = restTemplate.appendQueryParameter(URI.create("https://graph.facebook.com/search#foo"), token);
    assertEquals("https://graph.facebook.com/search?bearer_token=1234#foo", appended.toString());
  }
View Full Code Here

   * tests encoding of access token value passed in protected requests ref: SECOAUTH-90
   */
  @Test
  public void testDoubleEncodingOfAccessTokenValue() throws Exception {
    // try with fictitious token value with many characters to encode
    OAuth2AccessToken token = new DefaultOAuth2AccessToken("1 qI+x:y=z");
    // System.err.println(UriUtils.encodeQueryParam(token.getValue(), "UTF-8"));
    URI appended = restTemplate.appendQueryParameter(URI.create("https://graph.facebook.com/search"), token);
    assertEquals("https://graph.facebook.com/search?bearer_token=1+qI%2Bx%3Ay%3Dz", appended.toString());
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.common.OAuth2AccessToken

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.