mirror of https://github.com/apache/archiva.git
[MRM-780] Access to indexes files with a browser is not possible
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@649910 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c2c71dd5ec
commit
7875facb9b
|
@ -124,8 +124,10 @@ public class RepositoryServlet
|
||||||
final String msg = "Should throw " + UnauthorizedDavException.class.getName();
|
final String msg = "Should throw " + UnauthorizedDavException.class.getName();
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
webdavResponse.sendError(e.getErrorCode(), msg);
|
webdavResponse.sendError(e.getErrorCode(), msg);
|
||||||
|
} else if ( e.getCause() != null ) {
|
||||||
|
webdavResponse.sendError(e.getErrorCode(), e.getCause().getMessage());
|
||||||
} else {
|
} else {
|
||||||
webdavResponse.sendError(e);
|
webdavResponse.sendError(e.getErrorCode(), e.getMessage());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
getDavSessionProvider().releaseSession(webdavRequest);
|
getDavSessionProvider().releaseSession(webdavRequest);
|
||||||
|
|
|
@ -23,6 +23,12 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
import org.apache.maven.archiva.configuration.Configuration;
|
||||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
|
|
||||||
|
import com.meterware.httpunit.GetMethodWebRequest;
|
||||||
|
import com.meterware.httpunit.HttpNotFoundException;
|
||||||
|
import com.meterware.httpunit.HttpUnitOptions;
|
||||||
|
import com.meterware.httpunit.WebRequest;
|
||||||
|
import com.meterware.httpunit.WebResponse;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,4 +97,34 @@ public class RepositoryServletTest
|
||||||
// check other is still intact
|
// check other is still intact
|
||||||
assertRepositoryValid( servlet, REPOID_INTERNAL );
|
assertRepositoryValid( servlet, REPOID_INTERNAL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetRepositoryInvalidPathPassthroughPresent()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
String path = REQUEST_PATH + ".index/filecontent/segments.gen";
|
||||||
|
|
||||||
|
populateRepo( repoRootInternal, ".index/filecontent/segments.gen", "index file" );
|
||||||
|
|
||||||
|
WebRequest request = new GetMethodWebRequest( path );
|
||||||
|
WebResponse response = sc.getResponse( request );
|
||||||
|
assertResponseOK( response );
|
||||||
|
assertEquals( "index file", response.getText() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetRepositoryInvalidPathPassthroughMissing()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
String path = REQUEST_PATH + ".index/filecontent/foo.bar";
|
||||||
|
|
||||||
|
WebRequest request = new GetMethodWebRequest( path );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sc.getResponse( request );
|
||||||
|
fail( "should have been not found" );
|
||||||
|
}
|
||||||
|
catch ( HttpNotFoundException e )
|
||||||
|
{
|
||||||
|
assertEquals( "Error on HTTP request: 404 Invalid path to Artifact: legacy paths should have an expected type ending in [s] in the second part of the path. [http://machine.com/repository/internal/.index/filecontent/foo.bar]", e.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,29 +148,32 @@ public class ArchivaDavResourceFactory implements DavResourceFactory, Auditable
|
||||||
{
|
{
|
||||||
// At this point the incoming request can either be in default or
|
// At this point the incoming request can either be in default or
|
||||||
// legacy layout format.
|
// legacy layout format.
|
||||||
|
boolean fromProxy = fetchContentFromProxies(managedRepository, request, logicalResource );
|
||||||
|
|
||||||
|
boolean previouslyExisted = resourceFile.exists();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boolean fromProxy = fetchContentFromProxies(managedRepository, request, logicalResource );
|
|
||||||
|
|
||||||
// Perform an adjustment of the resource to the managed
|
// Perform an adjustment of the resource to the managed
|
||||||
// repository expected path.
|
// repository expected path.
|
||||||
String localResourcePath = repositoryRequest.toNativePath( logicalResource.getPath(), managedRepository );
|
String localResourcePath = repositoryRequest.toNativePath( logicalResource.getPath(), managedRepository );
|
||||||
resourceFile = new File( managedRepository.getRepoRoot(), localResourcePath );
|
resourceFile = new File( managedRepository.getRepoRoot(), localResourcePath );
|
||||||
|
|
||||||
boolean previouslyExisted = resourceFile.exists();
|
|
||||||
|
|
||||||
// Attempt to fetch the resource from any defined proxy.
|
|
||||||
if ( fromProxy )
|
|
||||||
{
|
|
||||||
processAuditEvents(request, locator.getWorkspaceName(), logicalResource.getPath(), previouslyExisted, resourceFile, " (proxied)");
|
|
||||||
}
|
|
||||||
resource = new ArchivaDavResource(resourceFile.getAbsolutePath(), logicalResource.getPath(), mimeTypes, locator, this, null);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( LayoutException e )
|
catch ( LayoutException e )
|
||||||
{
|
{
|
||||||
|
if ( previouslyExisted )
|
||||||
|
{
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
throw new DavException(HttpServletResponse.SC_NOT_FOUND, e);
|
throw new DavException(HttpServletResponse.SC_NOT_FOUND, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to fetch the resource from any defined proxy.
|
||||||
|
if ( fromProxy )
|
||||||
|
{
|
||||||
|
processAuditEvents(request, locator.getWorkspaceName(), logicalResource.getPath(), previouslyExisted, resourceFile, " (proxied)");
|
||||||
|
}
|
||||||
|
resource = new ArchivaDavResource(resourceFile.getAbsolutePath(), logicalResource.getPath(), mimeTypes, locator, this, null);
|
||||||
}
|
}
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue