Example usage for org.springframework.security.oauth.provider BaseConsumerDetails setAuthorities

List of usage examples for org.springframework.security.oauth.provider BaseConsumerDetails setAuthorities

Introduction

In this page you can find the example usage for org.springframework.security.oauth.provider BaseConsumerDetails setAuthorities.

Prototype

public void setAuthorities(List<GrantedAuthority> authorities) 

Source Link

Document

The base authorities for this consumer.

Usage

From source file:org.eurekastreams.server.service.security.oauth.ConsumerDetailsServiceImpl.java

/**
 * {@inheritDoc}/*from www  . ja  va  2  s.co m*/
 */
@Override
public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException {
    try {
        ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null);
        OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext,
                getOAuthConsumerByConsumerKeyAction);

        BaseConsumerDetails details = new BaseConsumerDetails();
        details.setConsumerKey(inConsumerKey);
        details.setConsumerName(inConsumerKey);
        details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret));
        details.setAuthorities(grantedAuthorities);

        // NOTE: This line supports OAuth 2-legged only!
        details.setRequiredToObtainAuthenticatedToken(false);

        return details;
    } catch (Exception ex) {
        log.error("Error occurred retrieving consumer with provided key.", ex);
        throw new OAuthException("Unable to retrieve consumer with provided information.");
    }
}