Package com.nimbusds.oauth2.sdk.token

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


  public void testWithIDTokenJWT()
    throws Exception {

    AccessToken accessToken = new BearerAccessToken("abc123");
    RefreshToken refreshToken = new RefreshToken("def456");

    OIDCAccessTokenResponse response = new OIDCAccessTokenResponse(accessToken, refreshToken, ID_TOKEN);

    assertEquals("abc123", response.getAccessToken().getValue());
    assertEquals("def456", response.getRefreshToken().getValue());
View Full Code Here


  public void testWithIDTokenJWTAndCustomParams()
    throws Exception {

    AccessToken accessToken = new BearerAccessToken("abc123");
    RefreshToken refreshToken = new RefreshToken("def456");
    Map<String,Object> customParams = new HashMap<>();
    customParams.put("sub_sid", "abc");
    customParams.put("priority", 10);

    OIDCAccessTokenResponse response = new OIDCAccessTokenResponse(accessToken, refreshToken, ID_TOKEN, customParams);
View Full Code Here

  public void testWithIDTokenString()
    throws Exception {

    AccessToken accessToken = new BearerAccessToken("abc123");
    RefreshToken refreshToken = new RefreshToken("def456");

    OIDCAccessTokenResponse response = new OIDCAccessTokenResponse(accessToken, refreshToken, ID_TOKEN_STRING);

    assertEquals("abc123", response.getAccessToken().getValue());
    assertEquals("def456", response.getRefreshToken().getValue());
View Full Code Here

  public void testWithIDTokenStringAndCustomParams()
    throws Exception {

    AccessToken accessToken = new BearerAccessToken("abc123");
    RefreshToken refreshToken = new RefreshToken("def456");
    Map<String,Object> customParams = new HashMap<>();
    customParams.put("sub_sid", "abc");
    customParams.put("priority", 10);

    OIDCAccessTokenResponse response = new OIDCAccessTokenResponse(accessToken, refreshToken, ID_TOKEN_STRING, customParams);
View Full Code Here

  public void testWithInvalidIDTokenString()
    throws Exception {

    AccessToken accessToken = new BearerAccessToken("abc123");
    RefreshToken refreshToken = new RefreshToken("def456");
    String invalidIDTokenString = "ey...";

    OIDCAccessTokenResponse response = new OIDCAccessTokenResponse(accessToken, refreshToken, invalidIDTokenString);

    assertEquals("abc123", response.getAccessToken().getValue());
View Full Code Here


  public void testConstructor() {

    AccessToken accessToken = new BearerAccessToken();
    RefreshToken refreshToken = new RefreshToken();

    AccessTokenResponse response = new AccessTokenResponse(accessToken, refreshToken);

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


  public void testAltConstructor() {

    AccessToken accessToken = new BearerAccessToken();
    RefreshToken refreshToken = new RefreshToken();
    TokenPair tokenPair = new TokenPair(accessToken, refreshToken);

    AccessTokenResponse response = new AccessTokenResponse(tokenPair);

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

    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
    assertEquals("abc", (String)atr.getCustomParams().get("sub_sid"));
    assertEquals(10, ((Number)atr.getCustomParams().get("priority")).intValue());
    assertEquals(2, atr.getCustomParams().size());
View Full Code Here

public class RefreshTokenGrantTest extends TestCase {


  public void testConstructor() {

    RefreshToken refreshToken = new RefreshToken();
    RefreshTokenGrant grant = new RefreshTokenGrant(refreshToken);
    assertEquals(GrantType.REFRESH_TOKEN, grant.getType());
    assertEquals(refreshToken, grant.getRefreshToken());

    Map<String,String> params = grant.toParameters();
    assertEquals(GrantType.REFRESH_TOKEN.getValue(), params.get("grant_type"));
    assertEquals(refreshToken.getValue(), params.get("refresh_token"));
    assertEquals(2, params.size());
  }
View Full Code Here

  public void testWithAccessToken()
    throws Exception {

    URI endpointURI = new URI("https://c2id.com/token/revoke");
    Token token = new BearerAccessToken();

    TokenRevocationRequest request = new TokenRevocationRequest(endpointURI, null, token);
    assertEquals(endpointURI, request.getEndpointURI());
    assertNull(request.getClientAuthentication());
    assertEquals(token, request.getToken());

    HTTPRequest httpRequest = request.toHTTPRequest();
    assertEquals(HTTPRequest.Method.POST, httpRequest.getMethod());
    assertEquals(endpointURI.toURL().toString(), httpRequest.getURL().toString());
    assertEquals(CommonContentTypes.APPLICATION_URLENCODED, httpRequest.getContentType());
    assertNull(httpRequest.getAuthorization());

    assertEquals(token.getValue(), httpRequest.getQueryParameters().get("token"));
    assertEquals("access_token", httpRequest.getQueryParameters().get("token_type_hint"));
    assertEquals(2, httpRequest.getQueryParameters().size());
  }
View Full Code Here

TOP

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

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.