Example usage for org.springframework.security.access PermissionEvaluator hasPermission

List of usage examples for org.springframework.security.access PermissionEvaluator hasPermission

Introduction

In this page you can find the example usage for org.springframework.security.access PermissionEvaluator hasPermission.

Prototype

boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
        Object permission);

Source Link

Document

Alternative method for evaluating a permission where only the identifier of the target object is available, rather than the target instance itself.

Usage

From source file:org.collectionspace.services.authorization.spring.SpringPermissionEvaluator.java

@Override
public boolean hasPermission(CSpaceResource res, CSpaceAction action) {
    Permission perm = SpringAuthorizationProvider.getPermission(action);
    Authentication authToken = SecurityContextHolder.getContext().getAuthentication();
    Serializable objectIdId = SpringAuthorizationProvider.getObjectIdentityIdentifier(res);
    String objectIdType = SpringAuthorizationProvider.getObjectIdentityType(res);
    PermissionEvaluator eval = provider.getProviderPermissionEvaluator();

    debug(res, authToken, objectIdId, objectIdType, perm);
    return eval.hasPermission(authToken, objectIdId, objectIdType, perm);
}