ref #7099 rename model.rights to model.permission
[cdmlib.git] / cdmlib-persistence / src / test / java / eu / etaxonomy / cdm / persistence / hibenate / permission / AbstractCdmPermissionVoterTest.java
1 /**
2 * Copyright (C) 2017 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.persistence.hibenate.permission;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 import org.junit.Assert;
15 import org.springframework.security.authentication.TestingAuthenticationToken;
16 import org.springframework.security.core.Authentication;
17 import org.springframework.security.core.GrantedAuthority;
18
19 import eu.etaxonomy.cdm.model.permission.User;
20 import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
21
22 /**
23 * @author a.kohlbecker
24 * @since Feb 2, 2017
25 *
26 */
27 abstract public class AbstractCdmPermissionVoterTest extends Assert {
28
29 /**
30 * @param e
31 * @return
32 */
33 protected Authentication authentication(CdmAuthority ... authorities) {
34
35 List<GrantedAuthority> ga = new ArrayList<>();
36
37 for(CdmAuthority a : authorities){
38 ga.add(a);
39 }
40
41 Authentication auth = new TestingAuthenticationToken(
42 User.NewInstance("Tester", "secret"),
43 null,
44 ga);
45 return auth;
46 }
47
48 }