}
close( namingEnumeration );
}
+ }
+
+ public List<String> getRoles( String username )
+ throws MappingException
+ {
+ List<String> groups = getGroups( username );
+ Map<String, String> rolesMapping = getLdapGroupMappings();
+
+ List<String> roles = new ArrayList<String>( groups.size() );
+
+ for ( String group : groups )
+ {
+ String role = rolesMapping.get( group );
+ if ( role != null )
+ {
+ roles.add( role );
+ }
+ }
+
+ return roles;
}
private void close( NamingEnumeration namingEnumeration )
log.warn( "removeLdapMapping not implemented" );
}
+ public void setLdapGroupMappings( Map<String, String> mappings )
+ throws MappingException
+ {
+ log.warn( "setLdapGroupMappings not implemented" );
+ }
+
public Map<String, String> getLdapGroupMappings()
{
Map<String, String> map = new HashMap<String, String>();
List<String> getGroups( String username )
throws MappingException;
+ List<String> getRoles( String username )
+ throws MappingException;
+
/**
* add mapping redback role <-> ldap group
*
Map<String, String> getLdapGroupMappings()
throws MappingException;
+ void setLdapGroupMappings( Map<String, String> mappings )
+ throws MappingException;
+
}
Logger log = LoggerFactory.getLogger( getClass() );
@Inject
- @Named( value = "apacheDS#test" )
+ @Named(value = "apacheDS#test")
private ApacheDs apacheDs;
private String suffix;
public void getGroups()
throws Exception
{
- List<String> roles = ldapRoleMapper.getGroups( "admin" );
+ List<String> groups = ldapRoleMapper.getGroups( "admin" );
+
+ log.info( "groups for admin: {}", groups );
+
+ Assertions.assertThat( groups ).isNotNull().isNotEmpty().hasSize( 3 ).contains( "archiva-admin",
+ "internal-repo-manager",
+ "internal-repo-observer" );
+
+ groups = ldapRoleMapper.getGroups( "user.8" );
+
+ Assertions.assertThat( groups ).isNotNull().isNotEmpty().hasSize( 1 ).contains( "internal-repo-observer" );
+
+ groups = ldapRoleMapper.getGroups( "user.7" );
+
+ Assertions.assertThat( groups ).isNotNull().isNotEmpty().hasSize( 2 ).contains( "archiva-admin",
+ "internal-repo-observer" );
+ }
+
+ @Test
+ public void getRoles()
+ throws Exception
+ {
+ List<String> roles = ldapRoleMapper.getRoles( "admin" );
log.info( "roles for admin: {}", roles );
- Assertions.assertThat( roles ).isNotNull().isNotEmpty().hasSize( 3 ).contains( "archiva-admin",
- "internal-repo-manager",
- "internal-repo-observer" );
+ Assertions.assertThat( roles ).isNotNull().isNotEmpty().hasSize( 3 ).contains( "Archiva System Administrator",
+ "Internal Repo Manager",
+ "Internal Repo Observer" );
+
+ roles = ldapRoleMapper.getRoles( "user.7" );
- roles = ldapRoleMapper.getGroups( "user.8" );
+ log.info( "roles for user.7: {}", roles );
- Assertions.assertThat( roles ).isNotNull().isNotEmpty().hasSize( 1 ).contains( "internal-repo-observer" );
+ Assertions.assertThat( roles ).isNotNull().isNotEmpty().hasSize( 2 ).contains( "Archiva System Administrator",
+ "Internal Repo Observer" );
- roles = ldapRoleMapper.getGroups( "user.7" );
+ roles = ldapRoleMapper.getRoles( "user.8" );
+
+ log.info( "roles for user.8: {}", roles );
+
+ Assertions.assertThat( roles ).isNotNull().isNotEmpty().hasSize( 1 ).contains( "Internal Repo Observer" );
- Assertions.assertThat( roles ).isNotNull().isNotEmpty().hasSize( 2 ).contains( "archiva-admin",
- "internal-repo-observer" );
}
+
}
<alias name="userConfiguration#redback" alias="userConfiguration#default"/>
+ <bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry"
+ init-method="initialize">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <system/>
+ <properties fileName="${basedir}/src/test/security.properties" config-optional="true"
+ config-at="org.apache.archiva.redback"/>
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+
<bean name="apacheDS#test" class="org.apache.archiva.redback.components.apacheds.DefaultApacheDs"
scope="prototype">
<property name="basedir" value="${basedir}/target/apacheds"/>
--- /dev/null
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+ldap.config.groups.role.archiva-admin=Archiva System Administrator
+ldap.config.groups.role.internal-repo-manager=Internal Repo Manager
+ldap.config.groups.role.internal-repo-observer=Internal Repo Observer
\ No newline at end of file
<module>redback-rbac-jdo</module>
<module>redback-rbac-memory</module>
<module>redback-rbac-cached</module>
+ <module>redback-rbac-ldap</module>
</modules>
</project>