aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web
diff options
context:
space:
mode:
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r--archiva-modules/archiva-web/archiva-security/pom.xml10
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java7
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java6
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java37
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java6
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java10
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/spring-context.xml33
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java38
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java19
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java5
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java18
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/test/resources/spring-context.xml165
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/pom.xml32
13 files changed, 341 insertions, 45 deletions
diff --git a/archiva-modules/archiva-web/archiva-security/pom.xml b/archiva-modules/archiva-web/archiva-security/pom.xml
index e9e571be6..b8092f9de 100644
--- a/archiva-modules/archiva-web/archiva-security/pom.xml
+++ b/archiva-modules/archiva-web/archiva-security/pom.xml
@@ -38,11 +38,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.redback.components</groupId>
- <artifactId>plexus-spring</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
@@ -84,5 +79,10 @@
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java
index 40d7a796a..6180f75d9 100644
--- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java
+++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.security;
* under the License.
*/
+import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import org.codehaus.plexus.redback.authentication.AuthenticationException;
@@ -35,11 +36,13 @@ import org.codehaus.plexus.redback.users.User;
import org.codehaus.plexus.redback.users.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
/**
* @version
* @plexus.component role="org.apache.maven.archiva.security.ServletAuthenticator" role-hint="default"
*/
+@Service("servletAuthenticator")
public class ArchivaServletAuthenticator
implements ServletAuthenticator
{
@@ -48,6 +51,7 @@ public class ArchivaServletAuthenticator
/**
* @plexus.requirement
*/
+ @Inject
private SecuritySystem securitySystem;
public boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result )
@@ -113,4 +117,7 @@ public class ArchivaServletAuthenticator
throw new UnauthorizedException( e.getMessage() );
}
}
+
+
+
}
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java
index 95aea4873..724ef5522 100644
--- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java
+++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java
@@ -25,6 +25,10 @@ import org.codehaus.plexus.redback.rbac.RBACManager;
import org.codehaus.plexus.redback.system.check.EnvironmentCheck;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import javax.inject.Named;
/**
* ArchivaStandardRolesCheck tests for the existance of expected / standard roles and permissions.
@@ -34,6 +38,7 @@ import org.slf4j.LoggerFactory;
* @plexus.component role="org.codehaus.plexus.redback.system.check.EnvironmentCheck"
* role-hint="required-roles"
*/
+@Service("environmentCheck#required-roles")
public class ArchivaStandardRolesCheck
implements EnvironmentCheck
{
@@ -42,6 +47,7 @@ public class ArchivaStandardRolesCheck
/**
* @plexus.requirement role-hint="cached"
*/
+ @Inject @Named(value = "rBACManager#cached")
private RBACManager rbacManager;
/**
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java
index 02285c2c2..36e3d7992 100644
--- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java
+++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java
@@ -35,6 +35,9 @@ import org.codehaus.plexus.redback.users.User;
import org.codehaus.plexus.redback.users.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
/**
* DefaultUserRepositories
@@ -42,22 +45,26 @@ import org.slf4j.LoggerFactory;
* @version $Id$
* @plexus.component role="org.apache.maven.archiva.security.UserRepositories" role-hint="default"
*/
+@Service("userRepositories")
public class DefaultUserRepositories
implements UserRepositories
{
/**
* @plexus.requirement
*/
+ @Inject
private SecuritySystem securitySystem;
/**
* @plexus.requirement role-hint="default"
*/
+ @Inject
private RoleManager roleManager;
/**
* @plexus.requirement
*/
+ @Inject
private ArchivaConfiguration archivaConfiguration;
private Logger log = LoggerFactory.getLogger( DefaultUserRepositories.class );
@@ -192,4 +199,34 @@ public class DefaultUserRepositories
throw new ArchivaSecurityException( e.getMessage() );
}
}
+
+ public SecuritySystem getSecuritySystem()
+ {
+ return securitySystem;
+ }
+
+ public void setSecuritySystem( SecuritySystem securitySystem )
+ {
+ this.securitySystem = securitySystem;
+ }
+
+ public RoleManager getRoleManager()
+ {
+ return roleManager;
+ }
+
+ public void setRoleManager( RoleManager roleManager )
+ {
+ this.roleManager = roleManager;
+ }
+
+ public ArchivaConfiguration getArchivaConfiguration()
+ {
+ return archivaConfiguration;
+ }
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java
index ea9cc0d66..0dfdb0001 100644
--- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java
+++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java
@@ -44,7 +44,7 @@ public interface ServletAuthenticator
* @throws AccountLockedException
* @throws MustChangePasswordException
*/
- public boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result )
+ boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result )
throws AuthenticationException, AccountLockedException, MustChangePasswordException;
/**
@@ -58,7 +58,7 @@ public interface ServletAuthenticator
* @throws AuthorizationException
* @throws UnauthorizedException
*/
- public boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId,
+ boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId,
String permission ) throws AuthorizationException, UnauthorizedException;
/**
@@ -74,6 +74,6 @@ public interface ServletAuthenticator
* @return
* @throws UnauthorizedException
*/
- public boolean isAuthorized( String principal, String repoId, String permission )
+ boolean isAuthorized( String principal, String repoId, String permission )
throws UnauthorizedException;
}
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java
index a26c8b5a7..35a5b1903 100644
--- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java
+++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java
@@ -37,7 +37,7 @@ public interface UserRepositories
* @throws AccessDeniedException
* @throws ArchivaSecurityException
*/
- public List<String> getObservableRepositoryIds( String principal )
+ List<String> getObservableRepositoryIds( String principal )
throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException;
/**
@@ -49,7 +49,7 @@ public interface UserRepositories
* @throws AccessDeniedException
* @throws ArchivaSecurityException
*/
- public List<String> getManagableRepositoryIds( String principal )
+ List<String> getManagableRepositoryIds( String principal )
throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException;
/**
@@ -58,7 +58,7 @@ public interface UserRepositories
* @param repoId the repository id to work off of.
* @throws ArchivaSecurityException if there was a problem creating the repository roles.
*/
- public void createMissingRepositoryRoles( String repoId )
+ void createMissingRepositoryRoles( String repoId )
throws ArchivaSecurityException;
/**
@@ -70,7 +70,7 @@ public interface UserRepositories
* @throws PrincipalNotFoundException
* @throws ArchivaSecurityException
*/
- public boolean isAuthorizedToUploadArtifacts( String principal, String repoId)
+ boolean isAuthorizedToUploadArtifacts( String principal, String repoId)
throws PrincipalNotFoundException, ArchivaSecurityException;
/**
@@ -82,7 +82,7 @@ public interface UserRepositories
* @throws ArchivaSecurityException
* @throws AccessDeniedException
*/
- public boolean isAuthorizedToDeleteArtifacts( String principal, String repoId )
+ boolean isAuthorizedToDeleteArtifacts( String principal, String repoId )
throws AccessDeniedException, ArchivaSecurityException;
}
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/spring-context.xml
new file mode 100644
index 000000000..5678a3a0d
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/spring-context.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:annotation-config />
+ <context:component-scan base-package="org.apache.maven.archiva.security"/>
+
+</beans> \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java
index 6e3eaff42..15eba1e26 100644
--- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java
+++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java
@@ -19,8 +19,7 @@ package org.apache.maven.archiva.security;
* under the License.
*/
-import java.io.File;
-
+import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@@ -29,15 +28,24 @@ import org.codehaus.plexus.redback.role.RoleManager;
import org.codehaus.plexus.redback.system.SecuritySystem;
import org.codehaus.plexus.redback.users.User;
import org.codehaus.plexus.redback.users.UserManager;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.File;
/**
- * AbstractSecurityTest
+ * AbstractSecurityTest
*
* @version $Id: AbstractSecurityTest
*/
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
public abstract class AbstractSecurityTest
- extends PlexusInSpringTestCase
+ extends TestCase
{
protected static final String USER_GUEST = "guest";
@@ -45,14 +53,21 @@ public abstract class AbstractSecurityTest
protected static final String USER_ALPACA = "alpaca";
+ @Inject
+ @Named( value = "securitySystem#testable" )
protected SecuritySystem securitySystem;
+ @Inject
+ @Named( value = "rBACManager#memory" )
private RBACManager rbacManager;
+ @Inject
protected RoleManager roleManager;
+ @Inject
private ArchivaConfiguration archivaConfiguration;
+ @Inject
protected UserRepositories userRepos;
protected void setupRepository( String repoId )
@@ -62,7 +77,7 @@ public abstract class AbstractSecurityTest
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId( repoId );
repoConfig.setName( "Testable repo <" + repoId + ">" );
- repoConfig.setLocation( getTestPath( "target/test-repo/" + repoId ) );
+ repoConfig.setLocation( new File( "./target/test-repo/" + repoId ).getPath() );
archivaConfiguration.getConfiguration().addManagedRepository( repoConfig );
// Add repo roles to security.
@@ -88,25 +103,20 @@ public abstract class AbstractSecurityTest
}
@Override
+ @Before
public void setUp()
throws Exception
{
super.setUp();
- File srcConfig = getTestFile( "src/test/resources/repository-archiva.xml" );
- File destConfig = getTestFile( "target/test-conf/archiva.xml" );
+ File srcConfig = new File( "./src/test/resources/repository-archiva.xml" );
+ File destConfig = new File( "./target/test-conf/archiva.xml" );
destConfig.getParentFile().mkdirs();
destConfig.delete();
FileUtils.copyFile( srcConfig, destConfig );
- securitySystem = (SecuritySystem) lookup( SecuritySystem.class, "testable" );
- rbacManager = (RBACManager) lookup( RBACManager.class, "memory" );
- roleManager = (RoleManager) lookup( RoleManager.class, "default" );
- userRepos = (UserRepositories) lookup( UserRepositories.class, "default" );
- archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
-
// Some basic asserts.
assertNotNull( securitySystem );
assertNotNull( rbacManager );
diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java
index 89f72848a..7a0ec20d1 100644
--- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java
+++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.security;
* under the License.
*/
+import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import org.codehaus.plexus.redback.authentication.AuthenticationException;
@@ -30,6 +31,8 @@ import org.codehaus.plexus.redback.users.User;
import org.codehaus.plexus.redback.users.UserManager;
import org.easymock.MockControl;
+import org.junit.Before;
+import org.junit.Test;
/**
* ArchivaServletAuthenticatorTest
@@ -39,27 +42,25 @@ import org.easymock.MockControl;
public class ArchivaServletAuthenticatorTest
extends AbstractSecurityTest
{
+ @Inject
private ServletAuthenticator servletAuth;
private MockControl httpServletRequestControl;
private HttpServletRequest request;
- @Override
+ @Before
public void setUp()
throws Exception
{
super.setUp();
- servletAuth = (ServletAuthenticator) lookup( ServletAuthenticator.class, "default" );
-
httpServletRequestControl = MockControl.createControl( HttpServletRequest.class );
request = (HttpServletRequest) httpServletRequestControl.getMock();
setupRepository( "corporate" );
}
- @Override
protected String getPlexusConfigLocation()
{
return "org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.xml";
@@ -71,6 +72,7 @@ public class ArchivaServletAuthenticatorTest
roleManager.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId, principal );
}
+ @Test
public void testIsAuthenticatedUserExists()
throws Exception
{
@@ -80,6 +82,7 @@ public class ArchivaServletAuthenticatorTest
assertTrue( isAuthenticated );
}
+ @Test
public void testIsAuthenticatedUserDoesNotExist()
throws Exception
{
@@ -95,6 +98,7 @@ public class ArchivaServletAuthenticatorTest
}
}
+ @Test
public void testIsAuthorizedUserHasWriteAccess()
throws Exception
{
@@ -114,6 +118,7 @@ public class ArchivaServletAuthenticatorTest
assertTrue( isAuthorized );
}
+ @Test
public void testIsAuthorizedUserHasNoWriteAccess()
throws Exception
{
@@ -145,6 +150,7 @@ public class ArchivaServletAuthenticatorTest
httpServletRequestControl.verify();
}
+ @Test
public void testIsAuthorizedUserHasReadAccess()
throws Exception
{
@@ -164,6 +170,7 @@ public class ArchivaServletAuthenticatorTest
assertTrue( isAuthorized );
}
+ @Test
public void testIsAuthorizedUserHasNoReadAccess()
throws Exception
{
@@ -186,6 +193,7 @@ public class ArchivaServletAuthenticatorTest
}
}
+ @Test
public void testIsAuthorizedGuestUserHasWriteAccess()
throws Exception
{
@@ -196,6 +204,7 @@ public class ArchivaServletAuthenticatorTest
assertTrue( isAuthorized );
}
+ @Test
public void testIsAuthorizedGuestUserHasNoWriteAccess()
throws Exception
{
@@ -206,6 +215,7 @@ public class ArchivaServletAuthenticatorTest
assertFalse( isAuthorized );
}
+ @Test
public void testIsAuthorizedGuestUserHasReadAccess()
throws Exception
{
@@ -217,6 +227,7 @@ public class ArchivaServletAuthenticatorTest
assertTrue( isAuthorized );
}
+ @Test
public void testIsAuthorizedGuestUserHasNoReadAccess()
throws Exception
{
diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java
index 85ba99507..d314e1c37 100644
--- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java
+++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java
@@ -22,6 +22,7 @@ package org.apache.maven.archiva.security;
import java.util.List;
import org.apache.commons.lang.StringUtils;
+import org.junit.Test;
/**
* DefaultUserRepositoriesTest
@@ -31,12 +32,12 @@ import org.apache.commons.lang.StringUtils;
public class DefaultUserRepositoriesTest
extends AbstractSecurityTest
{
- @Override
protected String getPlexusConfigLocation()
{
return "org/apache/maven/archiva/security/DefaultUserRepositoriesTest.xml";
}
-
+
+ @Test
public void testGetObservableRepositoryIds()
throws Exception
{
diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java
index 7fc1ffbf9..4f83d822f 100644
--- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java
+++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java
@@ -19,20 +19,29 @@ package org.apache.maven.archiva.security;
* under the License.
*/
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import junit.framework.TestCase;
import org.codehaus.plexus.redback.role.RoleManager;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
/**
* RoleProfilesTest
*
* @version $Id: RoleManagerTest.java 4330 2007-05-10 17:28:56Z jmcconnell $
*/
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
public class RoleManagerTest
- extends PlexusInSpringTestCase
+ extends TestCase
{
/**
* @plexus.requirement role-hint="default"
*/
+ @Inject
RoleManager roleManager;
protected void setUp()
@@ -40,9 +49,10 @@ public class RoleManagerTest
{
super.setUp();
- roleManager = (RoleManager) lookup( RoleManager.class.getName(), "default" );
+
}
-
+
+ @Test
public void testExpectedRoles()
throws Exception
{
diff --git a/archiva-modules/archiva-web/archiva-security/src/test/resources/spring-context.xml b/archiva-modules/archiva-web/archiva-security/src/test/resources/spring-context.xml
new file mode 100644
index 000000000..30e0cbd56
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-security/src/test/resources/spring-context.xml
@@ -0,0 +1,165 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <bean name="securitySystem#testable" class="org.codehaus.plexus.redback.system.DefaultSecuritySystem">
+ <property name="userManager" ref="userManager#memory"/>
+ <property name="keyManager" ref="keyManager#memory"/>
+ </bean>
+
+ <alias name="securitySystem#testable" alias="securitySystem"/>
+
+ <bean name="userRepositories" class="org.apache.maven.archiva.security.DefaultUserRepositories">
+ <property name="securitySystem" ref="securitySystem#testable"/>
+ <property name="roleManager" ref="roleManager"/>
+ <property name="archivaConfiguration" ref="archivaConfiguration"/>
+ </bean>
+
+ <bean name="authorizer#rbac" class="org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer">
+ <property name="manager" ref="rBACManager#memory"/>
+ <property name="userManager" ref="userManager#memory"/>
+ <property name="evaluator" ref="permissionEvaluator"/>
+ </bean>
+
+ <bean name="permissionEvaluator" class="org.codehaus.plexus.redback.authorization.rbac.evaluator.DefaultPermissionEvaluator">
+ <property name="userManager" ref="userManager#memory"/>
+ </bean>
+
+ <bean name="roleManager" class="org.codehaus.plexus.redback.role.DefaultRoleManager">
+ <property name="rbacManager" ref="rBACManager#memory"/>
+ </bean>
+
+ <bean name="rBACManager#cached" class="org.codehaus.plexus.redback.rbac.cached.CachedRbacManager">
+ <property name="rbacImpl" ref="rBACManager#memory"/>
+ </bean>
+
+ <!--
+
+
+ <component>
+ <role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.role.processor.DefaultRoleModelProcessor</implementation>
+ <description>DefaultRoleModelProcessor: inserts the components of the model that can be populated into the rbac manager</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.role.template.DefaultRoleTemplateProcessor</implementation>
+ <description>DefaultRoleTemplateProcessor: inserts the components of a template into the rbac manager</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+ <configuration>
+ <properties>
+ <system/>
+ <xml fileName="${basedir}/target/test-conf/archiva.xml"
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
+ </properties>
+ </configuration>
+ </component>
+
+
+ ignored ??
+
+ <component>
+ <role>org.apache.maven.archiva.security.ServletAuthenticator</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.archiva.security.ArchivaServletAuthenticator</implementation>
+ <description>ArchivaServletAuthenticator</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.system.SecuritySystem</role>
+ <role-hint>testable</role-hint>
+ <field-name>securitySystem</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ partially configured
+
+ <component>
+ <role>org.codehaus.plexus.redback.role.RoleManager</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.role.DefaultRoleManager</implementation>
+ <description>RoleProfileManager:</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.role.validator.RoleModelValidator</role>
+ <role-hint>default</role-hint>
+ <field-name>modelValidator</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
+ <role-hint>default</role-hint>
+ <field-name>modelProcessor</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
+ <role-hint>default</role-hint>
+ <field-name>templateProcessor</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+
+ -->
+</beans> \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml
index 09829fa27..fc2fb60ca 100644
--- a/archiva-modules/archiva-web/archiva-webapp/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml
@@ -160,20 +160,36 @@
<artifactId>struts2-core</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus.registry</groupId>
- <artifactId>plexus-registry-api</artifactId>
+ <groupId>org.codehaus.redback.components.registry</groupId>
+ <artifactId>spring-registry-api</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus.registry</groupId>
- <artifactId>plexus-registry-commons</artifactId>
+ <groupId>org.codehaus.redback.components.registry</groupId>
+ <artifactId>spring-registry-commons</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus.cache</groupId>
- <artifactId>plexus-cache-api</artifactId>
+ <groupId>org.codehaus.redback.components.cache</groupId>
+ <artifactId>spring-cache-api</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus.cache</groupId>
- <artifactId>plexus-cache-ehcache</artifactId>
+ <groupId>org.codehaus.redback.components.cache</groupId>
+ <artifactId>spring-cache-ehcache</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.ehcache</groupId>
+ <artifactId>ehcache-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>