Package org.surfnet.oaaas.model

Examples of org.surfnet.oaaas.model.AccessTokenResponse


    login(webdriver,false);
   
    // get token response
    String tokenResponse = getAuthorizationCodeRequestHandler().getTokenResponseBlocking();
   
    AccessTokenResponse accessTokenResponse = getMapper().readValue(tokenResponse, AccessTokenResponse.class);

    assertTrue(StringUtils.isNotBlank(accessTokenResponse.getAccessToken()));
    assertTrue(StringUtils.isBlank(accessTokenResponse.getRefreshToken()));
    assertTrue(StringUtils.isNotBlank(accessTokenResponse.getScope()));
    assertTrue(StringUtils.isNotBlank(accessTokenResponse.getTokenType()));
    assertEquals(accessTokenResponse.getExpiresIn(), 0L);
  }
View Full Code Here


    // get token response
    System.out.println("Getting response");
    String tokenResponse = getAuthorizationCodeRequestHandler().getTokenResponseBlocking();
    System.out.println("Got response");

    AccessTokenResponse accessTokenResponse = getMapper().readValue(tokenResponse, AccessTokenResponse.class);

    assertTrue(StringUtils.isNotBlank(accessTokenResponse.getAccessToken()));
    assertTrue(StringUtils.isNotBlank(accessTokenResponse.getRefreshToken()));
    assertTrue(StringUtils.isNotBlank(accessTokenResponse.getScope()));
    assertTrue(StringUtils.isNotBlank(accessTokenResponse.getTokenType()));
    assertTrue(accessTokenResponse.getExpiresIn() > 0);

    String tokenUrl = String.format("%s/oauth2/token", baseUrl());

    final HttpPost tokenRequest = new HttpPost(tokenUrl);
   
    /*
     * Now make a request for a new AccessToken based on the refreshToken
     */
    String postBody = String.format("grant_type=%s&refresh_token=%s&state=%s",
            OAuth2Validator.GRANT_TYPE_REFRESH_TOKEN, accessTokenResponse.getRefreshToken(), "dummy");

    tokenRequest.setEntity(new ByteArrayEntity(postBody.getBytes()));
    tokenRequest.addHeader("Authorization", AuthorizationCodeTestIT.authorizationBasic(clientId, secret));

    tokenRequest.addHeader("Content-Type", "application/x-www-form-urlencoded");

    HttpResponse tokenHttpResponse = new DefaultHttpClient().execute(tokenRequest);
    final InputStream responseContent = tokenHttpResponse.getEntity().getContent();
    String responseAsString = IOUtils.toString(responseContent);

    AccessTokenResponse refreshTokenResponse = getMapper().readValue(responseAsString, AccessTokenResponse.class);

    assertTrue(StringUtils.isNotBlank(refreshTokenResponse.getAccessToken()));
    assertTrue(StringUtils.isNotBlank(refreshTokenResponse.getRefreshToken()));
    assertTrue(StringUtils.isNotBlank(refreshTokenResponse.getScope()));
    assertTrue(StringUtils.isNotBlank(refreshTokenResponse.getTokenType()));
    assertTrue(accessTokenResponse.getExpiresIn() > 0);

    assertNotSame(refreshTokenResponse.getAccessToken(), accessTokenResponse.getAccessToken());
    assertNotSame(refreshTokenResponse.getRefreshToken(), accessTokenResponse.getRefreshToken());
    assertEquals(refreshTokenResponse.getScope(), accessTokenResponse.getScope());
    assertEquals(refreshTokenResponse.getExpiresIn(), accessTokenResponse.getExpiresIn());

  }
View Full Code Here

TOP

Related Classes of org.surfnet.oaaas.model.AccessTokenResponse

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.