Package com.nimbusds.oauth2.sdk.token

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


    assertNull(info.getRegistrationAccessToken());

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

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

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


  public void testMinimalConstructor()
    throws Exception {

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

    UserInfoRequest request = new UserInfoRequest(endpointURI, token);

    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(token, request.getAccessToken());
    assertEquals(HTTPRequest.Method.GET, request.getMethod());

    HTTPRequest httpRequest = request.toHTTPRequest();

    assertEquals(HTTPRequest.Method.GET, httpRequest.getMethod());
    assertEquals(endpointURI, httpRequest.getURL().toURI());
    assertNull(httpRequest.getQuery());
    assertEquals(token.toAuthorizationHeader(), httpRequest.getAuthorization());

    request = UserInfoRequest.parse(httpRequest);

    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(token, request.getAccessToken());
View Full Code Here

  public void testFullConstructor()
    throws Exception {

    URI url = new URI("https://c2id.com/userinfo");
    BearerAccessToken token = new BearerAccessToken();

    UserInfoRequest request = new UserInfoRequest(url, HTTPRequest.Method.POST, token);

    assertEquals(url, request.getEndpointURI());
    assertEquals(token, request.getAccessToken());
    assertEquals(HTTPRequest.Method.POST, request.getMethod());

    HTTPRequest httpRequest = request.toHTTPRequest();

    assertEquals(HTTPRequest.Method.POST, httpRequest.getMethod());
    assertEquals(url, httpRequest.getURL().toURI());
    assertEquals("application/x-www-form-urlencoded; charset=UTF-8", httpRequest.getContentType().toString());
    assertEquals("access_token="+token.getValue(), httpRequest.getQuery());
    assertNull(httpRequest.getAuthorization());

    request = UserInfoRequest.parse(httpRequest);

    assertEquals(url, request.getEndpointURI());
View Full Code Here

  public static UserInfoRequest parse(final HTTPRequest httpRequest)
    throws ParseException {
   
    HTTPRequest.Method httpMethod = httpRequest.getMethod();
   
    BearerAccessToken accessToken = BearerAccessToken.parse(httpRequest);

    URI endpointURI;

    try {
View Full Code Here

  public static OIDCClientUpdateRequest 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

    ClientMetadata metadata = new ClientMetadata();
    metadata.setName("My test app");
    metadata.setRedirectionURI(new URI("https://client.com/callback"));
    metadata.applyDefaults();

    BearerAccessToken accessToken = new BearerAccessToken();

    ClientRegistrationRequest request = new ClientRegistrationRequest(uri, metadata, accessToken);

    HTTPRequest httpRequest = request.toHTTPRequest();
View Full Code Here

  public void testCycle()
    throws Exception {

    URI uri = new URI("https://c2id.com/client-reg/123");
    BearerAccessToken accessToken = new BearerAccessToken();

    ClientReadRequest request = new ClientReadRequest(uri, accessToken);

    assertEquals(uri, request.getEndpointURI());
    assertEquals(accessToken, request.getAccessToken());

    HTTPRequest httpRequest = request.toHTTPRequest();

    assertEquals(HTTPRequest.Method.GET, httpRequest.getMethod());
    assertEquals(uri, httpRequest.getURL().toURI());
    assertEquals(accessToken.toAuthorizationHeader(), httpRequest.getAuthorization());

    request = ClientReadRequest.parse(httpRequest);

    assertEquals(uri.toString(), request.getEndpointURI().toString());
    assertEquals(accessToken.getValue(), request.getAccessToken().getValue());
  }
View Full Code Here

    // Parse the client metadata
    OIDCClientMetadata metadata = OIDCClientMetadata.parse(jsonObject);

    // Parse the optional bearer access token
    BearerAccessToken accessToken = null;
   
    String authzHeaderValue = httpRequest.getAuthorization();
   
    if (StringUtils.isNotBlank(authzHeaderValue))
      accessToken = BearerAccessToken.parse(authzHeaderValue);
View Full Code Here

    if (jsonObject.containsKey("registration_client_uri")) {

      registrationURI = JSONObjectUtils.getURI(jsonObject, "registration_client_uri");
    }

    BearerAccessToken accessToken = null;

    if (jsonObject.containsKey("registration_access_token")) {

      accessToken = new BearerAccessToken(
        JSONObjectUtils.getString(jsonObject, "registration_access_token"));
    }

    return new OIDCClientInformation(id, issueDate, metadata, secret, registrationURI, accessToken);
  }
View Full Code Here

    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

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.