Package com.nimbusds.oauth2.sdk.id

Examples of com.nimbusds.oauth2.sdk.id.Audience



  public void testParseInvalidClient()
    throws Exception {

    HTTPResponse httpResponse = new HTTPResponse(401);
    httpResponse.setContentType(CommonContentTypes.APPLICATION_JSON);
    httpResponse.setContent("{\"error\":\"invalid_client\", \"error_description\":\"Client authentication failed\"}");

    TokenErrorResponse errorResponse = TokenErrorResponse.parse(httpResponse);

    assertEquals(OAuth2Error.INVALID_CLIENT.getCode(), errorResponse.getErrorObject().getCode());
    assertEquals("Client authentication failed", errorResponse.getErrorObject().getDescription());
View Full Code Here


    TokenErrorResponse errorResponse = new TokenErrorResponse();
    assertNull(errorResponse.getErrorObject());
    assertTrue(errorResponse.toJSONObject().isEmpty());

    HTTPResponse httpResponse = errorResponse.toHTTPResponse();
    assertEquals(400, httpResponse.getStatusCode());
    assertNull(httpResponse.getContentType());
    assertNull(httpResponse.getContent());

    errorResponse = TokenErrorResponse.parse(httpResponse);
    assertNull(errorResponse.getErrorObject());
    assertTrue(errorResponse.toJSONObject().isEmpty());
  }
View Full Code Here

    AuthorizationCode code = new AuthorizationCode("123");
    State state = new State("xyz");

    AuthenticationSuccessResponse successResponse = new AuthenticationSuccessResponse(redirectURI, code, null, null, state);

    HTTPResponse httpResponse = successResponse.toHTTPResponse();

    AuthenticationResponse response = AuthenticationResponseParser.parse(httpResponse);

    assertEquals(redirectURI, response.getRedirectionURI());
    assertEquals(state, response.getState());
View Full Code Here

    ResponseType rt = new ResponseType(ResponseType.Value.CODE);
    State state = new State("xyz");

    AuthenticationErrorResponse errorResponse = new AuthenticationErrorResponse(redirectURI, OAuth2Error.ACCESS_DENIED, rt, state);

    HTTPResponse httpResponse = errorResponse.toHTTPResponse();

    AuthenticationResponse response = AuthenticationResponseParser.parse(httpResponse);

    assertEquals(redirectURI, response.getRedirectionURI());
    assertEquals(state, response.getState());
View Full Code Here

   
    // Parse required claims
    Issuer iss = new Issuer(JSONObjectUtils.getString(jsonObject, "iss"));
    Subject sub = new Subject(JSONObjectUtils.getString(jsonObject, "sub"));

    Audience aud;

    if (jsonObject.get("aud") instanceof String) {

      aud = new Audience(JSONObjectUtils.getString(jsonObject, "aud"));

    } else {
      String[] audList = JSONObjectUtils.getStringArray(jsonObject, "aud");

      if (audList.length > 1)
        throw new ParseException("Multiple audiences (aud) not supported");

      aud = new Audience(audList[0]);
    }

    Date exp = DateUtils.fromSecondsSinceEpoch(JSONObjectUtils.getLong(jsonObject, "exp"));

View Full Code Here

    Issuer issuer = new Issuer("iss");
    Subject subject = new Subject("sub");

    List<Audience> audList = new LinkedList<>();
    audList.add(new Audience("aud"));

    Date expirationTime = DateUtils.fromSecondsSinceEpoch(100000l);
    Date issueTime = DateUtils.fromSecondsSinceEpoch(200000l);

    IDTokenClaimsSet idTokenClaimsSet = new IDTokenClaimsSet(issuer, subject, audList, expirationTime, issueTime);
View Full Code Here

    Issuer issuer = new Issuer("iss");
    Subject subject = new Subject("sub");

    List<Audience> audList = new LinkedList<>();
    audList.add(new Audience("aud"));

    Date expirationTime = DateUtils.fromSecondsSinceEpoch(100000l);
    Date issueTime = DateUtils.fromSecondsSinceEpoch(200000l);

    IDTokenClaimsSet idTokenClaimsSet = new IDTokenClaimsSet(issuer, subject, audList, expirationTime, issueTime);
View Full Code Here

    responseType.add(OIDCResponseTypeValue.ID_TOKEN);

    IDTokenClaimsSet claimsSet = new IDTokenClaimsSet(
      new Issuer("iss"),
      new Subject("sub"),
      new Audience("aud").toSingleAudienceList(),
      new Date(),
      new Date());

    assertFalse(claimsSet.hasRequiredClaims(responseType));
View Full Code Here

    responseType.add(ResponseType.Value.CODE);

    IDTokenClaimsSet claimsSet = new IDTokenClaimsSet(
      new Issuer("iss"),
      new Subject("sub"),
      new Audience("aud").toSingleAudienceList(),
      new Date(),
      new Date());

    assertFalse(claimsSet.hasRequiredClaims(responseType));
View Full Code Here

    responseType.add(OIDCResponseTypeValue.ID_TOKEN);

    IDTokenClaimsSet claimsSet = new IDTokenClaimsSet(
      new Issuer("iss"),
      new Subject("sub"),
      new Audience("aud").toSingleAudienceList(),
      new Date(),
      new Date());

    assertFalse(claimsSet.hasRequiredClaims(responseType));
View Full Code Here

TOP

Related Classes of com.nimbusds.oauth2.sdk.id.Audience

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.