Package com.nimbusds.oauth2.sdk.auth

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


    try {
      params.put("client_assertion", clientAssertion.serialize());
   
    } catch (IllegalStateException e) {
   
      throw new SerializeException("Couldn't serialize JWT to a client assertion string: " + e.getMessage(), e);
   
   
    params.put("client_assertion_type", CLIENT_ASSERTION_TYPE);
   
    return params;
View Full Code Here


  @Override
  public void applyTo(final HTTPRequest httpRequest)
    throws SerializeException {
   
    if (httpRequest.getMethod() != HTTPRequest.Method.POST)
      throw new SerializeException("The HTTP request method must be POST");
   
    ContentType ct = httpRequest.getContentType();
   
    if (ct == null)
      throw new SerializeException("Missing HTTP Content-Type header");
   
    if (! ct.match(CommonContentTypes.APPLICATION_URLENCODED))
      throw new SerializeException("The HTTP Content-Type header must be " + CommonContentTypes.APPLICATION_URLENCODED);
   
    Map <String,String> params = httpRequest.getQueryParameters();
   
    params.putAll(toParameters());
   
View Full Code Here

    httpRequest.ensureMethod(HTTPRequest.Method.POST);
    httpRequest.ensureContentType(CommonContentTypes.APPLICATION_URLENCODED);

    // Parse client authentication, if any
    ClientAuthentication clientAuth = ClientAuthentication.parse(httpRequest);

    // No fragment! May use query component!
    Map<String,String> params = httpRequest.getQueryParameters();

    // Parse grant
View Full Code Here

  public void testWithAccessTokenAndClientAuth()
    throws Exception {

    URI endpointURI = new URI("https://c2id.com/token/revoke");
    Token token = new BearerAccessToken();
    ClientAuthentication clientAuth = new ClientSecretBasic(new ClientID("123"), new Secret("secret"));

    TokenRevocationRequest request = new TokenRevocationRequest(endpointURI, clientAuth, token);
    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(clientAuth, request.getClientAuthentication());
    assertEquals(token, request.getToken());
View Full Code Here

  public void testWithRefreshTokenAndClientAuth()
    throws Exception {

    URI endpointURI = new URI("https://c2id.com/token/revoke");
    Token token = new RefreshToken();
    ClientAuthentication clientAuth = new ClientSecretBasic(new ClientID("123"), new Secret("secret"));

    TokenRevocationRequest request = new TokenRevocationRequest(endpointURI, clientAuth, token);
    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(clientAuth, request.getClientAuthentication());
    assertEquals(token, request.getToken());
View Full Code Here

  public void testWithAccessTokenAndClientAuth()
    throws Exception {

    URI endpointURI = new URI("https://c2id.com/token/revoke");
    Token token = new BearerAccessToken();
    ClientAuthentication clientAuth = new ClientSecretBasic(new ClientID("123"), new Secret("secret"));

    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

  public void testWithRefreshTokenAndClientAuth()
    throws Exception {

    URI endpointURI = new URI("https://c2id.com/token/revoke");
    Token token = new RefreshToken();
    ClientAuthentication clientAuth = new ClientSecretBasic(new ClientID("123"), new Secret("secret"));

    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 testWithAccessTokenAndClientAuth()
    throws Exception {

    URI endpointURI = new URI("https://c2id.com/token/revoke");
    Token token = new BearerAccessToken();
    ClientAuthentication clientAuth = new ClientSecretBasic(new ClientID("123"), new Secret("secret"));

    TokenRevocationRequest request = new TokenRevocationRequest(endpointURI, clientAuth, token);
    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(clientAuth, request.getClientAuthentication());
    assertEquals(token, request.getToken());
View Full Code Here

  public void testWithRefreshTokenAndClientAuth()
    throws Exception {

    URI endpointURI = new URI("https://c2id.com/token/revoke");
    Token token = new RefreshToken();
    ClientAuthentication clientAuth = new ClientSecretBasic(new ClientID("123"), new Secret("secret"));

    TokenRevocationRequest request = new TokenRevocationRequest(endpointURI, clientAuth, token);
    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(clientAuth, request.getClientAuthentication());
    assertEquals(token, request.getToken());
View Full Code Here

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

    ClientMetadata metadata = ClientMetadata.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")) {

        final long t = JSONObjectUtils.getLong(jsonObject, "client_secret_expires_at");

        if (t > 0) {
          exp = new Date(t * 1000);
        }
      }

      secret = new Secret(value, exp);
    }

    URI registrationURI = null;

    if (jsonObject.containsKey("registration_client_uri")) {
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.