Examples of RefreshToken


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

    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

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

  public void testWithRefreshToken()
    throws Exception {

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

    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("refresh_token", httpRequest.getQueryParameters().get("token_type_hint"));
    assertEquals(2, httpRequest.getQueryParameters().size());
  }
View Full Code Here

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

  public void testWithRefreshTokenAndClientAuth()
    throws Exception {

    URI endpointURI = new URI("https://c2id.com/token/revoke");
    Token token = new RefreshToken();
    ClientAuthentication clientAuth = new ClientSecretBasic(new ClientID("123"), new Secret("secret"));

    TokenRevocationRequest request = new TokenRevocationRequest(endpointURI, clientAuth, token);
    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(clientAuth, 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());

    assertEquals(token.getValue(), httpRequest.getQueryParameters().get("token"));
    assertEquals("refresh_token", httpRequest.getQueryParameters().get("token_type_hint"));
    assertEquals(2, httpRequest.getQueryParameters().size());

    ClientSecretBasic basicAuth = ClientSecretBasic.parse(httpRequest.getAuthorization());
    assertEquals("123", basicAuth.getClientID().getValue());
View Full Code Here

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

  public static AccessTokenResponse parse(final JSONObject jsonObject)
    throws ParseException {
   
    AccessToken accessToken = AccessToken.parse(jsonObject);
   
    RefreshToken refreshToken = RefreshToken.parse(jsonObject);

    // Get the std param names for the access + refresh token
    Set<String> paramNames = accessToken.getParamNames();

    if (refreshToken != null)
      paramNames.addAll(refreshToken.getParamNames());

    // Determine the custom param names
    Set<String> customParamNames = jsonObject.keySet();
    customParamNames.removeAll(paramNames);
View Full Code Here

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

      token = new TypelessAccessToken(tokenValue);

    } else if (tokenTypeHint.equals("refresh_token")) {

      token = new RefreshToken(tokenValue);
    }


    // Parse client auth
    ClientAuthentication clientAuth = ClientAuthentication.parse(httpRequest);
View Full Code Here

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

  public void testParseSuccess()
    throws Exception {

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

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

    HTTPResponse httpResponse = response.toHTTPResponse();
View Full Code Here

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

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

  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

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

  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

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

  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
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.