Example usage for org.springframework.security.oauth2.common.exceptions OAuth2Exception INVALID_GRANT

List of usage examples for org.springframework.security.oauth2.common.exceptions OAuth2Exception INVALID_GRANT

Introduction

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

Prototype

String INVALID_GRANT

To view the source code for org.springframework.security.oauth2.common.exceptions OAuth2Exception INVALID_GRANT.

Click Source Link

Usage

From source file:org.springframework.security.oauth2.common.exception.OAuth2ExceptionJackson2DeserializerTests.java

@Test
public void readValueInvalidGrant() throws Exception {
    String accessToken = createResponse(OAuth2Exception.INVALID_GRANT);
    InvalidGrantException result = (InvalidGrantException) mapper.readValue(accessToken, OAuth2Exception.class);
    assertEquals(DETAILS, result.getMessage());
    assertEquals(null, result.getAdditionalInformation());
}

From source file:org.springframework.security.oauth2.common.exception.OAuth2ExceptionJackson2DeserializerTests.java

@Test
public void readValueRedirectUriMismatch() throws Exception {
    String accessToken = createResponse(OAuth2Exception.INVALID_GRANT, "Redirect URI mismatch.");
    RedirectMismatchException result = (RedirectMismatchException) mapper.readValue(accessToken,
            OAuth2Exception.class);
    assertEquals("Redirect URI mismatch.", result.getMessage());
    assertEquals(null, result.getAdditionalInformation());
}

From source file:org.cloudfoundry.identity.uaa.oauth.UaaAuthorizationEndpoint.java

private OAuth2AccessToken getAccessTokenForImplicitGrantOrHybrid(TokenRequest tokenRequest,
        OAuth2Request storedOAuth2Request, String grantType) throws OAuth2Exception {
    // These 1 method calls have to be atomic, otherwise the ImplicitGrantService can have a race condition where
    // one thread removes the token request before another has a chance to redeem it.
    synchronized (this.implicitLock) {
        switch (grantType) {
        case GRANT_TYPE_IMPLICIT:
            return getTokenGranter().grant(grantType,
                    new ImplicitTokenRequest(tokenRequest, storedOAuth2Request));
        case GRANT_TYPE_AUTHORIZATION_CODE:
            return getHybridTokenGranterForAuthCode().grant(grantType,
                    new ImplicitTokenRequest(tokenRequest, storedOAuth2Request));
        default://from  ww  w. j  av a 2  s. com
            throw new OAuth2Exception(OAuth2Exception.INVALID_GRANT);
        }
    }
}