001/*
002 *  Copyright 2016 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.repository;
017
018import java.util.Set;
019
020import org.ametys.core.group.GroupIdentity;
021import org.ametys.core.right.ModifiableProfileAssignmentStorage;
022import org.ametys.core.right.ProfileAssignmentStorage;
023import org.ametys.core.user.UserIdentity;
024import org.ametys.plugins.repository.jcr.ACLJCRAmetysObjectHelper;
025
026/**
027 * Implementation of {@link ProfileAssignmentStorage} for {@link ModifiableACLAmetysObject}s which stores profile assignments in subnodes of the node representing this object.
028 */
029public class ModifiableACLAmetysObjectProfileAssignmentStorage extends ACLAmetysObjectProfileAssignmentStorage implements ModifiableProfileAssignmentStorage
030{
031    @Override
032    public void addAllowedProfilesForAnyConnectedUser(Object object, Set<String> profileIds)
033    {
034        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
035        ametysObj.addAllowedProfilesForAnyConnectedUser(profileIds);
036    }
037
038    @Override
039    public void removeAllowedProfilesForAnyConnectedUser(Object object, Set<String> profileIds)
040    {
041        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
042        ametysObj.removeAllowedProfilesForAnyConnectedUser(profileIds);
043    }
044
045    
046    /* -------------------------------------- */
047    /* DENIED PROFILES FOR ANY CONNECTED USER */
048    /* -------------------------------------- */
049    
050    @Override
051    public void addDeniedProfilesForAnyConnectedUser(Object object, Set<String> profileIds)
052    {
053        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
054        ametysObj.addDeniedProfilesForAnyConnectedUser(profileIds);
055    }
056    
057    @Override
058    public void removeDeniedProfilesForAnyConnectedUser(Object object, Set<String> profileIds)
059    {
060        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
061        ametysObj.removeDeniedProfilesForAnyConnectedUser(profileIds);
062    }
063    
064    
065    /* ------------------------------ */
066    /* ALLOWED PROFILES FOR ANONYMOUS */
067    /* ------------------------------ */
068    
069    @Override
070    public void addAllowedProfilesForAnonymous(Object object, Set<String> profileIds)
071    {
072        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
073        ametysObj.addAllowedProfilesForAnonymous(profileIds);
074    }
075    
076    @Override
077    public void removeAllowedProfilesForAnonymous(Object object, Set<String> profileIds)
078    {
079        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
080        ametysObj.removeAllowedProfilesForAnonymous(profileIds);
081    }
082    
083    
084    /* ----------------------------- */
085    /* DENIED PROFILES FOR ANONYMOUS */
086    /* ----------------------------- */
087    
088    @Override
089    public void addDeniedProfilesForAnonymous(Object object, Set<String> profileIds)
090    {
091        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
092        ametysObj.addDeniedProfilesForAnonymous(profileIds);
093    }
094    
095    @Override
096    public void removeDeniedProfilesForAnonymous(Object object, Set<String> profileIds)
097    {
098        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
099        ametysObj.removeDeniedProfilesForAnonymous(profileIds);
100    }
101    
102    
103    /* --------------------------- */
104    /* MANAGEMENT OF ALLOWED USERS */
105    /* --------------------------- */
106
107    @Override
108    public void addAllowedUsers(Set<UserIdentity> users, Object object, String profileId)
109    {
110        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
111        ametysObj.addAllowedUsers(users, profileId);
112    }
113
114    @Override
115    public void removeAllowedUsers(Set<UserIdentity> users, Object object, String profileId)
116    {
117        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
118        ametysObj.removeAllowedUsers(users, profileId);
119    }
120
121    @Override
122    public void removeAllowedUsers(Set<UserIdentity> users, Object object)
123    {
124        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
125        ametysObj.removeAllowedUsers(users);
126    }
127    
128    
129    /* ---------------------------- */
130    /* MANAGEMENT OF ALLOWED GROUPS */
131    /* ---------------------------- */
132
133    @Override
134    public void addAllowedGroups(Set<GroupIdentity> groups, Object object, String profileId)
135    {
136        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
137        ametysObj.addAllowedGroups(groups, profileId);
138    }
139
140    @Override
141    public void removeAllowedGroups(Set<GroupIdentity> groups, Object object, String profileId)
142    {
143        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
144        ametysObj.removeAllowedGroups(groups, profileId);
145    }
146
147    @Override
148    public void removeAllowedGroups(Set<GroupIdentity> groups, Object object)
149    {
150        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
151        ametysObj.removeAllowedGroups(groups);
152    }
153
154    
155    /* ---------------------------- */
156    /* MANAGEMENT OF DENIED USERS */
157    /* ---------------------------- */
158
159    @Override
160    public void addDeniedUsers(Set<UserIdentity> users, Object object, String profileId)
161    {
162        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
163        ametysObj.addDeniedUsers(users, profileId);
164    }
165
166    @Override
167    public void removeDeniedUsers(Set<UserIdentity> users, Object object, String profileId)
168    {
169        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
170        ametysObj.removeDeniedUsers(users, profileId);
171    }
172
173    @Override
174    public void removeDeniedUsers(Set<UserIdentity> users, Object object)
175    {
176        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
177        ametysObj.removeDeniedUsers(users);
178    }
179
180    
181    /* ----------------------------- */
182    /* MANAGEMENT OF DENIED GROUPS */
183    /* ----------------------------- */
184
185    @Override
186    public void addDeniedGroups(Set<GroupIdentity> groups, Object object, String profileId)
187    {
188        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
189        ametysObj.addDeniedGroups(groups, profileId);
190    }
191
192    @Override
193    public void removeDeniedGroups(Set<GroupIdentity> groups, Object object, String profileId)
194    {
195        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
196        ametysObj.removeDeniedGroups(groups, profileId);
197    }
198
199    @Override
200    public void removeDeniedGroups(Set<GroupIdentity> groups, Object object)
201    {
202        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
203        ametysObj.removeDeniedGroups(groups);
204    }
205    
206    
207    /* ------ */
208    /* REMOVE */
209    /* ------ */
210
211    @Override
212    public void removeProfile(String profileId)
213    {
214        ACLJCRAmetysObjectHelper.removeProfile(profileId);
215    }
216    
217    @Override
218    public void removeUser(UserIdentity user)
219    {
220        ACLJCRAmetysObjectHelper.removeUser(user);
221    }
222    
223    @Override
224    public void removeGroup(GroupIdentity group)
225    {
226        ACLJCRAmetysObjectHelper.removeGroup(group);
227    }
228    
229    /* ----------- */
230    /* INHERITANCE */
231    /* ----------- */
232    
233    @Override
234    public void disallowInheritance(Object object, boolean disallow)
235    {
236        ModifiableACLAmetysObject ametysObj = (ModifiableACLAmetysObject) object;
237        ametysObj.disallowInheritance(disallow);
238    }
239    
240    /* ------------------------------ */
241    /* SUPPORT OF OBJECT AND PRIORITY */
242    /* ------------------------------ */
243    
244    @Override
245    public boolean isSupported(Object object)
246    {
247        return object instanceof ModifiableACLAmetysObject;
248    }
249
250    @Override
251    public int getPriority()
252    {
253        return ProfileAssignmentStorage.MAX_PRIORITY;
254    }
255}