Package com.nimbusds.oauth2.sdk.token

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


  }


  public void testConstructorWithCustomParams() {

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

    AccessTokenResponse response = new AccessTokenResponse(accessToken, null, customParams);
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);
View Full Code Here

  }


  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

  public static ClientReadRequest parse(final HTTPRequest httpRequest)
    throws ParseException {

    httpRequest.ensureMethod(HTTPRequest.Method.GET);

    BearerAccessToken accessToken = BearerAccessToken.parse(httpRequest.getAuthorization());

    URI endpointURI;

    try {
      endpointURI = httpRequest.getURL().toURI();
View Full Code Here

  public static ClientUpdateRequest parse(final HTTPRequest httpRequest)
    throws ParseException {

    httpRequest.ensureMethod(HTTPRequest.Method.PUT);
   
    BearerAccessToken accessToken = BearerAccessToken.parse(httpRequest.getAuthorization());
   
    JSONObject jsonObject = httpRequest.getQueryAsJSONObject();
   
    ClientID id = new ClientID(JSONObjectUtils.getString(jsonObject, "client_id"));
View Full Code Here

    ClientID id = new ClientID("123");
    OIDCClientMetadata metadata = new OIDCClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/cb"));
    URI regURI = new URI("https://c2id.com/client-reg/123");
    BearerAccessToken accessToken = new BearerAccessToken();
    metadata.setName("My app");
    metadata.applyDefaults();

    OIDCClientInformation clientInfo = new OIDCClientInformation(id, null, metadata, null, regURI, accessToken);

    OIDCClientInformationResponse response = new OIDCClientInformationResponse(clientInfo);

    HTTPResponse httpResponse = response.toHTTPResponse();

    ClientRegistrationResponse regResponse = OIDCClientRegistrationResponseParser.parse(httpResponse);

    response = (OIDCClientInformationResponse)regResponse;

    assertEquals(id, response.getOIDCClientInformation().getID());
    assertEquals("My app", response.getOIDCClientInformation().getMetadata().getName());
    assertNull(response.getOIDCClientInformation().getSecret());
    assertNull(response.getOIDCClientInformation().getIDIssueDate());
    assertEquals(regURI, response.getOIDCClientInformation().getRegistrationURI());
    assertEquals(accessToken.getValue(), response.getOIDCClientInformation().getRegistrationAccessToken().getValue());
  }
View Full Code Here

    Date issueDate = new Date(new Date().getTime() / 1000 * 1000);
    OIDCClientMetadata metadata = new OIDCClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/cb"));
    metadata.applyDefaults();
    Secret secret = new Secret();
    BearerAccessToken accessToken = new BearerAccessToken();
    URI uri = new URI("https://c2id.com/client-reg/123");

    OIDCClientInformation info = new OIDCClientInformation(
      id, issueDate, metadata, secret, uri, accessToken);

    OIDCClientInformationResponse response = new OIDCClientInformationResponse(info);

    assertEquals(info, response.getOIDCClientInformation());
    assertEquals(info, response.getClientInformation());

    HTTPResponse httpResponse = response.toHTTPResponse();

    response = OIDCClientInformationResponse.parse(httpResponse);

    assertEquals(id.getValue(), response.getClientInformation().getID().getValue());
    assertEquals(issueDate, response.getClientInformation().getIDIssueDate());
    assertEquals("https://client.com/cb", response.getClientInformation().getMetadata().getRedirectionURIs().iterator().next().toString());
    assertEquals(secret.getValue(), response.getClientInformation().getSecret().getValue());
    assertEquals(uri.toString(), response.getClientInformation().getRegistrationURI().toString());
    assertEquals(accessToken.getValue(), response.getClientInformation().getRegistrationAccessToken().getValue());
  }
View Full Code Here

  public void testCycle()
    throws Exception {

    URI uri = new URI("https://c2id.com/client-reg/123");
    ClientID clientID = new ClientID("123");
    BearerAccessToken accessToken = new BearerAccessToken();
    OIDCClientMetadata metadata = new OIDCClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/cb"));
    metadata.setName("My app");
    metadata.applyDefaults();
    Secret secret = new Secret();

    OIDCClientUpdateRequest request = new OIDCClientUpdateRequest(
      uri,
      clientID,
      accessToken,
      metadata,
      secret);

    assertEquals(uri, request.getEndpointURI());
    assertEquals(clientID, request.getClientID());
    assertEquals(accessToken, request.getAccessToken());
    assertEquals(metadata, request.getOIDCClientMetadata());
    assertEquals(metadata, request.getClientMetadata());
    assertEquals(secret, request.getClientSecret());


    HTTPRequest httpRequest = request.toHTTPRequest();

    request = OIDCClientUpdateRequest.parse(httpRequest);

    assertEquals(uri.toString(), request.getEndpointURI().toString());
    assertEquals(clientID.getValue(), request.getClientID().getValue());
    assertEquals(accessToken.getValue(), request.getAccessToken().getValue());
    assertEquals("https://client.com/cb", request.getClientMetadata().getRedirectionURIs().iterator().next().toString());
    assertEquals("My app", request.getClientMetadata().getName());
    assertEquals(secret.getValue(), request.getClientSecret().getValue());
  }
View Full Code Here

    Date now = new Date(new Date().getTime() / 1000 * 1000);
    OIDCClientMetadata metadata = new OIDCClientMetadata();
    metadata.setName("Example app");
    Secret secret = new Secret("secret");
    URI regURI = new URI("https://c2id.com/client-reg/123");
    BearerAccessToken accessToken = new BearerAccessToken("xyz");

    OIDCClientInformation info = new OIDCClientInformation(clientID, now, metadata, secret, regURI, accessToken);

    assertEquals(clientID, info.getID());
    assertEquals(now, info.getIDIssueDate());
View Full Code Here

TOP

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

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.