Package com.nimbusds.oauth2.sdk.auth

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


  public void testParseSuccess()
    throws Exception {

    URI redirectURI = new URI("https://example.com/in");
    AuthorizationCode code = new AuthorizationCode("123");
    State state = new State("xyz");

    AuthenticationSuccessResponse successResponse = new AuthenticationSuccessResponse(redirectURI, code, null, null, state);

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


    } 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

    throws ParseException {
 
    String clientIDString = params.get("client_id");
   
    if (clientIDString == null)
      throw new ParseException("Missing \"client_id\" parameter");
   
    String secretValue = params.get("client_secret");
   
    if (secretValue == null)
      throw new ParseException("Missing \"client_secret\" parameter");
   
    return new ClientSecretPost(new ClientID(clientIDString), new Secret(secretValue));
  }
View Full Code Here

    try {
      privateKeyJWT = new PrivateKeyJWT(clientAssertion);

    }catch (IllegalArgumentException e) {

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

    // Check that the top level client_id matches the assertion subject + issuer

    ClientID clientID = JWTAuthentication.parseClientID(params);

    if (clientID != null) {

      if (! clientID.equals(privateKeyJWT.getClientID()))
        throw new ParseException("The client identifier doesn't match the client assertion subject / issuer");
    }

    return privateKeyJWT;
  }
View Full Code Here

    try {
      clientSecretJWT = new ClientSecretJWT(clientAssertion);

    } catch (IllegalArgumentException e) {

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

    // Check that the top level client_id matches the assertion subject + issuer
   
    ClientID clientID = JWTAuthentication.parseClientID(params);

    if (clientID != null) {

      if (! clientID.equals(clientSecretJWT.getClientID()))
        throw new ParseException("The client identifier doesn't match the client assertion subject / issuer");
    }

    return clientSecretJWT;
  }
View Full Code Here

   */
  public void ensureMethod(final Method expectedMethod)
    throws ParseException {
   
    if (method != expectedMethod)
      throw new ParseException("The HTTP request method must be " + expectedMethod);
  }
View Full Code Here

   */
  private void ensureQuery()
    throws ParseException {
   
    if (query == null || query.trim().isEmpty())
      throw new ParseException("Missing or empty HTTP query string / entity body");
  }
View Full Code Here

    try {
      contentType = new ContentType(ct);
     
    } catch (javax.mail.internet.ParseException e) {
   
      throw new ParseException("Invalid Content-Type value: " + e.getMessage());
    }
  }
View Full Code Here

   */
  public void ensureContentType()
    throws ParseException {
 
    if (contentType == null)
      throw new ParseException("Missing HTTP Content-Type header");
  }
View Full Code Here

    throws ParseException {
   
    final String clientAssertionType = params.get("client_assertion_type");
   
    if (clientAssertionType == null)
      throw new ParseException("Missing \"client_assertion_type\" parameter");
   
    if (! clientAssertionType.equals(CLIENT_ASSERTION_TYPE))
      throw new ParseException("Invalid \"client_assertion_type\" parameter, must be " + CLIENT_ASSERTION_TYPE);
  }
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.