Project

General

Profile

Download (900 Bytes) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.util;
10

    
11
import org.springframework.security.core.Authentication;
12

    
13
import eu.etaxonomy.cdm.persistence.permission.Role;
14

    
15
/**
16
 * @author a.kohlbecker
17
 * @since Jul 25, 2018
18
 */
19
public class RoleProberImpl implements IRoleProber {
20

    
21
    private Role role;
22

    
23
    public RoleProberImpl(Role role){
24
        this.role = role;
25
    }
26

    
27
    @Override
28
    public boolean checkForRole(Authentication authentication) {
29
        if(authentication != null) {
30
            return authentication.getAuthorities().stream().anyMatch(a -> {
31
                return a.equals(role);
32
            });
33
        }
34
        return false;
35
    }
36
}
(11-11/15)