Package com.nimbusds.oauth2.sdk.http

Examples of com.nimbusds.oauth2.sdk.http.HTTPResponse


    assertEquals("def456", response.getRefreshToken().getValue());
    assertEquals(ID_TOKEN_STRING, response.getIDTokenString());
    assertEquals(ID_TOKEN_STRING, response.getIDToken().serialize());
    assertTrue(response.getCustomParams().isEmpty());

    HTTPResponse httpResponse = response.toHTTPResponse();

    response = OIDCAccessTokenResponse.parse(httpResponse);

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


    assertEquals(ID_TOKEN_STRING, response.getIDToken().serialize());
    assertEquals("abc", (String)response.getCustomParams().get("sub_sid"));
    assertEquals(10, ((Number)response.getCustomParams().get("priority")).intValue());
    assertEquals(2, response.getCustomParams().size());

    HTTPResponse httpResponse = response.toHTTPResponse();

    response = OIDCAccessTokenResponse.parse(httpResponse);

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

    assertEquals(OAuth2Error.INVALID_REQUEST.getCode(), params.get("error"));
    assertEquals(OAuth2Error.INVALID_REQUEST.getDescription(), params.get("error_description"));
    assertEquals(state.toString(), params.get("state"));
    assertEquals(3, params.size());
     
    HTTPResponse httpResponse = r.toHTTPResponse();
     
    assertEquals(HTTPResponse.SC_FOUND, httpResponse.getStatusCode());
    assertEquals(location, httpResponse.getLocation());

    r = AuthorizationErrorResponse.parse(httpResponse);

    assertEquals(REDIRECT_URI, r.getRedirectionURI());
    assertEquals(OAuth2Error.INVALID_REQUEST, r.getErrorObject());
View Full Code Here

    assertEquals(claims, response.getUserInfo());
    assertEquals("application/json; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfoJWT());

    HTTPResponse httpResponse = response.toHTTPResponse();

    response = UserInfoSuccessResponse.parse(httpResponse);

    assertEquals("application/json; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfoJWT());
View Full Code Here

    assertEquals(jwt, response.getUserInfoJWT());
    assertEquals("application/jwt; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfo());

    HTTPResponse httpResponse = response.toHTTPResponse();

    response = UserInfoSuccessResponse.parse(httpResponse);

    assertEquals("application/jwt; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfo());
View Full Code Here


  public void testParseFull()
    throws Exception {

    HTTPResponse httpResponse = new HTTPResponse(403);
    httpResponse.setContentType(CommonContentTypes.APPLICATION_JSON);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("error", "access_denied");
    jsonObject.put("error_description", "Access denied");
    jsonObject.put("error_uri", "https://c2id.com/errors/access_denied");

    httpResponse.setContent(jsonObject.toJSONString());

    ErrorObject errorObject = ErrorObject.parse(httpResponse);

    assertEquals(403, errorObject.getHTTPStatusCode());
    assertEquals("access_denied", errorObject.getCode());
View Full Code Here


  public void testParseWithOmittedURI()
    throws Exception {

    HTTPResponse httpResponse = new HTTPResponse(403);
    httpResponse.setContentType(CommonContentTypes.APPLICATION_JSON);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("error", "access_denied");
    jsonObject.put("error_description", "Access denied");

    httpResponse.setContent(jsonObject.toJSONString());

    ErrorObject errorObject = ErrorObject.parse(httpResponse);

    assertEquals(403, errorObject.getHTTPStatusCode());
    assertEquals("access_denied", errorObject.getCode());
View Full Code Here


  public void testParseWithCodeOnly()
    throws Exception {

    HTTPResponse httpResponse = new HTTPResponse(403);
    httpResponse.setContentType(CommonContentTypes.APPLICATION_JSON);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("error", "access_denied");

    httpResponse.setContent(jsonObject.toJSONString());

    ErrorObject errorObject = ErrorObject.parse(httpResponse);

    assertEquals(403, errorObject.getHTTPStatusCode());
    assertEquals("access_denied", errorObject.getCode());
View Full Code Here


  public void testParseNone()
    throws Exception {

    HTTPResponse httpResponse = new HTTPResponse(403);

    ErrorObject errorObject = ErrorObject.parse(httpResponse);

    assertEquals(403, errorObject.getHTTPStatusCode());
    assertNull(errorObject.getCode());
View Full Code Here

    assertEquals(STATE, new State(params.get("state")));
    assertEquals(2, params.size());

    URI uri = resp.toURI();

    HTTPResponse httpResponse = resp.toHTTPResponse();
    assertEquals(302, httpResponse.getStatusCode());
    assertEquals(uri.toString(), httpResponse.getLocation().toString());

    resp = AuthorizationSuccessResponse.parse(httpResponse);

    assertEquals(ABS_REDIRECT_URI, resp.getRedirectionURI());
    assertEquals(CODE, resp.getAuthorizationCode());
View Full Code Here

TOP

Related Classes of com.nimbusds.oauth2.sdk.http.HTTPResponse

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.