Package com.nimbusds.oauth2.sdk.auth

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


    try {
      String decodedClientID = URLDecoder.decode(credentials[0], UTF8_CHARSET.name());
      String decodedSecret = URLDecoder.decode(credentials[1], UTF8_CHARSET.name());

      return new ClientSecretBasic(new ClientID(decodedClientID), new Secret(decodedSecret));
     
    } catch (UnsupportedEncodingException e) {
   
      throw new ParseException(e.getMessage(), e);
    }
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

   *                        client information instance.
   */
  public static ClientInformation parse(final JSONObject jsonObject)
    throws ParseException {

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

    Date issueDate = null;

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

View Full Code Here

    AuthenticationRequest authRequest = new AuthenticationRequest(
      new URI("https://c2id.com/login"),
      ResponseType.parse("code"),
      Scope.parse("openid email"),
      new ClientID("123"),
      new URI("https://client.com/cb"),
      new State(),
      new Nonce());

    ClaimsRequest claimsRequest = ClaimsRequest.resolve(authRequest);
View Full Code Here

            final JWTID jti) {

    if (clientID == null)
      throw new IllegalArgumentException("The client ID must not be null");

    iss = new Issuer(clientID.getValue());

    sub = new Subject(clientID.getValue());

   
    if (aud == null)
View Full Code Here

   */
  public static JWTAuthenticationClaimsSet parse(final JSONObject jsonObject)
    throws ParseException {
   
    // 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"));


    // Parse optional claims

    Date nbf = null;

    if (jsonObject.containsKey("nbf"))
      nbf = DateUtils.fromSecondsSinceEpoch(JSONObjectUtils.getLong(jsonObject, "nbf"));

    Date iat = null;

    if (jsonObject.containsKey("iat"))
      iat = DateUtils.fromSecondsSinceEpoch(JSONObjectUtils.getLong(jsonObject, "iat"));

    JWTID jti = null;

    if (jsonObject.containsKey("jti"))
      jti = new JWTID(JSONObjectUtils.getString(jsonObject, "jti"));


    // Check client ID

    if (! iss.getValue().equals(sub.getValue()))
      throw new ParseException("JWT issuer and subject must have the same client ID");

    ClientID clientID = new ClientID(iss.getValue());

    return new JWTAuthenticationClaimsSet(clientID, aud, exp, nbf, iat, jti);
  }
View Full Code Here

    Date iat = null;

    if (jsonObject.containsKey("iat"))
      iat = DateUtils.fromSecondsSinceEpoch(JSONObjectUtils.getLong(jsonObject, "iat"));

    JWTID jti = null;

    if (jsonObject.containsKey("jti"))
      jti = new JWTID(JSONObjectUtils.getString(jsonObject, "jti"));


    // Check client ID

    if (! iss.getValue().equals(sub.getValue()))
View Full Code Here

    throws Exception {

    AuthorizationCode code = new AuthorizationCode();

    AuthenticationSuccessResponse response = new AuthenticationSuccessResponse(
      REDIRECT_URI, code, null, null, new State("abc"));

    assertEquals(REDIRECT_URI, response.getRedirectionURI());
    assertNull(response.getIDToken());
    assertEquals(code, response.getAuthorizationCode());
    assertNull(response.getAccessToken());
View Full Code Here

    ResponseType responseType = resp.impliedResponseType();
    assertTrue(new ResponseType("code").equals(responseType));

    Map<String,String> params = resp.toParameters();
    assertEquals(CODE, new AuthorizationCode(params.get("code")));
    assertEquals(STATE, new State(params.get("state")));
    assertEquals(2, params.size());

    URI uri = resp.toURI();

    HTTPResponse httpResponse = resp.toHTTPResponse();
View Full Code Here

TOP

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

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.