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

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

Introduction

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

Prototype

public String getSummary() 

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 w  w w  . jav a2 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;
    }
}