1 package org.apache.archiva.redback.rbac.ldap;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
22 import org.apache.archiva.redback.rbac.AbstractRBACManager;
23 import org.apache.archiva.redback.rbac.AbstractRole;
24 import org.apache.archiva.redback.rbac.AbstractUserAssignment;
25 import org.apache.archiva.redback.rbac.Operation;
26 import org.apache.archiva.redback.rbac.Permission;
27 import org.apache.archiva.redback.rbac.RBACManager;
28 import org.apache.archiva.redback.rbac.RbacManagerException;
29 import org.apache.archiva.redback.rbac.RbacObjectInvalidException;
30 import org.apache.archiva.redback.rbac.RbacObjectNotFoundException;
31 import org.apache.archiva.redback.rbac.Resource;
32 import org.apache.archiva.redback.rbac.Role;
33 import org.apache.archiva.redback.rbac.UserAssignment;
34 import org.springframework.stereotype.Service;
36 import javax.inject.Inject;
37 import java.util.Collection;
38 import java.util.Collections;
39 import java.util.List;
42 * @author Olivier Lamy
45 @Service( "rbacManager#ldap" )
46 public class LdapRbacManager
47 extends AbstractRBACManager
48 implements RBACManager
52 private LdapConnectionFactory ldapConnectionFactory;
54 public Role createRole( String name )
56 return new MockRole();
59 public Role saveRole( Role role )
60 throws RbacManagerException
65 public void saveRoles( Collection<Role> roles )
66 throws RbacManagerException
71 public Role getRole( String roleName )
72 throws RbacManagerException
78 public List<Role> getAllRoles()
79 throws RbacManagerException
82 return Collections.emptyList();
85 public void removeRole( Role role )
86 throws RbacManagerException
91 public Permission createPermission( String name )
92 throws RbacManagerException
94 return new MockPermission();
97 public Permission createPermission( String name, String operationName, String resourceIdentifier )
98 throws RbacManagerException
100 return new MockPermission();
103 public Permission savePermission( Permission permission )
104 throws RbacManagerException
109 public Permission getPermission( String permissionName )
110 throws RbacManagerException
112 return new MockPermission();
115 public List<Permission> getAllPermissions()
116 throws RbacManagerException
119 return Collections.emptyList();
122 public void removePermission( Permission permission )
123 throws RbacManagerException
128 public Operation createOperation( String name )
129 throws RbacManagerException
131 return new MockOperation();
134 public Operation saveOperation( Operation operation )
135 throws RbacManagerException
140 public Operation getOperation( String operationName )
141 throws RbacManagerException
143 return new MockOperation();
146 public List<Operation> getAllOperations()
147 throws RbacManagerException
150 return Collections.emptyList();
153 public void removeOperation( Operation operation )
154 throws RbacManagerException
159 public Resource createResource( String identifier )
160 throws RbacManagerException
162 return new MockResource();
165 public Resource saveResource( Resource resource )
166 throws RbacManagerException
171 public Resource getResource( String resourceIdentifier )
172 throws RbacManagerException
175 return new MockResource();
178 public List<Resource> getAllResources()
179 throws RbacManagerException
182 return Collections.emptyList();
185 public void removeResource( Resource resource )
186 throws RbacManagerException
191 public UserAssignment createUserAssignment( String principal )
192 throws RbacManagerException
194 return new MockUserAssignment();
197 public UserAssignment saveUserAssignment( UserAssignment userAssignment )
198 throws RbacManagerException
200 return userAssignment;
203 public UserAssignment getUserAssignment( String principal )
204 throws RbacManagerException
207 return new MockUserAssignment();
210 public List<UserAssignment> getAllUserAssignments()
211 throws RbacManagerException
214 return Collections.emptyList();
217 public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
218 throws RbacManagerException
221 return Collections.emptyList();
224 public void removeUserAssignment( UserAssignment userAssignment )
225 throws RbacManagerException
230 public void eraseDatabase()
235 //-------------------------------
237 //-------------------------------
239 private static class MockRole
243 public void addPermission( Permission permission )
248 public void addChildRoleName( String name )
253 public List<String> getChildRoleNames()
255 return Collections.emptyList();
258 public String getDescription()
263 public String getName()
268 public List<Permission> getPermissions()
270 return Collections.emptyList();
273 public boolean isAssignable()
278 public void removePermission( Permission permission )
283 public void setAssignable( boolean assignable )
288 public void setChildRoleNames( List<String> names )
293 public void setDescription( String description )
298 public void setName( String name )
303 public void setPermissions( List<Permission> permissions )
305 //To change body of implemented methods use File | Settings | File Templates.
308 public boolean isPermanent()
313 public void setPermanent( boolean permanent )
319 private static class MockPermission
320 implements Permission
322 public String getDescription()
327 public String getName()
332 public Operation getOperation()
337 public Resource getResource()
342 public void setDescription( String description )
347 public void setName( String name )
352 public void setOperation( Operation operation )
357 public void setResource( Resource resource )
362 public boolean isPermanent()
367 public void setPermanent( boolean permanent )
373 private static class MockOperation
376 public String getDescription()
381 public String getName()
386 public void setDescription( String description )
391 public void setName( String name )
396 public boolean isPermanent()
401 public void setPermanent( boolean permanent )
407 private static class MockResource
410 public String getIdentifier()
415 public boolean isPattern()
420 public void setIdentifier( String identifier )
425 public void setPattern( boolean pattern )
430 public boolean isPermanent()
435 public void setPermanent( boolean permanent )
441 private static class MockUserAssignment
442 extends AbstractUserAssignment
443 implements UserAssignment
445 public String getPrincipal()
450 public List<String> getRoleNames()
452 return Collections.emptyList();
455 public void setPrincipal( String principal )
460 public void setRoleNames( List<String> roles )
465 public boolean isPermanent()
470 public void setPermanent( boolean permanent )