Package com.nimbusds.oauth2.sdk.token

Examples of com.nimbusds.oauth2.sdk.token.BearerAccessToken


    throws ParseException {
   
    final String clientAssertion = params.get("client_assertion");
   
    if (clientAssertion == null)
      throw new ParseException("Missing \"client_assertion\" parameter");
   
    try {
      return SignedJWT.parse(clientAssertion);
     
    } catch (java.text.ParseException e) {
   
      throw new ParseException("Invalid \"client_assertion\" JWT: " + e.getMessage(), e);
    }
  }
View Full Code Here


    httpRequest.ensureContentType(CommonContentTypes.APPLICATION_URLENCODED);
   
    String query = httpRequest.getQuery();
   
    if (query == null)
      throw new ParseException("Missing HTTP POST request entity body");
   
    Map<String,String> params = URLUtils.parseParameters(query);
   
    JWSAlgorithm alg = parseClientAssertion(params).getHeader().getAlgorithm();
     
    if (ClientSecretJWT.getSupportedJWAs().contains(alg))
      return ClientSecretJWT.parse(params);
       
    else if (PrivateKeyJWT.getSupportedJWAs().contains(alg))
      return PrivateKeyJWT.parse(params);
     
    else
      throw new ParseException("Unsupported signed JWT algorithm: " + alg);
  }
View Full Code Here

    throws ParseException {
   
    String[] parts = header.split("\\s");
   
    if (parts.length != 2)
      throw new ParseException("Unexpected number of HTTP Authorization header value parts: " + parts.length);
   
    if (! parts[0].equalsIgnoreCase("Basic"))
      throw new ParseException("HTTP authentication must be \"Basic\"");
   
    String credentialsString = new String(Base64.decodeBase64(parts[1]), UTF8_CHARSET);

    String[] credentials = credentialsString.split(":", 2);
   
    if (credentials.length != 2)
      throw new ParseException("Missing credentials delimiter \":\"");

    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

    throws ParseException {
   
    String header = httpRequest.getAuthorization();
   
    if (header == null)
      throw new ParseException("Missing HTTP Authorization header");
     
    return parse(header);
  }
View Full Code Here

    try {
      o = new JSONParser(JSONParser.USE_HI_PRECISION_FLOAT).parse(s);
     
    } catch (net.minidev.json.parser.ParseException e) {
     
      throw new ParseException("Invalid JSON: " + e.getMessage(), e);
    }
   
    if (o instanceof JSONObject)
      return (JSONObject)o;
    else
      throw new ParseException("JSON entity is not an object");
  }
View Full Code Here

      if (this.statusCode == c)
        return;
    }

    throw new ParseException("Unexpected HTTP status code " +
      this.statusCode +
      ", must be "
      Arrays.toString(expectedStatusCode));
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public static <T> T getGeneric(final JSONObject o, final String key, final Class<T> clazz)
    throws ParseException {
 
    if (! o.containsKey(key))
      throw new ParseException("Missing JSON object member with key \"" + key + "\"");
   
    if (o.get(key) == null)
      throw new ParseException("JSON object member with key \"" + key + "\" has null value");
   
    Object value = o.get(key);
   
    if (! clazz.isAssignableFrom(value.getClass()))
      throw new ParseException("Unexpected type of JSON object member with key \"" + key + "\"");
   
    return (T)value;
  }
View Full Code Here

   */
  public void ensureStatusCodeNotOK()
    throws ParseException {

    if (statusCode == SC_OK)
      throw new ParseException("Unexpected HTTP status code, must not be 200 (OK)");
  }
View Full Code Here

  public void testParseError()
    throws Exception {

    URI redirectURI = new URI("https://example.com/in");
    ResponseType rt = new ResponseType(ResponseType.Value.CODE);
    State state = new State("xyz");

    AuthenticationErrorResponse errorResponse = new AuthenticationErrorResponse(redirectURI, OAuth2Error.ACCESS_DENIED, rt, state);

    HTTPResponse httpResponse = errorResponse.toHTTPResponse();
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

TOP

Related Classes of com.nimbusds.oauth2.sdk.token.BearerAccessToken

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.