View Javadoc

1   /*
2    * Copyright 2015 Data Archiving and Networked Services (an institute of
3    * Koninklijke Nederlandse Akademie van Wetenschappen), King's College London,
4    * Georg-August-Universitaet Goettingen Stiftung Oeffentlichen Rechts
5    *
6    * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by
7    * the European Commission - subsequent versions of the EUPL (the "Licence");
8    * You may not use this work except in compliance with the Licence.
9    * You may obtain a copy of the Licence at:
10   *
11   * https://joinup.ec.europa.eu/software/page/eupl
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the Licence is distributed on an "AS IS" basis,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the Licence for the specific language governing
17   * permissions and limitations under the Licence.
18   */
19  
20  package eu.ehri.project.acl;
21  
22  import com.tinkerpop.blueprints.Vertex;
23  import eu.ehri.project.definitions.Entities;
24  import eu.ehri.project.models.Group;
25  import eu.ehri.project.models.PermissionGrant;
26  import eu.ehri.project.models.base.Accessor;
27  import eu.ehri.project.models.base.Entity;
28  
29  import java.util.Collections;
30  
31  /**
32   * Implementation of an anonymous user singleton.
33   */
34  public enum AnonymousAccessor implements Accessor {
35  
36      INSTANCE;
37  
38      /**
39       * Obtain the shared instance of the Anonymous Accessor.
40       * There Can Be Only One.
41       */
42      public static Accessor getInstance() {
43          return INSTANCE;
44      }
45  
46      @Override
47      public <T extends Entity> T as(Class<T> cls) {
48          throw new UnsupportedOperationException();
49      }
50  
51      @Override
52      public boolean isAdmin() {
53          return false;
54      }
55  
56      @Override
57      public boolean isAnonymous() {
58          return true;
59      }
60  
61      @Override
62      public String getId() {
63          return Group.ANONYMOUS_GROUP_IDENTIFIER;
64      }
65  
66      @Override
67      public String getType() {
68          return Entities.GROUP;
69      }
70  
71      @Override
72      public Vertex asVertex() {
73          return null;
74      }
75  
76      @Override
77      public String getIdentifier() {
78          return Group.ANONYMOUS_GROUP_IDENTIFIER;
79      }
80  
81      @Override
82      public Iterable<Accessor> getParents() {
83          return Collections.emptyList();
84      }
85  
86      @Override
87      public Iterable<Accessor> getAllParents() {
88          return Collections.emptyList();
89      }
90  
91      @Override
92      public Iterable<PermissionGrant> getPermissionGrants() {
93          return Collections.emptyList();
94      }
95  
96      @Override
97      public void addPermissionGrant(PermissionGrant grant) {
98          throw new UnsupportedOperationException();
99      }
100 
101     @Override
102     public <T> T getProperty(String key) {
103         return null;
104     }
105 
106     @Override
107     public <T> T getProperty(Enum<?> key) {
108         return null;
109     }
110 
111     @Override
112     public java.util.Set<String> getPropertyKeys() {
113         return Collections.emptySet();
114     }
115 }