return true;
}
- public boolean isAuthorizedToAccessVirtualRepository( String principal, String repoId )
+ public boolean isAuthorized( String principal, String repoId )
throws UnauthorizedException
{
try
public boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId,
boolean isWriteRequest ) throws AuthorizationException, UnauthorizedException;
- public boolean isAuthorizedToAccessVirtualRepository( String principal, String repoId )
+ public boolean isAuthorized( String principal, String repoId )
throws UnauthorizedException;
}
}
catch ( AuthenticationException e )
{
+ // safety check for MRM-911
+ String guest = archivaXworkUser.getGuest();
+ try
+ {
+ if( servletAuth.isAuthorized( guest,
+ ( ( ArchivaDavResourceLocator ) request.getRequestLocator() ).getRepositoryId() ) )
+ {
+ return true;
+ }
+ }
+ catch ( UnauthorizedException ae )
+ {
+ throw new UnauthorizedDavException( repositoryId,
+ "You are not authenticated and authorized to access any repository." );
+ }
+
throw new UnauthorizedDavException( repositoryId, "You are not authenticated" );
}
catch ( MustChangePasswordException e )
// for the current user logged in
try
{
- if( servletAuth.isAuthorizedToAccessVirtualRepository( activePrincipal, repository ) )
+ if( servletAuth.isAuthorized( activePrincipal, repository ) )
{
getResource( locator, mergedRepositoryContents, logicalResource, repository );
}
{
try
{
- if( servletAuth.isAuthorizedToAccessVirtualRepository( activePrincipal, repository ) )
+ if( servletAuth.isAuthorized( activePrincipal, repository ) )
{
allow = true;
break;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavServletRequest;
import org.apache.maven.archiva.webdav.util.RepositoryPathUtil;
+import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.apache.maven.archiva.security.ServletAuthenticator;
import org.codehaus.plexus.redback.authentication.AuthenticationException;
import org.codehaus.plexus.redback.authentication.AuthenticationResult;
+import org.codehaus.plexus.redback.authorization.UnauthorizedException;
import org.codehaus.plexus.redback.policy.MustChangePasswordException;
import org.codehaus.plexus.redback.policy.AccountLockedException;
import org.codehaus.plexus.redback.xwork.filter.authentication.HttpAuthenticator;
private HttpAuthenticator httpAuth;
- public ArchivaDavSessionProvider( ServletAuthenticator servletAuth, HttpAuthenticator httpAuth )
+ private ArchivaXworkUser archivaXworkUser;
+
+ public ArchivaDavSessionProvider( ServletAuthenticator servletAuth, HttpAuthenticator httpAuth, ArchivaXworkUser archivaXworkUser )
{
this.servletAuth = servletAuth;
this.httpAuth = httpAuth;
+ this.archivaXworkUser = archivaXworkUser;
}
public boolean attachSession( WebdavRequest request )
}
catch ( AuthenticationException e )
{
- throw new UnauthorizedDavException( repositoryId, "You are not authenticated" );
+ // safety check for MRM-911
+ String guest = archivaXworkUser.getGuest();
+ try
+ {
+ if( servletAuth.isAuthorized( guest,
+ ( ( ArchivaDavResourceLocator ) request.getRequestLocator() ).getRepositoryId() ) )
+ {
+ request.setDavSession(new ArchivaDavSession());
+ return true;
+ }
+ }
+ catch ( UnauthorizedException ae )
+ {
+ throw new UnauthorizedDavException( repositoryId,
+ "You are not authenticated and authorized to access any repository." );
+ }
+
+ throw new UnauthorizedDavException( repositoryId, "You are not authenticated." );
}
catch ( MustChangePasswordException e )
{
import org.apache.maven.archiva.configuration.ConfigurationEvent;
import org.apache.maven.archiva.configuration.ConfigurationListener;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.apache.maven.archiva.security.ServletAuthenticator;
import org.codehaus.plexus.redback.xwork.filter.authentication.HttpAuthenticator;
import org.codehaus.plexus.spring.PlexusToSpringUtils;
HttpAuthenticator httpAuth =
(HttpAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( HttpAuthenticator.ROLE, "basic" ) );
- sessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth );
+ ArchivaXworkUser archivaXworkUser =
+ (ArchivaXworkUser) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaXworkUser.class.getName() ) );
+ sessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth, archivaXworkUser );
}
public void configurationEvent( ConfigurationEvent event )
throws Exception
{
super.setUp();
- sessionProvider = new ArchivaDavSessionProvider(new ServletAuthenticatorMock(), new HttpAuthenticatorMock());
+ sessionProvider = new ArchivaDavSessionProvider(new ServletAuthenticatorMock(), new HttpAuthenticatorMock(), null);
request = new WebdavRequestImpl(new HttpServletRequestMock(), null);
}
return true;
}
- public boolean isAuthorizedToAccessVirtualRepository(String arg0, String arg1)
+ public boolean isAuthorized(String arg0, String arg1)
throws UnauthorizedException
{
return true;
{
public UnauthenticatedDavSessionProvider()
{
- super(null, null);
+ super(null, null, null);
}
@Override