Example usage for org.springframework.security.oauth.provider.token OAuthProviderToken getConsumerKey

List of usage examples for org.springframework.security.oauth.provider.token OAuthProviderToken getConsumerKey

Introduction

In this page you can find the example usage for org.springframework.security.oauth.provider.token OAuthProviderToken getConsumerKey.

Prototype

String getConsumerKey();

Source Link

Document

The consumer key associated with this oauth token.

Usage

From source file:nl.surfnet.coin.api.controller.Oauth1AccessConfirmationController.java

@RequestMapping("/oauth1/confirm_access")
public ModelAndView getAccessConfirmation(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String token = request.getParameter("oauth_token");
    if (token == null) {
        throw new IllegalArgumentException("A request token to authorize must be provided.");
    }/*from   w  ww  .  j  ava  2 s  .  co m*/

    OAuthProviderToken providerToken = tokenServices.getToken(token);
    ConsumerDetails client = clientDetailsService.loadConsumerByConsumerKey(providerToken.getConsumerKey());

    String callback = request.getParameter("oauth_callback");
    TreeMap<String, Object> model = new TreeMap<String, Object>();
    model.put("oauth_token", token);
    if (callback != null) {
        model.put("oauth_callback", callback);
    }
    model.put("client", client);
    model.put("locale", RequestContextUtils.getLocale(request).toString());
    model.put("staticContentBasePath", staticContentBasePath);
    Map<String, String> languageLinks = new HashMap<String, String>();
    languageLinks.put("en", getUrlWithLanguageParam(request, "en"));
    languageLinks.put("nl", getUrlWithLanguageParam(request, "nl"));
    model.put("languageLinks", languageLinks);

    if (client instanceof OpenConextConsumerDetails) {
        ClientMetaData clientMetaData = ((OpenConextConsumerDetails) client).getClientMetaData();
        if (!clientMetaData.isConsentRequired()) {
            /*
             * We skip the consent screen, but to ensure that we hit all the filters and keep
             * the user flow intact we have implemented this using a javascript POST
             */
            return new ModelAndView("access_confirmation_oauth1_skip_consent", model);
        }
    }

    return new ModelAndView("access_confirmation_oauth1", model);
}