mirror of https://github.com/apache/archiva.git
[MRM-1721] Chaining user manager implementations.
take care of last changes in redback to be able to track exception when using userManagerImpl. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1419573 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
166d6359ed
commit
48deda62b1
|
@ -49,6 +49,7 @@ import org.apache.archiva.redback.system.DefaultSecuritySession;
|
||||||
import org.apache.archiva.redback.system.SecuritySession;
|
import org.apache.archiva.redback.system.SecuritySession;
|
||||||
import org.apache.archiva.redback.system.SecuritySystem;
|
import org.apache.archiva.redback.system.SecuritySystem;
|
||||||
import org.apache.archiva.redback.users.User;
|
import org.apache.archiva.redback.users.User;
|
||||||
|
import org.apache.archiva.redback.users.UserManagerException;
|
||||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||||
import org.apache.archiva.repository.ContentNotFoundException;
|
import org.apache.archiva.repository.ContentNotFoundException;
|
||||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||||
|
@ -104,7 +105,7 @@ import java.util.TimeZone;
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
* @since 1.4-M1
|
* @since 1.4-M1
|
||||||
*/
|
*/
|
||||||
@Service ( "repositoriesService#rest" )
|
@Service( "repositoriesService#rest" )
|
||||||
public class DefaultRepositoriesService
|
public class DefaultRepositoriesService
|
||||||
extends AbstractRestService
|
extends AbstractRestService
|
||||||
implements RepositoriesService
|
implements RepositoriesService
|
||||||
|
@ -112,7 +113,7 @@ public class DefaultRepositoriesService
|
||||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named ( value = "taskExecutor#indexing" )
|
@Named( value = "taskExecutor#indexing" )
|
||||||
private ArchivaIndexingTaskExecutor archivaIndexingTaskExecutor;
|
private ArchivaIndexingTaskExecutor archivaIndexingTaskExecutor;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -131,14 +132,14 @@ public class DefaultRepositoriesService
|
||||||
private RepositoryContentFactory repositoryFactory;
|
private RepositoryContentFactory repositoryFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named ( value = "archivaTaskScheduler#repository" )
|
@Named( value = "archivaTaskScheduler#repository" )
|
||||||
private ArchivaTaskScheduler scheduler;
|
private ArchivaTaskScheduler scheduler;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DownloadRemoteIndexScheduler downloadRemoteIndexScheduler;
|
private DownloadRemoteIndexScheduler downloadRemoteIndexScheduler;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named ( value = "repositorySessionFactory" )
|
@Named( value = "repositorySessionFactory" )
|
||||||
protected RepositorySessionFactory repositorySessionFactory;
|
protected RepositorySessionFactory repositorySessionFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -298,6 +299,10 @@ public class DefaultRepositoriesService
|
||||||
{
|
{
|
||||||
throw new ArchivaRestServiceException( "user " + userName + " not found", e );
|
throw new ArchivaRestServiceException( "user " + userName + " not found", e );
|
||||||
}
|
}
|
||||||
|
catch ( UserManagerException e )
|
||||||
|
{
|
||||||
|
throw new ArchivaRestServiceException( "ArchivaRestServiceException:" + e.getMessage(), e );
|
||||||
|
}
|
||||||
|
|
||||||
// check karma on source : read
|
// check karma on source : read
|
||||||
AuthenticationResult authn = new AuthenticationResult( true, userName, null );
|
AuthenticationResult authn = new AuthenticationResult( true, userName, null );
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.archiva.redback.system.DefaultSecuritySession;
|
||||||
import org.apache.archiva.redback.system.SecuritySession;
|
import org.apache.archiva.redback.system.SecuritySession;
|
||||||
import org.apache.archiva.redback.system.SecuritySystem;
|
import org.apache.archiva.redback.system.SecuritySystem;
|
||||||
import org.apache.archiva.redback.users.User;
|
import org.apache.archiva.redback.users.User;
|
||||||
|
import org.apache.archiva.redback.users.UserManagerException;
|
||||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -113,9 +114,13 @@ public class ArchivaServletAuthenticator
|
||||||
throw new UnauthorizedException( e.getMessage(), e );
|
throw new UnauthorizedException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( AuthorizationException e )
|
catch ( AuthorizationException e )
|
||||||
|
{
|
||||||
|
throw new UnauthorizedException( e.getMessage(), e );
|
||||||
|
} catch ( UserManagerException e )
|
||||||
{
|
{
|
||||||
throw new UnauthorizedException( e.getMessage(), e );
|
throw new UnauthorizedException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.archiva.redback.system.DefaultSecuritySession;
|
||||||
import org.apache.archiva.redback.system.SecuritySession;
|
import org.apache.archiva.redback.system.SecuritySession;
|
||||||
import org.apache.archiva.redback.system.SecuritySystem;
|
import org.apache.archiva.redback.system.SecuritySystem;
|
||||||
import org.apache.archiva.redback.users.User;
|
import org.apache.archiva.redback.users.User;
|
||||||
|
import org.apache.archiva.redback.users.UserManagerException;
|
||||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -43,7 +44,7 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* DefaultUserRepositories
|
* DefaultUserRepositories
|
||||||
*/
|
*/
|
||||||
@Service ( "userRepositories" )
|
@Service( "userRepositories" )
|
||||||
public class DefaultUserRepositories
|
public class DefaultUserRepositories
|
||||||
implements UserRepositories
|
implements UserRepositories
|
||||||
{
|
{
|
||||||
|
@ -151,6 +152,10 @@ public class DefaultUserRepositories
|
||||||
{
|
{
|
||||||
throw new PrincipalNotFoundException( "Unable to find principal " + principal + "", e );
|
throw new PrincipalNotFoundException( "Unable to find principal " + principal + "", e );
|
||||||
}
|
}
|
||||||
|
catch ( UserManagerException e )
|
||||||
|
{
|
||||||
|
throw new ArchivaSecurityException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
|
||||||
if ( user.isLocked() )
|
if ( user.isLocked() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||||
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
|
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
|
||||||
import org.apache.archiva.redback.users.User;
|
import org.apache.archiva.redback.users.User;
|
||||||
import org.apache.archiva.redback.users.UserManager;
|
import org.apache.archiva.redback.users.UserManager;
|
||||||
|
import org.apache.archiva.redback.users.UserManagerException;
|
||||||
import org.apache.archiva.redback.users.UserManagerListener;
|
import org.apache.archiva.redback.users.UserManagerListener;
|
||||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||||
import org.apache.archiva.redback.users.UserQuery;
|
import org.apache.archiva.redback.users.UserQuery;
|
||||||
|
@ -81,12 +82,14 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User addUser( User user )
|
public User addUser( User user )
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerPerId.get( user.getUserManagerId() ).addUser( user );
|
return userManagerPerId.get( user.getUserManagerId() ).addUser( user );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addUserUnchecked( User user )
|
public void addUserUnchecked( User user )
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
userManagerPerId.get( user.getUserManagerId() ).addUserUnchecked( user );
|
userManagerPerId.get( user.getUserManagerId() ).addUserUnchecked( user );
|
||||||
}
|
}
|
||||||
|
@ -105,6 +108,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User createUser( String username, String fullName, String emailAddress )
|
public User createUser( String username, String fullName, String emailAddress )
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
UserManager userManager = findFirstWritable();
|
UserManager userManager = findFirstWritable();
|
||||||
if ( userManager == null )
|
if ( userManager == null )
|
||||||
|
@ -123,7 +127,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteUser( String username )
|
public void deleteUser( String username )
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
UserManager userManager = findFirstWritable();
|
UserManager userManager = findFirstWritable();
|
||||||
if ( userManager == null )
|
if ( userManager == null )
|
||||||
|
@ -144,10 +148,10 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User findUser( String username )
|
public User findUser( String username )
|
||||||
throws UserNotFoundException
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
User user = null;
|
User user = null;
|
||||||
UserNotFoundException lastException = null;
|
UserManagerException lastException = null;
|
||||||
for ( UserManager userManager : userManagerPerId.values() )
|
for ( UserManager userManager : userManagerPerId.values() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -162,12 +166,19 @@ public class ArchivaConfigurableUsersManager
|
||||||
{
|
{
|
||||||
lastException = e;
|
lastException = e;
|
||||||
}
|
}
|
||||||
|
catch ( UserManagerException e )
|
||||||
|
{
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( user == null )
|
if ( user == null )
|
||||||
|
{
|
||||||
|
if ( lastException != null )
|
||||||
{
|
{
|
||||||
throw lastException;
|
throw lastException;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +186,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User getGuestUser()
|
public User getGuestUser()
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
User user = null;
|
User user = null;
|
||||||
UserNotFoundException lastException = null;
|
UserNotFoundException lastException = null;
|
||||||
|
@ -205,6 +216,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
List<User> users = new ArrayList<User>();
|
List<User> users = new ArrayList<User>();
|
||||||
|
|
||||||
|
@ -221,6 +233,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
List<User> users = new ArrayList<User>();
|
List<User> users = new ArrayList<User>();
|
||||||
|
|
||||||
|
@ -237,6 +250,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsersByQuery( UserQuery query )
|
public List<User> findUsersByQuery( UserQuery query )
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
List<User> users = new ArrayList<User>();
|
List<User> users = new ArrayList<User>();
|
||||||
|
|
||||||
|
@ -253,6 +267,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
List<User> users = new ArrayList<User>();
|
List<User> users = new ArrayList<User>();
|
||||||
|
|
||||||
|
@ -275,6 +290,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getUsers()
|
public List<User> getUsers()
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
List<User> users = new ArrayList<User>();
|
List<User> users = new ArrayList<User>();
|
||||||
|
|
||||||
|
@ -291,6 +307,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getUsers( boolean orderAscending )
|
public List<User> getUsers( boolean orderAscending )
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
List<User> users = new ArrayList<User>();
|
List<User> users = new ArrayList<User>();
|
||||||
|
|
||||||
|
@ -314,14 +331,14 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User updateUser( User user )
|
public User updateUser( User user )
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerPerId.get( user.getUserManagerId() ).updateUser( user );
|
return userManagerPerId.get( user.getUserManagerId() ).updateUser( user );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User updateUser( User user, boolean passwordChangeRequired )
|
public User updateUser( User user, boolean passwordChangeRequired )
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException, UserManagerException
|
||||||
{
|
{
|
||||||
return userManagerPerId.get( user.getUserManagerId() ).updateUser( user, passwordChangeRequired );
|
return userManagerPerId.get( user.getUserManagerId() ).updateUser( user, passwordChangeRequired );
|
||||||
}
|
}
|
||||||
|
@ -382,6 +399,7 @@ public class ArchivaConfigurableUsersManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User createGuestUser()
|
public User createGuestUser()
|
||||||
|
throws UserManagerException
|
||||||
{
|
{
|
||||||
return findFirstWritable().createGuestUser();
|
return findFirstWritable().createGuestUser();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue