Example usage for org.springframework.security.oauth2.provider.expression OAuth2ExpressionUtils hasAnyScope

List of usage examples for org.springframework.security.oauth2.provider.expression OAuth2ExpressionUtils hasAnyScope

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.provider.expression OAuth2ExpressionUtils hasAnyScope.

Prototype

public static boolean hasAnyScope(Authentication authentication, String[] scopes) 

Source Link

Usage

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

@RequestMapping(value = "/oauth/token/list/user/{userId}", method = GET)
public ResponseEntity<List<RevocableToken>> listUserTokens(@PathVariable String userId,
        OAuth2Authentication authentication) {
    if (OAuth2ExpressionUtils.hasAnyScope(authentication, new String[] { "tokens.list", "uaa.admin" })) {
        logger.debug("Listing revocable tokens for user:" + userId);
        List<RevocableToken> result = tokenProvisioning.getUserTokens(userId);
        removeTokenValues(result);/*from   w w w  . j  av  a2  s  .c  om*/
        return new ResponseEntity<>(result, OK);
    } else {
        return listUserTokens(authentication);
    }
}

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

@RequestMapping(value = "/oauth/token/list/client/{clientId}", method = GET)
public ResponseEntity<List<RevocableToken>> listClientTokens(@PathVariable String clientId,
        OAuth2Authentication authentication) {
    if (OAuth2ExpressionUtils.hasAnyScope(authentication, new String[] { "tokens.list", "uaa.admin" })) {
        logger.debug("Listing revocable tokens for client:" + clientId);
        List<RevocableToken> result = tokenProvisioning.getClientTokens(clientId);
        removeTokenValues(result);/*from  www . j a v a 2s  .  c  om*/
        return new ResponseEntity<>(result, OK);
    } else {
        return listUserTokens(authentication);
    }
}