Package com.nimbusds.oauth2.sdk.id

Examples of com.nimbusds.oauth2.sdk.id.ClientID


    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

  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

    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

TOP

Related Classes of com.nimbusds.oauth2.sdk.id.ClientID

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.