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.SecuritySystem;
|
||||
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.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
|
@ -104,7 +105,7 @@ import java.util.TimeZone;
|
|||
* @author Olivier Lamy
|
||||
* @since 1.4-M1
|
||||
*/
|
||||
@Service ( "repositoriesService#rest" )
|
||||
@Service( "repositoriesService#rest" )
|
||||
public class DefaultRepositoriesService
|
||||
extends AbstractRestService
|
||||
implements RepositoriesService
|
||||
|
@ -112,7 +113,7 @@ public class DefaultRepositoriesService
|
|||
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
@Inject
|
||||
@Named ( value = "taskExecutor#indexing" )
|
||||
@Named( value = "taskExecutor#indexing" )
|
||||
private ArchivaIndexingTaskExecutor archivaIndexingTaskExecutor;
|
||||
|
||||
@Inject
|
||||
|
@ -131,14 +132,14 @@ public class DefaultRepositoriesService
|
|||
private RepositoryContentFactory repositoryFactory;
|
||||
|
||||
@Inject
|
||||
@Named ( value = "archivaTaskScheduler#repository" )
|
||||
@Named( value = "archivaTaskScheduler#repository" )
|
||||
private ArchivaTaskScheduler scheduler;
|
||||
|
||||
@Inject
|
||||
private DownloadRemoteIndexScheduler downloadRemoteIndexScheduler;
|
||||
|
||||
@Inject
|
||||
@Named ( value = "repositorySessionFactory" )
|
||||
@Named( value = "repositorySessionFactory" )
|
||||
protected RepositorySessionFactory repositorySessionFactory;
|
||||
|
||||
@Inject
|
||||
|
@ -298,6 +299,10 @@ public class DefaultRepositoriesService
|
|||
{
|
||||
throw new ArchivaRestServiceException( "user " + userName + " not found", e );
|
||||
}
|
||||
catch ( UserManagerException e )
|
||||
{
|
||||
throw new ArchivaRestServiceException( "ArchivaRestServiceException:" + e.getMessage(), e );
|
||||
}
|
||||
|
||||
// check karma on source : read
|
||||
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.SecuritySystem;
|
||||
import org.apache.archiva.redback.users.User;
|
||||
import org.apache.archiva.redback.users.UserManagerException;
|
||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -113,9 +114,13 @@ public class ArchivaServletAuthenticator
|
|||
throw new UnauthorizedException( e.getMessage(), e );
|
||||
}
|
||||
catch ( AuthorizationException e )
|
||||
{
|
||||
throw new UnauthorizedException( e.getMessage(), e );
|
||||
} catch ( UserManagerException 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.SecuritySystem;
|
||||
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.security.common.ArchivaRoleConstants;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -43,7 +44,7 @@ import java.util.List;
|
|||
/**
|
||||
* DefaultUserRepositories
|
||||
*/
|
||||
@Service ( "userRepositories" )
|
||||
@Service( "userRepositories" )
|
||||
public class DefaultUserRepositories
|
||||
implements UserRepositories
|
||||
{
|
||||
|
@ -151,6 +152,10 @@ public class DefaultUserRepositories
|
|||
{
|
||||
throw new PrincipalNotFoundException( "Unable to find principal " + principal + "", e );
|
||||
}
|
||||
catch ( UserManagerException e )
|
||||
{
|
||||
throw new ArchivaSecurityException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
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.redback.users.User;
|
||||
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.UserNotFoundException;
|
||||
import org.apache.archiva.redback.users.UserQuery;
|
||||
|
@ -81,12 +82,14 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public User addUser( User user )
|
||||
throws UserManagerException
|
||||
{
|
||||
return userManagerPerId.get( user.getUserManagerId() ).addUser( user );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUserUnchecked( User user )
|
||||
throws UserManagerException
|
||||
{
|
||||
userManagerPerId.get( user.getUserManagerId() ).addUserUnchecked( user );
|
||||
}
|
||||
|
@ -105,6 +108,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public User createUser( String username, String fullName, String emailAddress )
|
||||
throws UserManagerException
|
||||
{
|
||||
UserManager userManager = findFirstWritable();
|
||||
if ( userManager == null )
|
||||
|
@ -123,7 +127,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public void deleteUser( String username )
|
||||
throws UserNotFoundException
|
||||
throws UserNotFoundException, UserManagerException
|
||||
{
|
||||
UserManager userManager = findFirstWritable();
|
||||
if ( userManager == null )
|
||||
|
@ -144,10 +148,10 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public User findUser( String username )
|
||||
throws UserNotFoundException
|
||||
throws UserManagerException
|
||||
{
|
||||
User user = null;
|
||||
UserNotFoundException lastException = null;
|
||||
UserManagerException lastException = null;
|
||||
for ( UserManager userManager : userManagerPerId.values() )
|
||||
{
|
||||
try
|
||||
|
@ -162,11 +166,18 @@ public class ArchivaConfigurableUsersManager
|
|||
{
|
||||
lastException = e;
|
||||
}
|
||||
catch ( UserManagerException e )
|
||||
{
|
||||
lastException = e;
|
||||
}
|
||||
}
|
||||
|
||||
if ( user == null )
|
||||
{
|
||||
throw lastException;
|
||||
if ( lastException != null )
|
||||
{
|
||||
throw lastException;
|
||||
}
|
||||
}
|
||||
|
||||
return user;
|
||||
|
@ -175,7 +186,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public User getGuestUser()
|
||||
throws UserNotFoundException
|
||||
throws UserNotFoundException, UserManagerException
|
||||
{
|
||||
User user = null;
|
||||
UserNotFoundException lastException = null;
|
||||
|
@ -205,6 +216,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
||||
throws UserManagerException
|
||||
{
|
||||
List<User> users = new ArrayList<User>();
|
||||
|
||||
|
@ -221,6 +233,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
||||
throws UserManagerException
|
||||
{
|
||||
List<User> users = new ArrayList<User>();
|
||||
|
||||
|
@ -237,6 +250,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public List<User> findUsersByQuery( UserQuery query )
|
||||
throws UserManagerException
|
||||
{
|
||||
List<User> users = new ArrayList<User>();
|
||||
|
||||
|
@ -253,6 +267,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
||||
throws UserManagerException
|
||||
{
|
||||
List<User> users = new ArrayList<User>();
|
||||
|
||||
|
@ -275,6 +290,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public List<User> getUsers()
|
||||
throws UserManagerException
|
||||
{
|
||||
List<User> users = new ArrayList<User>();
|
||||
|
||||
|
@ -291,6 +307,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public List<User> getUsers( boolean orderAscending )
|
||||
throws UserManagerException
|
||||
{
|
||||
List<User> users = new ArrayList<User>();
|
||||
|
||||
|
@ -314,14 +331,14 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public User updateUser( User user )
|
||||
throws UserNotFoundException
|
||||
throws UserNotFoundException, UserManagerException
|
||||
{
|
||||
return userManagerPerId.get( user.getUserManagerId() ).updateUser( user );
|
||||
}
|
||||
|
||||
@Override
|
||||
public User updateUser( User user, boolean passwordChangeRequired )
|
||||
throws UserNotFoundException
|
||||
throws UserNotFoundException, UserManagerException
|
||||
{
|
||||
return userManagerPerId.get( user.getUserManagerId() ).updateUser( user, passwordChangeRequired );
|
||||
}
|
||||
|
@ -382,6 +399,7 @@ public class ArchivaConfigurableUsersManager
|
|||
|
||||
@Override
|
||||
public User createGuestUser()
|
||||
throws UserManagerException
|
||||
{
|
||||
return findFirstWritable().createGuestUser();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue