Package com.nimbusds.oauth2.sdk.auth

Examples of com.nimbusds.oauth2.sdk.auth.Secret


   
    ClientID id = new ClientID(JSONObjectUtils.getString(jsonObject, "client_id"));

    OIDCClientMetadata metadata = OIDCClientMetadata.parse(jsonObject);
   
    Secret clientSecret = null;
   
    if (jsonObject.get("client_secret") != null)
      clientSecret = new Secret(JSONObjectUtils.getString(jsonObject, "client_secret"));


    URI endpointURI;

    try {
View Full Code Here


      issueDate = new Date(JSONObjectUtils.getLong(jsonObject, "client_id_issued_at") * 1000);
    }

    OIDCClientMetadata metadata = OIDCClientMetadata.parse(jsonObject);

    Secret secret = null;

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

      String value = JSONObjectUtils.getString(jsonObject, "client_secret");

      Date exp = null;

      if (jsonObject.containsKey("client_secret_expires_at"))
        exp = new Date(JSONObjectUtils.getLong(jsonObject, "client_secret_expires_at") * 1000);

      secret = new Secret(value, exp);
    }

    URI registrationURI = null;

    if (jsonObject.containsKey("registration_client_uri")) {
View Full Code Here

    } catch (MalformedURLException e) {

      throw new SerializeException(e.getMessage(), e);
    }

    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, url);
    httpRequest.setContentType(CommonContentTypes.APPLICATION_URLENCODED);

    if (getClientAuthentication() != null) {
      getClientAuthentication().applyTo(httpRequest);
    }

    Map<String,String> params = httpRequest.getQueryParameters();

    params.putAll(authzGrant.toParameters());

    if (scope != null && ! scope.isEmpty()) {
      params.put("scope", scope.toString());
    }

    if (clientID != null) {
      params.put("client_id", clientID.getValue());
    }

    httpRequest.setQuery(URLUtils.serializeParameters(params));

    return httpRequest;
  }
View Full Code Here

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

    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("access_token", httpRequest.getQueryParameters().get("token_type_hint"));
    assertEquals(2, httpRequest.getQueryParameters().size());

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

    throws SerializeException {
   
    if (getEndpointURI() == null)
      throw new SerializeException("The endpoint URI is not specified");
   
    HTTPRequest httpRequest;

    URL endpointURL;

    try {
      endpointURL = getEndpointURI().toURL();

    } catch (MalformedURLException e) {

      throw new SerializeException(e.getMessage(), e);
    }
   
    if (method.equals(HTTPRequest.Method.GET)) {

      httpRequest = new HTTPRequest(HTTPRequest.Method.GET, endpointURL);

    } else if (method.equals(HTTPRequest.Method.POST)) {

      httpRequest = new HTTPRequest(HTTPRequest.Method.POST, endpointURL);

    } else {

      throw new IllegalArgumentException("The HTTP request method must be GET or POST");
    }
   
    httpRequest.setQuery(toQueryString());
   
    return httpRequest;
  }
View Full Code Here

    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

    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());
    assertEquals("secret", basicAuth.getClientSecret().getValue());
  }
View Full Code Here


  public void testWithUnknownToken()
    throws Exception {

    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, new URL("https://c2id.com/token/revoke"));
    httpRequest.setContentType(CommonContentTypes.APPLICATION_URLENCODED);

    Map<String,String> queryParams = new HashMap<>();
    queryParams.put("token", "abc");
    httpRequest.setQuery(URLUtils.serializeParameters(queryParams));

    TokenRevocationRequest request = TokenRevocationRequest.parse(httpRequest);
    assertEquals("abc", request.getToken().getValue());
    assertFalse(request.getToken() instanceof AccessToken);
    assertFalse(request.getToken() instanceof RefreshToken);
View Full Code Here

    URI uri = resp.toURI();

    System.out.println("Location: " + uri);

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

    resp = AuthorizationSuccessResponse.parse(httpResponse);

    assertEquals(ABS_REDIRECT_URI, resp.getRedirectionURI());
    assertEquals(TOKEN, resp.getAccessToken());
View Full Code Here

TOP

Related Classes of com.nimbusds.oauth2.sdk.auth.Secret

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.