Package com.nimbusds.oauth2.sdk

Examples of com.nimbusds.oauth2.sdk.ErrorObject


  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


  public static ClientRegistrationErrorResponse parse(final HTTPResponse httpResponse)
    throws ParseException {
   
    httpResponse.ensureStatusCodeNotOK();

    ErrorObject error;

    String wwwAuth = httpResponse.getWWWAuthenticate();
   
    if (StringUtils.isNotBlank(wwwAuth)) {

      error = BearerTokenError.parse(wwwAuth);

    } else {
     
      String code = null;
      String description = null;
     
      if (CommonContentTypes.APPLICATION_JSON.match(httpResponse.getContentType())) {
       
        JSONObject jsonObject = httpResponse.getContentAsJSONObject();

        code = JSONObjectUtils.getString(jsonObject, "error");

        if (jsonObject.containsKey("error_description"))
          description = JSONObjectUtils.getString(jsonObject, "error_description");
      }
     
      error = new ErrorObject(code, description, httpResponse.getStatusCode());
    }

    return new ClientRegistrationErrorResponse(error);
  }
View Full Code Here

  public void testCodeErrorResponse()
    throws Exception {

    URI redirectURI = new URI("https://client.com/cb");
    ErrorObject error = OAuth2Error.ACCESS_DENIED;
    ResponseType responseType = new ResponseType("code");
    State state = new State("123");

    AuthenticationErrorResponse response = new AuthenticationErrorResponse(
      redirectURI, error, responseType, state);
View Full Code Here

  public void testIDTokenErrorResponse()
    throws Exception {

    URI redirectURI = new URI("https://client.com/cb");
    ErrorObject error = OAuth2Error.ACCESS_DENIED;
    ResponseType responseType = new ResponseType("id_token");
    State state = new State("123");

    AuthenticationErrorResponse response = new AuthenticationErrorResponse(
      redirectURI, error, responseType, state);
View Full Code Here

     
    } catch (ResolveException e) {
     
      // Repackage exception with redirection URI, state, error object
     
      ErrorObject err;
     
      if (request.getRequestURI() != null)
        err = OIDCError.INVALID_REQUEST_URI;
      else
        err = OIDCError.INVALID_REQUEST_OBJECT;
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

TOP

Related Classes of com.nimbusds.oauth2.sdk.ErrorObject

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.