Example usage for org.springframework.security.oauth2.client.resource OAuth2AccessDeniedException getHttpErrorCode

List of usage examples for org.springframework.security.oauth2.client.resource OAuth2AccessDeniedException getHttpErrorCode

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.client.resource OAuth2AccessDeniedException getHttpErrorCode.

Prototype

@Override
    public int getHttpErrorCode() 

Source Link

Usage

From source file:org.cloudfoundry.client.lib.oauth2.OauthClient.java

private OAuth2AccessToken createToken(String username, String password, String clientId, String clientSecret) {
    OAuth2ProtectedResourceDetails resource = getResourceDetails(username, password, clientId, clientSecret);
    AccessTokenRequest request = createAccessTokenRequest(username, password);

    ResourceOwnerPasswordAccessTokenProvider provider = createResourceOwnerPasswordAccessTokenProvider();
    try {/*from ww  w  .j  a  va  2 s  . c  o  m*/
        return provider.obtainAccessToken(resource, request);
    } catch (OAuth2AccessDeniedException oauthEx) {
        HttpStatus status = HttpStatus.valueOf(oauthEx.getHttpErrorCode());
        CloudFoundryException cfEx = new CloudFoundryException(status, oauthEx.getMessage());
        cfEx.setDescription(oauthEx.getSummary());
        throw cfEx;
    }
}