From e12526fa50abfe415d8bbfef39dce074cf38cc8d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 4 Jan 2013 19:00:15 +0000 Subject: [PATCH] move ldap role mapper to ldap common git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1429033 13f79535-47bb-0310-9956-ffa450edef68 --- redback-common/redback-common-ldap/pom.xml | 50 +++++++++++++-- .../ldap/role}/DefaultLdapRoleMapper.java | 2 +- .../common/ldap/role}/LdapRoleMapper.java | 2 +- .../common/ldap/role}/TestLdapRoleMapper.java | 20 +++--- .../resources/spring-context-role-mapper.xml | 62 +++++++++++++++++++ .../src/test/resources/spring-context.xml | 2 +- 6 files changed, 116 insertions(+), 22 deletions(-) rename {redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap => redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role}/DefaultLdapRoleMapper.java (99%) rename {redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap => redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role}/LdapRoleMapper.java (97%) rename {redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/java/org/apache/archiva/redback/rbac/ldap => redback-common/redback-common-ldap/src/test/java/org/apache/archiva/redback/common/ldap/role}/TestLdapRoleMapper.java (94%) create mode 100755 redback-common/redback-common-ldap/src/test/resources/spring-context-role-mapper.xml diff --git a/redback-common/redback-common-ldap/pom.xml b/redback-common/redback-common-ldap/pom.xml index b54570171..7f945e6d8 100644 --- a/redback-common/redback-common-ldap/pom.xml +++ b/redback-common/redback-common-ldap/pom.xml @@ -52,17 +52,27 @@ commons-lang commons-lang - + org.slf4j slf4j-simple test + + org.easytesting + fest-assert + test + + + org.apache.archiva.redback.components + spring-apacheds + test + + + org.apache.archiva.redback + redback-policy + test + @@ -89,6 +99,34 @@ + + org.codehaus.mojo + build-helper-maven-plugin + + + allocate-ldap-port + process-classes + + reserve-network-port + + + + ldapPort + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${ldapPort} + ${basedir} + + + diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/DefaultLdapRoleMapper.java b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java similarity index 99% rename from redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/DefaultLdapRoleMapper.java rename to redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java index 466ad2ed3..721ea61e8 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/DefaultLdapRoleMapper.java +++ b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java @@ -1,4 +1,4 @@ -package org.apache.archiva.redback.rbac.ldap; +package org.apache.archiva.redback.common.ldap.role; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRoleMapper.java b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapper.java similarity index 97% rename from redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRoleMapper.java rename to redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapper.java index 949e9b5a3..e37cfa34e 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRoleMapper.java +++ b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapper.java @@ -1,4 +1,4 @@ -package org.apache.archiva.redback.rbac.ldap; +package org.apache.archiva.redback.common.ldap.role; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/java/org/apache/archiva/redback/rbac/ldap/TestLdapRoleMapper.java b/redback-common/redback-common-ldap/src/test/java/org/apache/archiva/redback/common/ldap/role/TestLdapRoleMapper.java similarity index 94% rename from redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/java/org/apache/archiva/redback/rbac/ldap/TestLdapRoleMapper.java rename to redback-common/redback-common-ldap/src/test/java/org/apache/archiva/redback/common/ldap/role/TestLdapRoleMapper.java index bf977ea90..c519784a8 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/java/org/apache/archiva/redback/rbac/ldap/TestLdapRoleMapper.java +++ b/redback-common/redback-common-ldap/src/test/java/org/apache/archiva/redback/common/ldap/role/TestLdapRoleMapper.java @@ -1,4 +1,4 @@ -package org.apache.archiva.redback.rbac.ldap; +package org.apache.archiva.redback.common.ldap.role; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,8 +22,6 @@ import junit.framework.TestCase; import org.apache.archiva.redback.components.apacheds.ApacheDs; import org.apache.archiva.redback.policy.PasswordEncoder; import org.apache.archiva.redback.policy.encoders.SHA1PasswordEncoder; -import org.apache.archiva.redback.users.UserManager; -import org.apache.archiva.redback.users.ldap.service.LdapCacheService; import org.fest.assertions.Assertions; import org.junit.After; import org.junit.Before; @@ -37,7 +35,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.inject.Inject; import javax.inject.Named; -import javax.naming.NameClassPair; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.Attribute; @@ -58,7 +55,8 @@ import java.util.Map; * @author Olivier Lamy */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" }) +@ContextConfiguration( + locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-role-mapper.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) public class TestLdapRoleMapper extends TestCase @@ -67,11 +65,7 @@ public class TestLdapRoleMapper Logger log = LoggerFactory.getLogger( getClass() ); @Inject - @Named(value = "userManager#ldap") - private UserManager userManager; - - @Inject - @Named(value = "apacheDS#test") + @Named( value = "apacheDS#test" ) private ApacheDs apacheDs; private String suffix; @@ -80,8 +74,8 @@ public class TestLdapRoleMapper private PasswordEncoder passwordEncoder; - @Inject - private LdapCacheService ldapCacheService; + //@Inject + //private LdapCacheService ldapCacheService; @Inject @Named(value = "ldapRoleMapper#test") @@ -142,7 +136,7 @@ public class TestLdapRoleMapper throws Exception { // clear cache - ldapCacheService.removeAllUsers(); + //ldapCacheService.removeAllUsers(); InitialDirContext context = apacheDs.getAdminContext(); diff --git a/redback-common/redback-common-ldap/src/test/resources/spring-context-role-mapper.xml b/redback-common/redback-common-ldap/src/test/resources/spring-context-role-mapper.xml new file mode 100755 index 000000000..c30308064 --- /dev/null +++ b/redback-common/redback-common-ldap/src/test/resources/spring-context-role-mapper.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/resources/spring-context.xml b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/resources/spring-context.xml index c87f86ddc..c30308064 100755 --- a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/resources/spring-context.xml +++ b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/resources/spring-context.xml @@ -51,7 +51,7 @@ - + -- 2.39.5