mirror of https://github.com/apache/archiva.git
start working on browsing only one repository to avoid merging incomplete metadata
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1301522 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5fffe588b9
commit
6c2bf258aa
|
@ -165,20 +165,17 @@
|
||||||
<groupId>org.codehaus.redback</groupId>
|
<groupId>org.codehaus.redback</groupId>
|
||||||
<artifactId>redback-users-memory</artifactId>
|
<artifactId>redback-users-memory</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<version>${redback.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.redback</groupId>
|
<groupId>org.codehaus.redback</groupId>
|
||||||
<artifactId>redback-keys-memory</artifactId>
|
<artifactId>redback-keys-memory</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<version>${redback.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.redback</groupId>
|
<groupId>org.codehaus.redback</groupId>
|
||||||
<artifactId>redback-rbac-cached</artifactId>
|
<artifactId>redback-rbac-cached</artifactId>
|
||||||
<version>${redback.version}</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
|
|
@ -28,6 +28,7 @@ import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
|
@ -64,4 +65,11 @@ public interface BrowseService
|
||||||
ProjectVersionMetadata getProjectVersionMetadata( @PathParam( "g" ) String groupId,
|
ProjectVersionMetadata getProjectVersionMetadata( @PathParam( "g" ) String groupId,
|
||||||
@PathParam( "a" ) String artifactId )
|
@PathParam( "a" ) String artifactId )
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
@Path( "userRepositories" )
|
||||||
|
@GET
|
||||||
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||||
|
@RedbackAuthorization( noPermission = true, noRestriction = true )
|
||||||
|
List<String> getUserRepositories()
|
||||||
|
throws ArchivaRestServiceException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,6 +350,12 @@ public class DefaultBrowseService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getUserRepositories()
|
||||||
|
throws ArchivaRestServiceException
|
||||||
|
{
|
||||||
|
return getObservableRepos();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------
|
//---------------------------
|
||||||
// internals
|
// internals
|
||||||
//---------------------------
|
//---------------------------
|
||||||
|
|
|
@ -33,10 +33,18 @@
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>archiva-configuration</artifactId>
|
<artifactId>archiva-configuration</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>archiva-repository-admin-api</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>archiva-security-common</artifactId>
|
<artifactId>archiva-security-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.inject</groupId>
|
||||||
|
<artifactId>javax.inject</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>servlet-api</artifactId>
|
<artifactId>servlet-api</artifactId>
|
||||||
|
@ -153,6 +161,31 @@
|
||||||
<artifactId>redback-common-test-resources</artifactId>
|
<artifactId>redback-common-test-resources</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>archiva-repository-admin-default</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-http</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-http-lightweight</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>metadata-repository-api</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>metadata-store-file</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -190,6 +223,9 @@
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
|
<basedir>${basedir}</basedir>
|
||||||
|
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
|
||||||
|
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
|
||||||
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
|
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
|
||||||
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
|
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
|
||||||
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
|
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
|
||||||
|
|
|
@ -20,8 +20,9 @@ package org.apache.archiva.security;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||||
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||||
|
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
|
||||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||||
import org.codehaus.plexus.redback.authentication.AuthenticationResult;
|
import org.codehaus.plexus.redback.authentication.AuthenticationResult;
|
||||||
import org.codehaus.plexus.redback.authorization.AuthorizationException;
|
import org.codehaus.plexus.redback.authorization.AuthorizationException;
|
||||||
|
@ -57,9 +58,9 @@ public class DefaultUserRepositories
|
||||||
private RoleManager roleManager;
|
private RoleManager roleManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ArchivaConfiguration archivaConfiguration;
|
private ManagedRepositoryAdmin managedRepositoryAdmin;
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger( DefaultUserRepositories.class );
|
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||||
|
|
||||||
public List<String> getObservableRepositoryIds( String principal )
|
public List<String> getObservableRepositoryIds( String principal )
|
||||||
throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException
|
throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException
|
||||||
|
@ -80,36 +81,57 @@ public class DefaultUserRepositories
|
||||||
private List<String> getAccessibleRepositoryIds( String principal, String operation )
|
private List<String> getAccessibleRepositoryIds( String principal, String operation )
|
||||||
throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException
|
throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException
|
||||||
{
|
{
|
||||||
SecuritySession securitySession = createSession( principal );
|
|
||||||
|
|
||||||
List<String> repoIds = new ArrayList<String>();
|
List<ManagedRepository> managedRepositories = getAccessibleRepositories( principal, operation );
|
||||||
|
List<String> repoIds = new ArrayList<String>( managedRepositories.size() );
|
||||||
List<ManagedRepositoryConfiguration> repos = archivaConfiguration.getConfiguration().getManagedRepositories();
|
for ( ManagedRepository managedRepository : managedRepositories )
|
||||||
|
|
||||||
for ( ManagedRepositoryConfiguration repo : repos )
|
|
||||||
{
|
{
|
||||||
try
|
repoIds.add( managedRepository.getId() );
|
||||||
{
|
|
||||||
String repoId = repo.getId();
|
|
||||||
if ( securitySystem.isAuthorized( securitySession, operation, repoId ) )
|
|
||||||
{
|
|
||||||
repoIds.add( repoId );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch ( AuthorizationException e )
|
|
||||||
{
|
|
||||||
// swallow.
|
|
||||||
if ( log.isDebugEnabled() )
|
|
||||||
{
|
|
||||||
log.debug( "Not authorizing '{}' for repository '{}': {}",
|
|
||||||
Lists.<Object>newArrayList( principal, repo.getId(), e.getMessage() ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return repoIds;
|
return repoIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ManagedRepository> getAccessibleRepositories( String principal, String operation )
|
||||||
|
throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException
|
||||||
|
{
|
||||||
|
SecuritySession securitySession = createSession( principal );
|
||||||
|
|
||||||
|
List<ManagedRepository> managedRepositories = new ArrayList<ManagedRepository>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
|
||||||
|
|
||||||
|
for ( ManagedRepository repo : repos )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String repoId = repo.getId();
|
||||||
|
if ( securitySystem.isAuthorized( securitySession, operation, repoId ) )
|
||||||
|
{
|
||||||
|
managedRepositories.add( repo );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( AuthorizationException e )
|
||||||
|
{
|
||||||
|
// swallow.
|
||||||
|
if ( log.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
log.debug( "Not authorizing '{}' for repository '{}': {}",
|
||||||
|
Lists.<Object>newArrayList( principal, repo.getId(), e.getMessage() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return managedRepositories;
|
||||||
|
}
|
||||||
|
catch ( RepositoryAdminException e )
|
||||||
|
{
|
||||||
|
throw new ArchivaSecurityException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private SecuritySession createSession( String principal )
|
private SecuritySession createSession( String principal )
|
||||||
throws ArchivaSecurityException, AccessDeniedException
|
throws ArchivaSecurityException, AccessDeniedException
|
||||||
{
|
{
|
||||||
|
@ -212,14 +234,4 @@ public class DefaultUserRepositories
|
||||||
{
|
{
|
||||||
this.roleManager = roleManager;
|
this.roleManager = roleManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArchivaConfiguration getArchivaConfiguration()
|
|
||||||
{
|
|
||||||
return archivaConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
|
|
||||||
{
|
|
||||||
this.archivaConfiguration = archivaConfiguration;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.archiva.security;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,5 +86,18 @@ public interface UserRepositories
|
||||||
*/
|
*/
|
||||||
boolean isAuthorizedToDeleteArtifacts( String principal, String repoId )
|
boolean isAuthorizedToDeleteArtifacts( String principal, String repoId )
|
||||||
throws AccessDeniedException, ArchivaSecurityException;
|
throws AccessDeniedException, ArchivaSecurityException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param principal
|
||||||
|
* @param operation
|
||||||
|
* @since 1.4-M3
|
||||||
|
* @return
|
||||||
|
* @throws ArchivaSecurityException
|
||||||
|
* @throws AccessDeniedException
|
||||||
|
* @throws PrincipalNotFoundException
|
||||||
|
*/
|
||||||
|
List<ManagedRepository> getAccessibleRepositories( String principal, String operation )
|
||||||
|
throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,10 @@
|
||||||
<bean name="userRepositories" class="org.apache.archiva.security.DefaultUserRepositories">
|
<bean name="userRepositories" class="org.apache.archiva.security.DefaultUserRepositories">
|
||||||
<property name="securitySystem" ref="securitySystem#testable"/>
|
<property name="securitySystem" ref="securitySystem#testable"/>
|
||||||
<property name="roleManager" ref="roleManager"/>
|
<property name="roleManager" ref="roleManager"/>
|
||||||
<property name="archivaConfiguration" ref="archivaConfiguration"/>
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<bean name="authorizer#rbac" class="org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer">
|
<bean name="authorizer#rbac" class="org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer">
|
||||||
<property name="manager" ref="rBACManager#memory"/>
|
<property name="manager" ref="rBACManager#memory"/>
|
||||||
<property name="userManager" ref="userManager#memory"/>
|
<property name="userManager" ref="userManager#memory"/>
|
||||||
|
@ -83,7 +84,9 @@
|
||||||
</bean>
|
</bean>
|
||||||
<alias name="archivaConfiguration#default" alias="archivaConfiguration"/>
|
<alias name="archivaConfiguration#default" alias="archivaConfiguration"/>
|
||||||
|
|
||||||
<bean name="registry#test" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
|
<alias name="commons-configuration" alias="registry#test"/>
|
||||||
|
|
||||||
|
<bean name="commons-configuration" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
|
||||||
<property name="properties">
|
<property name="properties">
|
||||||
<value>
|
<value>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
@ -98,38 +101,16 @@
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!--
|
<bean name="scheduler" class="org.codehaus.redback.components.scheduler.DefaultScheduler">
|
||||||
partially configured
|
<property name="properties">
|
||||||
|
<props>
|
||||||
|
<prop key="org.quartz.scheduler.instanceName">scheduler1</prop>
|
||||||
|
<prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
|
||||||
|
<prop key="org.quartz.threadPool.threadCount">2</prop>
|
||||||
|
<prop key="org.quartz.threadPool.threadPriority">4</prop>
|
||||||
|
<prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
|
||||||
|
</props>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<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>
|
</beans>
|
|
@ -170,19 +170,29 @@ $(function() {
|
||||||
var mainContent = $("#main-content");
|
var mainContent = $("#main-content");
|
||||||
mainContent.html($("#browse-tmpl" ).tmpl());
|
mainContent.html($("#browse-tmpl" ).tmpl());
|
||||||
mainContent.find("#browse_result").html(mediumSpinnerImg());
|
mainContent.find("#browse_result").html(mediumSpinnerImg());
|
||||||
$.ajax("restServices/archivaServices/browseService/rootGroups", {
|
|
||||||
|
$.ajax("restServices/archivaServices/browseService/userRepositories", {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var browseResultEntries = mapbrowseResultEntries(data);
|
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data}));// selected_repository_tmpl
|
||||||
$.log("size:"+browseResultEntries.length);
|
$.ajax("restServices/archivaServices/browseService/rootGroups", {
|
||||||
var browseViewModel = new BrowseViewModel(browseResultEntries,null,null);
|
type: "GET",
|
||||||
ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
|
dataType: 'json',
|
||||||
ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
|
success: function(data) {
|
||||||
enableAutocompleBrowse();
|
var browseResultEntries = mapbrowseResultEntries(data);
|
||||||
|
$.log("size:"+browseResultEntries.length);
|
||||||
|
var browseViewModel = new BrowseViewModel(browseResultEntries,null,null);
|
||||||
|
ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
|
||||||
|
ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
|
||||||
|
enableAutocompleBrowse();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enableAutocompleBrowse=function(groupId){
|
enableAutocompleBrowse=function(groupId){
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="main_browse_result">
|
<div id="main_browse_result">
|
||||||
<div id="main_browse_result_content" class="well">
|
<div id="main_browse_result_content" class="well">
|
||||||
|
<div id="selected_repository"></div>
|
||||||
<div id="browse_breadcrumb" data-bind='template:{name:"browse-breadcrumb-tmpl"}'></div>
|
<div id="browse_breadcrumb" data-bind='template:{name:"browse-breadcrumb-tmpl"}'></div>
|
||||||
<div id="browse_result" class="well" data-bind='template:{name:"browse-groups-tmpl"}'></div>
|
<div id="browse_result" class="well" data-bind='template:{name:"browse-groups-tmpl"}'></div>
|
||||||
<div id="browse_artifact" class="well" data-bind='template:{name:"browse-artifact-tmpl"}'></div>
|
<div id="browse_artifact" class="well" data-bind='template:{name:"browse-artifact-tmpl"}'></div>
|
||||||
|
@ -377,3 +378,12 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script id="selected_repository_tmpl" type="text/html">
|
||||||
|
<select id="repository">
|
||||||
|
{{each(i,repository) repositories}}
|
||||||
|
<option value="${repository}">${repository}</option>
|
||||||
|
{{/each}}
|
||||||
|
</select>
|
||||||
|
</script>
|
Loading…
Reference in New Issue