Example usage for org.springframework.security.oauth2.common.exceptions RedirectMismatchException getHttpErrorCode

List of usage examples for org.springframework.security.oauth2.common.exceptions RedirectMismatchException getHttpErrorCode

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.common.exceptions RedirectMismatchException getHttpErrorCode.

Prototype

@Override
    public int getHttpErrorCode() 

Source Link

Usage

From source file:sparklr.common.AbstractAuthorizationCodeProviderTests.java

@Test
@OAuth2ContextConfiguration(resource = MyClientWithRegisteredRedirect.class, initialize = false)
public void testRegisteredRedirectWithWrongOneInTokenEndpoint() throws Exception {
    approveAccessTokenGrant("http://anywhere?key=value", true);
    // Setting the redirect uri directly in the request should override the saved value
    context.getAccessTokenRequest().set("redirect_uri", "http://nowhere.com");
    try {// ww  w .  j ava  2 s . co  m
        assertNotNull(context.getAccessToken());
        fail("Expected RedirectMismatchException");
    } catch (RedirectMismatchException e) {
        assertEquals(HttpStatus.BAD_REQUEST.value(), e.getHttpErrorCode());
        assertEquals("invalid_grant", e.getOAuth2ErrorCode());
    }
}