From 0f07e0019f4a532ce0cb6b0df685ba18d106b243 Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Wed, 21 May 2008 01:39:40 +0000 Subject: [PATCH] [MRM-694] -put authorization check for virtual repos git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@658525 13f79535-47bb-0310-9956-ffa450edef68 --- .../webdav/ArchivaDavResourceFactory.java | 23 +++++++++++-------- .../archiva/webdav/util/IndexWriter.java | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java index f8f71dfbc..4ee011dc6 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java @@ -147,7 +147,7 @@ public class ArchivaDavResourceFactory // handle browse requests for virtual repos if ( RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ).endsWith( "/" ) ) { - return getResource( repositories, archivaLocator ); + return getResource( request, repositories, archivaLocator ); } } else @@ -664,7 +664,7 @@ public class ArchivaDavResourceFactory } } - private DavResource getResource( List repositories, ArchivaDavResourceLocator locator ) + private DavResource getResource( DavServletRequest request, List repositories, ArchivaDavResourceLocator locator ) throws DavException { List mergedRepositoryContents = new ArrayList(); @@ -685,15 +685,18 @@ public class ArchivaDavResourceFactory repository + ">" ); } - if ( !locator.getResourcePath().startsWith( ArchivaVirtualDavResource.HIDDEN_PATH_PREFIX ) ) + if( isAuthorized( request, repository ) ) { - if( managedRepository != null ) - { - File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource.getPath() ); - if( resourceFile.exists() ) - { - mergedRepositoryContents.add( resourceFile ); - } + if ( !locator.getResourcePath().startsWith( ArchivaVirtualDavResource.HIDDEN_PATH_PREFIX ) ) + { + if( managedRepository != null ) + { + File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource.getPath() ); + if( resourceFile.exists() ) + { + mergedRepositoryContents.add( resourceFile ); + } + } } } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/IndexWriter.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/IndexWriter.java index 3c6b07f20..4854344a2 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/IndexWriter.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/IndexWriter.java @@ -129,8 +129,7 @@ public class IndexWriter for( File resource : localResources ) { List files = new ArrayList( Arrays.asList( resource.listFiles() ) ); - Collections.sort( files ); - + for ( File file : files ) { if( uniqueChildFiles.get( file.getName() ) == null ) @@ -142,6 +141,7 @@ public class IndexWriter List uniqueChildFilesInList = new ArrayList(); uniqueChildFilesInList.addAll( uniqueChildFiles.values() ); + Collections.sort( uniqueChildFilesInList ); for ( File file : uniqueChildFilesInList ) { -- 2.39.5