Package com.nimbusds.oauth2.sdk.token

Examples of com.nimbusds.oauth2.sdk.token.AccessToken


  }


  public void testAltConstructorMinimal() {

    AccessToken accessToken = new BearerAccessToken();
    TokenPair tokenPair = new TokenPair(accessToken, null);

    AccessTokenResponse response = new AccessTokenResponse(tokenPair);

    assertEquals(accessToken, response.getAccessToken());
View Full Code Here


  }


  public void testAltConstructorWithCustomParams() {

    AccessToken accessToken = new BearerAccessToken();
    TokenPair tokenPair = new TokenPair(accessToken, null);
    Map<String,Object> customParams = new HashMap<>();
    customParams.put("sub_sid", "abc");

    AccessTokenResponse response = new AccessTokenResponse(tokenPair, customParams);
View Full Code Here

    httpResponse.setContent(o.toString());


    AccessTokenResponse atr = AccessTokenResponse.parse(httpResponse);

    AccessToken accessToken = atr.getAccessToken();
    assertEquals(accessTokenString, accessToken.getValue());
    assertEquals(exp, accessToken.getLifetime());
    assertNull(accessToken.getScope());

    RefreshToken refreshToken = atr.getRefreshToken();
    assertEquals(refreshTokenString, refreshToken.getValue());

    // Custom param
View Full Code Here

    httpResponse.setContent(o.toString());


    AccessTokenResponse atr = AccessTokenResponse.parse(httpResponse);

    AccessToken accessToken = atr.getAccessToken();
    assertEquals(accessTokenString, accessToken.getValue());
    assertNull(accessToken.getScope());

    // Test pair getter
    TokenPair pair = atr.getTokenPair();
    assertEquals(accessToken, pair.getAccessToken());
View Full Code Here


  public void testComputeAgainstSpecExample()
    throws Exception {

    AccessToken token = new TypelessAccessToken("jHkWEdUXMU1BwAsC4vtUsZwnNvTIxEl0z9K3vx5KF0Y");

    AccessTokenHash computedHash = AccessTokenHash.compute(token, JWSAlgorithm.RS256);

    AccessTokenHash expectedHash = new AccessTokenHash("77QmUPtjPfzWtF2AnpK9RQ");
View Full Code Here

  }


  public void testEquality() {

    AccessToken token = new TypelessAccessToken("12345678");

    AccessTokenHash hash1 = AccessTokenHash.compute(token, JWSAlgorithm.HS512);

    AccessTokenHash hash2 = AccessTokenHash.compute(token, JWSAlgorithm.HS512);
View Full Code Here

  }


  public void testUnsupportedJWSAlg() {

    AccessToken token = new TypelessAccessToken("12345678");

    assertNull(AccessTokenHash.compute(token, new JWSAlgorithm("no-such-alg")));
  }
View Full Code Here

    assertTrue(new ResponseType("token").equals(responseType));

    Map<String,String> params = resp.toParameters();
    assertEquals(TOKEN.getValue(), params.get("access_token"));
    assertEquals(STATE, new State(params.get("state")));
    assertEquals(TOKEN.getType(), new AccessTokenType(params.get("token_type")));
    assertEquals("3600", params.get("expires_in"));
    assertEquals(4, params.size());

    URI uri = resp.toURI();
View Full Code Here

    AuthorizationSuccessResponse response = AuthorizationSuccessResponse.parse(redirectionURI);
    assertEquals("https://client.example.org/cb", response.getRedirectionURI().toString());
    assertNull(response.getAuthorizationCode());
    assertEquals("xyz", response.getState().getValue());
    BearerAccessToken accessToken = (BearerAccessToken)response.getAccessToken();
    assertEquals("2YotnFZFEjr1zCsicMWpAA", accessToken.getValue());
    assertEquals(3600l, accessToken.getLifetime());
  }
View Full Code Here

    String refreshTokenString = params.get("refresh_token");

    if (refreshTokenString == null || refreshTokenString.trim().isEmpty())
      throw new ParseException("Missing or empty \"refresh_token\" parameter", OAuth2Error.INVALID_REQUEST);

    RefreshToken refreshToken = new RefreshToken(refreshTokenString);

    return new RefreshTokenGrant(refreshToken);
  }
View Full Code Here

TOP

Related Classes of com.nimbusds.oauth2.sdk.token.AccessToken

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.