<groupId>org.codehaus.redback</groupId>
<artifactId>redback-rbac-role-manager</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
<!-- Test Scoped -->
<dependency>
<groupId>org.codehaus.redback</groupId>
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <scope>test</scope>
- </dependency>
+
</dependencies>
</project>
* under the License.
*/
-import java.util.ArrayList;
-import java.util.List;
-
+import com.google.common.collect.Lists;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.codehaus.plexus.redback.authentication.AuthenticationResult;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
/**
* DefaultUserRepositories
- *
+ *
* @version $Id$
- * plexus.component role="org.apache.maven.archiva.security.UserRepositories" role-hint="default"
+ * plexus.component role="org.apache.maven.archiva.security.UserRepositories" role-hint="default"
*/
-@Service("userRepositories")
+@Service( "userRepositories" )
public class DefaultUserRepositories
implements UserRepositories
{
*/
@Inject
private ArchivaConfiguration archivaConfiguration;
-
+
private Logger log = LoggerFactory.getLogger( DefaultUserRepositories.class );
public List<String> getObservableRepositoryIds( String principal )
List<String> repoIds = new ArrayList<String>();
- List<ManagedRepositoryConfiguration> repos =
- archivaConfiguration.getConfiguration().getManagedRepositories();
+ List<ManagedRepositoryConfiguration> repos = archivaConfiguration.getConfiguration().getManagedRepositories();
for ( ManagedRepositoryConfiguration repo : repos )
{
catch ( AuthorizationException e )
{
// swallow.
- log.debug( "Not authorizing '" + principal + "' for repository '" + repo.getId() + "': "
- + e.getMessage() );
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Not authorizing '{}' for repository '{}': {}",
+ Lists.<Object>newArrayList( principal, repo.getId(), e.getMessage() ) );
+ }
}
}
}
catch ( RoleManagerException e )
{
- throw new ArchivaSecurityException(
- "Unable to create roles for configured repositories: " + e.getMessage(),
+ throw new ArchivaSecurityException( "Unable to create roles for configured repositories: " + e.getMessage(),
e );
}
}
throw new ArchivaSecurityException( e.getMessage() );
}
}
-
+
public boolean isAuthorizedToDeleteArtifacts( String principal, String repoId )
throws AccessDeniedException, ArchivaSecurityException
{
protected RoleManager roleManager;
@Inject
+ @Named( value = "archivaConfiguration#default" )
private ArchivaConfiguration archivaConfiguration;
@Inject
repoConfig.setId( repoId );
repoConfig.setName( "Testable repo <" + repoId + ">" );
repoConfig.setLocation( new File( "./target/test-repo/" + repoId ).getPath() );
- archivaConfiguration.getConfiguration().addManagedRepository( repoConfig );
+ if ( !archivaConfiguration.getConfiguration().getManagedRepositoriesAsMap().containsKey( repoId ) )
+ {
+ archivaConfiguration.getConfiguration().addManagedRepository( repoConfig );
+ }
// Add repo roles to security.
userRepos.createMissingRepositoryRoles( repoId );
<alias name="servletAuthenticator" alias="servletAuthenticator#test"/>
- <!--
+ <bean name="archivaConfiguration#default" class="org.apache.maven.archiva.configuration.DefaultArchivaConfiguration">
+ <property name="registry" ref="registry#test"/>
+ </bean>
+ <alias name="archivaConfiguration#default" alias="archivaConfiguration"/>
- <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>
+ <bean name="registry#test" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
<system/>
- <xml fileName="${basedir}/target/test-conf/archiva.xml"
+ <xml fileName="${basedir}/target/test-conf/archiva.xml" config-forceCreate="true"
+ config-optional="true"
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
- </properties>
- </configuration>
- </component>
-
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+ <!--
partially configured
<component>