Project

General

Profile

Download (1.01 KB) 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.vaadin.permission;
10

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

    
13
import eu.etaxonomy.cdm.api.utility.RoleProbe;
14

    
15
/**
16
 * @author a.kohlbecker
17
 * @since Jul 16, 2018
18
 *
19
 */
20
public class RegistrationCuratorRoleProbe implements RoleProbe {
21

    
22
    @Override
23
    public boolean checkForRole(Authentication authentication){
24

    
25
        if(authentication != null) {
26
            return authentication.getAuthorities().stream().anyMatch(a -> {
27
                return a.equals(RolesAndPermissions.ROLE_CURATION)
28
                        // doing faster regex check here instreas of using CdmAuthoritiy.fromString()
29
                        || a.getAuthority().matches("^Registration\\.\\[.*UPDATE");
30
            });
31
        }
32
        return false;
33
    }
34

    
35
}
(6-6/8)