Examples of InvalidClientException


Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

  protected void validateGrantType(String grantType, ClientDetails clientDetails) {
    Collection<String> authorizedGrantTypes = clientDetails.getAuthorizedGrantTypes();
    if (authorizedGrantTypes != null && !authorizedGrantTypes.isEmpty()
        && !authorizedGrantTypes.contains(grantType)) {
      throw new InvalidClientException("Unauthorized grant type: " + grantType);
    }
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

    if (!responseTypes.contains("token") && !responseTypes.contains("code")) {
      throw new UnsupportedResponseTypeException("Unsupported response types: " + responseTypes);
    }

    if (authorizationRequest.getClientId() == null) {
      throw new InvalidClientException("A client id must be provided");
    }

    try {

      if (!(principal instanceof Authentication) || !((Authentication) principal).isAuthenticated()) {
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

    converter = new JaxbOAuth2ExceptionMessageConverter();
  }

  @Test
  public void writeInvalidClient() throws IOException {
    OAuth2Exception oauthException = new InvalidClientException(DETAILS);
    String expected = createResponse(oauthException.getOAuth2ErrorCode());
    converter.write(oauthException, contentType, outputMessage);
    assertEquals(expected, getOutput());
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

  @Test
  public void readInvalidClient() throws IOException {
    String accessToken = createResponse(OAuth2Exception.INVALID_CLIENT);
    when(inputMessage.getBody()).thenReturn(createInputStream(accessToken));
    @SuppressWarnings("unused")
    InvalidClientException result = (InvalidClientException) converter.read(InvalidClientException.class,
        inputMessage);
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

    assertTrue("Wrong token: " + result, result.contains("\"expires_in\":"));
  }

  @Test
  public void testExceptionSerialization() throws Exception {
    InvalidClientException exception = new InvalidClientException("FOO");
    exception.addAdditionalInformation("foo", "bar");
    String result = new ObjectMapper().writeValueAsString(exception);
    // System.err.println(result);
    assertTrue("Wrong result: "+result, result.contains("\"error\":\"invalid_client\""));
    assertTrue("Wrong result: "+result, result.contains("\"error_description\":\"FOO\""));
    assertTrue("Wrong result: "+result, result.contains("\"foo\":\"bar\""));
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

  }

  @Test
  public void readValueInvalidClient() throws Exception {
    String accessToken = createResponse(OAuth2Exception.INVALID_CLIENT);
    InvalidClientException result = (InvalidClientException) mapper.readValue(accessToken, OAuth2Exception.class);
    assertEquals(DETAILS,result.getMessage());
    assertEquals(null,result.getAdditionalInformation());
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

  }

  @Test
  public void readValueWithAdditionalDetails() throws Exception {
    String accessToken = "{\"error\": \"invalid_client\", \"error_description\": \"some detail\", \"foo\": \"bar\"}";
    InvalidClientException result = (InvalidClientException) mapper.readValue(accessToken, OAuth2Exception.class);
    assertEquals(DETAILS,result.getMessage());
    assertEquals("{foo=bar}",result.getAdditionalInformation().toString());
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

  }

  @Test
  public void testCommenceWithOAuth2Exception() throws Exception {
    request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE);
    entryPoint.commence(request, response, new BadCredentialsException("Bad", new InvalidClientException(
        "Bad client")));
    assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getStatus());
    assertEquals("{\"error\":\"invalid_client\",\"error_description\":\"Bad client\"}", response.getContentAsString());
    assertEquals(MediaType.APPLICATION_JSON_VALUE, response.getContentType());
    assertEquals(null, response.getErrorMessage());
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

    oauthException = null;
  }

  @Test
  public void writeValueAsStringInvalidClient() throws Exception {
    oauthException = new InvalidClientException(DETAILS);
    String expected = createResponse(oauthException.getOAuth2ErrorCode());
    assertEquals(expected,mapper.writeValueAsString(oauthException));
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidClientException

    assertEquals(expected,mapper.writeValueAsString(oauthException));
  }

  @Test
  public void writeValueAsStringWithAdditionalDetails() throws Exception {
    oauthException = new InvalidClientException(DETAILS);
    oauthException.addAdditionalInformation("foo", "bar");
    String expected = "{\"error\":\"invalid_client\",\"error_description\":\"some detail\",\"foo\":\"bar\"}";
    assertEquals(expected,mapper.writeValueAsString(oauthException));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.