UserManagerException is now a checked Exception

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1419568 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-10 16:34:46 +00:00
parent e0dc1a1966
commit 30c1cfa2a4
33 changed files with 504 additions and 264 deletions

View File

@ -32,6 +32,7 @@ import org.apache.archiva.redback.policy.PolicyViolationException;
import org.apache.archiva.redback.policy.UserSecurityPolicy;
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.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -47,14 +48,14 @@ import java.util.Map;
*
* @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
*/
@Service ("authenticator#user-manager")
@Service("authenticator#user-manager")
public class UserManagerAuthenticator
implements Authenticator
{
private Logger log = LoggerFactory.getLogger( getClass() );
@Inject
@Named (value = "userManager#configurable")
@Named(value = "userManager#configurable")
private UserManager userManager;
@Inject
@ -152,6 +153,14 @@ public class UserManagerAuthenticator
authnResultExceptionsMap.put( AuthenticationConstants.AUTHN_NO_SUCH_USER,
"Login for user " + source.getPrincipal() + " failed. user not found." );
}
catch ( UserManagerException e )
{
log.warn( "Login for user {} failed, message: {}", source.getPrincipal(), e.getMessage() );
resultException = e;
authnResultExceptionsMap.put( AuthenticationConstants.AUTHN_RUNTIME_EXCEPTION,
"Login for user " + source.getPrincipal() + " failed, message: "
+ e.getMessage() );
}
return new AuthenticationResult( authenticationSuccess, username, resultException, authnResultExceptionsMap );
}

View File

@ -24,6 +24,7 @@ import org.apache.archiva.redback.authentication.Authenticator;
import org.apache.archiva.redback.policy.MustChangePasswordException;
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.UserNotFoundException;
import org.apache.archiva.redback.authentication.AuthenticationException;
import org.apache.archiva.redback.authentication.AuthenticationResult;
@ -46,8 +47,8 @@ import java.util.Date;
*
* @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
*/
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" })
public class UserManagerAuthenticatorTest
extends TestCase
{
@ -117,7 +118,7 @@ public class UserManagerAuthenticatorTest
@Test
public void testAuthenticateLockedPassword()
throws AuthenticationException, MustChangePasswordException, UserNotFoundException
throws AuthenticationException, MustChangePasswordException, UserNotFoundException, UserManagerException
{
userSecurityPolicy.setEnabled( true );
@ -156,7 +157,7 @@ public class UserManagerAuthenticatorTest
@Test
public void testAuthenticateExpiredPassword()
throws AuthenticationException, AccountLockedException, UserNotFoundException
throws AuthenticationException, AccountLockedException, UserNotFoundException, UserManagerException
{
userSecurityPolicy.setEnabled( true );
userSecurityPolicy.setPasswordExpirationDays( 15 );

View File

@ -23,6 +23,7 @@ import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.keys.KeyManager;
import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.rbac.RbacManagerException;
import org.apache.archiva.redback.users.UserManagerException;
import javax.xml.stream.XMLStreamException;
import java.io.File;
@ -38,7 +39,7 @@ public interface DataManagementTool
throws RbacManagerException, IOException, XMLStreamException;
void backupUserDatabase( UserManager manager, File backupDirectory )
throws IOException, XMLStreamException;
throws IOException, XMLStreamException, UserManagerException;
void backupKeyDatabase( KeyManager manager, File backupDirectory )
throws IOException, XMLStreamException;
@ -47,7 +48,7 @@ public interface DataManagementTool
throws IOException, XMLStreamException, RbacManagerException;
void restoreUsersDatabase( UserManager manager, File backupDirectory )
throws IOException, XMLStreamException;
throws IOException, XMLStreamException, UserManagerException;
void restoreKeysDatabase( KeyManager manager, File backupDirectory )
throws IOException, XMLStreamException;

View File

@ -52,6 +52,7 @@ import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.rbac.Resource;
import org.apache.archiva.redback.rbac.UserAssignment;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.jdo.UserDatabase;
import org.apache.archiva.redback.users.jdo.io.stax.UsersManagementStaxReader;
import org.apache.archiva.redback.users.jdo.io.stax.UsersManagementStaxWriter;
@ -97,7 +98,7 @@ public class JdoDataManagementTool
}
public void backupUserDatabase( UserManager manager, File backupDirectory )
throws IOException, XMLStreamException
throws IOException, XMLStreamException, UserManagerException
{
UserDatabase database = new UserDatabase();
database.setUsers( manager.getUsers() );
@ -232,7 +233,7 @@ public class JdoDataManagementTool
@SuppressWarnings("unchecked")
public void restoreUsersDatabase( UserManager manager, File backupDirectory )
throws IOException, XMLStreamException
throws IOException, XMLStreamException, UserManagerException
{
UsersManagementStaxReader reader = new UsersManagementStaxReader();

View File

@ -28,6 +28,7 @@ import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.rbac.Role;
import org.apache.archiva.redback.rbac.UserAssignment;
import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.SystemUtils;
@ -56,8 +57,8 @@ import java.util.List;
import java.util.Locale;
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" })
public class DataManagementTest
extends TestCase
{
@ -67,20 +68,20 @@ public class DataManagementTest
private File targetDirectory;
@Inject
@Named( value = "jdoFactory#users" )
@Named(value = "jdoFactory#users")
UserConfigurableJdoFactory jdoFactory;
@Inject
@Named( value = "userManager#jdo" )
@Named(value = "userManager#jdo")
UserManager userManager;
@Inject
@Named( value = "keyManager#jdo" )
@Named(value = "keyManager#jdo")
KeyManager keyManager;
@Inject
@Named( value = "rBACManager#jdo" )
@Named(value = "rBACManager#jdo")
RBACManager rbacManager;
@Before
@ -184,6 +185,7 @@ public class DataManagementTest
}
private void createUserDatabase( UserManager manager )
throws UserManagerException
{
User user = manager.createUser( "smcqueen", "Steve McQueen", "the cooler king" );
user.setPassword( "abc123" );
@ -250,7 +252,7 @@ public class DataManagementTest
FileWriter fw = new FileWriter( backupFile );
IOUtils.copy( is, fw);
IOUtils.copy( is, fw );
is.close();
@ -373,6 +375,7 @@ public class DataManagementTest
}
private void assertEmpty( UserManager manager )
throws UserManagerException
{
List<User> users = manager.getUsers();
assertEquals( 0, users.size() );
@ -392,7 +395,7 @@ public class DataManagementTest
FileWriter fw = new FileWriter( backupFile );
IOUtils.copy( getClass().getResourceAsStream( "/expected-keys.xml" ), fw);
IOUtils.copy( getClass().getResourceAsStream( "/expected-keys.xml" ), fw );
fw.close();

View File

@ -30,6 +30,7 @@ import org.apache.archiva.redback.system.SecuritySystem;
import org.apache.archiva.redback.system.check.EnvironmentCheck;
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.UserNotFoundException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
@ -49,7 +50,7 @@ import java.util.Properties;
* @author Olivier Lamy
* @since 2.0
*/
@Service( "environmentCheck#adminAutoCreateCheck" )
@Service("environmentCheck#adminAutoCreateCheck")
public class AdminAutoCreateCheck
implements EnvironmentCheck
{
@ -65,11 +66,11 @@ public class AdminAutoCreateCheck
public static final String ADMIN_PASSWORD_KEY = "redback.admin.password";
@Inject
@Named( value = "userManager#configurable" )
@Named(value = "userManager#configurable")
private UserManager userManager;
@Inject
@Named( value = "userConfiguration#default" )
@Named(value = "userConfiguration#default")
private UserConfiguration config;
@Inject
@ -79,7 +80,7 @@ public class AdminAutoCreateCheck
private RoleManager roleManager;
@Inject
@Named( value = "rBACManager#cached" )
@Named(value = "rBACManager#cached")
private RBACManager rbacManager;
public void validateEnvironment( List<String> violations )
@ -91,13 +92,15 @@ public class AdminAutoCreateCheck
{
useForceAdminCreationFile();
}
}
catch ( UserNotFoundException e )
{
useForceAdminCreationFile();
}
catch ( UserManagerException e )
{
useForceAdminCreationFile();
}
}
private void useForceAdminCreationFile()

View File

@ -22,6 +22,7 @@ package org.apache.archiva.redback.integration.checks.security;
import org.apache.archiva.redback.policy.UserSecurityPolicy;
import org.apache.archiva.redback.role.RoleManagerException;
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.role.RoleManager;
import org.apache.archiva.redback.system.SecuritySystem;
@ -36,9 +37,8 @@ import java.util.List;
* RequiredRolesEnvironmentCheck:
*
* @author: Jesse McConnell <jesse@codehaus.org>
*
*/
@Service( "environmentCheck#guest-user-check" )
@Service("environmentCheck#guest-user-check")
public class GuestUserEnvironmentCheck
implements EnvironmentCheck
{
@ -64,15 +64,23 @@ public class GuestUserEnvironmentCheck
UserManager userManager = securitySystem.getUserManager();
UserSecurityPolicy policy = securitySystem.getPolicy();
User guest;
User guest = null;
try
{
guest = userManager.getGuestUser();
}
catch ( UserNotFoundException e )
catch ( UserManagerException e )
{
policy.setEnabled( false );
guest = userManager.createGuestUser();
try
{
guest = userManager.createGuestUser();
}
catch ( UserManagerException ume )
{
violations.add( "unable to initialize guest user properly: " + ume.getMessage() );
return;
}
policy.setEnabled( true );
}

View File

@ -26,6 +26,7 @@ import org.apache.archiva.redback.rbac.UserAssignment;
import org.apache.archiva.redback.system.check.EnvironmentCheck;
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.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -41,7 +42,6 @@ import java.util.List;
* and unlocks them on startup.
*
* @author: Jesse McConnell <jesse@codehaus.org>
*
*/
@Service( "environmentCheck#locked-admin-check" )
public class LockedAdminEnvironmentCheck
@ -98,6 +98,11 @@ public class LockedAdminEnvironmentCheck
{
log.warn( "Dangling UserAssignment -> {}", userAssignment.getPrincipal() );
}
catch ( UserManagerException e )
{
log.warn( "fail to find user {} for admin unlock check: {}", userAssignment.getPrincipal(),
e.getMessage() );
}
}
}
catch ( RbacManagerException e )

View File

@ -22,6 +22,7 @@ package org.apache.archiva.redback.integration.filter.authentication;
import org.apache.archiva.redback.authentication.AuthenticationException;
import org.apache.archiva.redback.policy.MustChangePasswordException;
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.authentication.AuthenticationDataSource;
import org.apache.archiva.redback.authentication.AuthenticationResult;
@ -43,7 +44,6 @@ import java.io.IOException;
* HttpAuthenticator
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
public abstract class HttpAuthenticator
{
@ -80,6 +80,11 @@ public abstract class HttpAuthenticator
log.info( "Login attempt against unknown user: {}", ds );
throw new HttpAuthenticationException( "User name or password invalid." );
}
catch ( UserManagerException e )
{
log.info( "UserManagerException: {}", e.getMessage() );
throw new HttpAuthenticationException( e.getMessage(), e );
}
}
/**
@ -176,28 +181,5 @@ public abstract class HttpAuthenticator
httpSession.setAttribute( SecuritySession.USERKEY, user );
}
public String storeDefaultUser( String principal, HttpSession httpSession )
{
httpSession.setAttribute( SecuritySession.SESSION_KEY, null );
httpSession.setAttribute( SecuritySession.USERKEY, null );
if ( StringUtils.isEmpty( principal ) )
{
return null;
}
try
{
User user = securitySystem.getUserManager().findUser( principal );
httpSession.setAttribute( SecuritySession.USERKEY, user );
return user.getUsername();
}
catch ( UserNotFoundException e )
{
log.warn( "Default User '" + principal + "' not found.", e );
return null;
}
}
}

View File

@ -22,6 +22,7 @@ package org.apache.archiva.redback.integration.filter.authentication.digest;
import org.apache.archiva.redback.authentication.AuthenticationException;
import org.apache.archiva.redback.policy.MustChangePasswordException;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.commons.codec.binary.Base64;
import org.apache.archiva.redback.authentication.AuthenticationResult;
import org.apache.archiva.redback.authentication.TokenBasedAuthenticationDataSource;
@ -44,14 +45,13 @@ import java.io.IOException;
* HttpDigestAuthentication methods for working with <a href="http://www.faqs.org/rfcs/rfc2617.html">RFC 2617 HTTP Authentication</a>.
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
@Service("httpAuthenticator#digest")
public class HttpDigestAuthentication
extends HttpAuthenticator
{
@Inject
@Named(value="userManager#configurable")
@Named(value = "userManager#configurable")
private UserManager userManager;
/**
@ -61,10 +61,8 @@ public class HttpDigestAuthentication
/**
* NOTE: Must be alphanumeric.
*
*
*/
private String digestKey ="OrycteropusAfer";
private String digestKey = "OrycteropusAfer";
private String realm;
@ -126,6 +124,11 @@ public class HttpDigestAuthentication
log.error( msg, e );
throw new HttpAuthenticationException( msg, e );
}
catch ( UserManagerException e )
{
log.error( "issue find user {}, message: {}", username, e.getMessage(), e );
throw new HttpAuthenticationException( "issue find user " + username + ", message: " + e.getMessage(), e );
}
}
/**
@ -135,7 +138,7 @@ public class HttpDigestAuthentication
* @param response the response to use.
* @param realmName the realm name to state.
* @param exception the exception to base the message off of.
* @throws IOException if there was a problem with the {@link HttpServletResponse#sendError(int,String)} call.
* @throws IOException if there was a problem with the {@link HttpServletResponse#sendError(int, String)} call.
*/
public void challenge( HttpServletRequest request, HttpServletResponse response, String realmName,
AuthenticationException exception )
@ -194,8 +197,8 @@ public class HttpDigestAuthentication
}
else
{
throw new IllegalStateException( "Http Digest Parameter [qop] with value of [" + digestHeader.qop
+ "] is unsupported." );
throw new IllegalStateException(
"Http Digest Parameter [qop] with value of [" + digestHeader.qop + "] is unsupported." );
}
return Digest.md5Hex( digest );

View File

@ -21,6 +21,7 @@ package org.apache.archiva.redback.integration.model;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.commons.lang.StringUtils;
@ -54,6 +55,7 @@ public abstract class UserCredentials
private String timestampLastPasswordChange;
public User createUser( UserManager um )
throws UserManagerException
{
User user = um.createUser( username, fullName, email );

View File

@ -36,6 +36,7 @@ import org.apache.archiva.redback.rest.api.services.LoginService;
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
import org.apache.archiva.redback.system.SecuritySession;
import org.apache.archiva.redback.system.SecuritySystem;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -48,6 +49,7 @@ import javax.servlet.http.HttpSession;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
@ -178,6 +180,14 @@ public class DefaultLoginService
{
return buildRestUser( e.getUser() );
}
catch ( UserManagerException e )
{
log.info( "UserManagerException: {}", e.getMessage() );
List<ErrorMessage> errorMessages =
Arrays.asList( new ErrorMessage().message( "UserManagerException: " + e.getMessage() ) );
throw new RedbackServiceException( errorMessages );
}
}
public Boolean isLogged()

View File

@ -22,6 +22,7 @@ import org.apache.archiva.redback.policy.PasswordEncoder;
import org.apache.archiva.redback.policy.PasswordRuleViolationException;
import org.apache.archiva.redback.policy.PasswordRuleViolations;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.commons.lang.StringUtils;
import org.apache.archiva.redback.keys.AuthenticationKey;
import org.apache.archiva.redback.keys.KeyManagerException;
@ -42,13 +43,14 @@ import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Olivier Lamy
* @since 1.4
*/
@Service( "passwordService#rest" )
@Service("passwordService#rest")
public class DefaultPasswordService
implements PasswordService
{
@ -66,7 +68,7 @@ public class DefaultPasswordService
@Inject
public DefaultPasswordService( SecuritySystem securitySystem,
@Named( "httpAuthenticator#basic" ) HttpAuthenticator httpAuthenticator,
@Named("httpAuthenticator#basic") HttpAuthenticator httpAuthenticator,
PasswordValidator passwordValidator )
{
this.securitySystem = securitySystem;
@ -74,12 +76,12 @@ public class DefaultPasswordService
this.passwordValidator = passwordValidator;
}
public org.apache.archiva.redback.rest.api.model.User changePasswordWithKey( String password, String passwordConfirmation,
String key )
public org.apache.archiva.redback.rest.api.model.User changePasswordWithKey( String password,
String passwordConfirmation,
String key )
throws RedbackServiceException
{
//RedbackRequestInformation redbackRequestInformation = RedbackAuthenticationThreadLocal.get();
String principal = null;
@ -130,6 +132,13 @@ public class DefaultPasswordService
errorMessages.add( errorMessage );
throw new RedbackServiceException( errorMessages );
}
catch ( UserManagerException e )
{
log.info( "UserManagerException: {}", e.getMessage() );
List<ErrorMessage> errorMessages =
Arrays.asList( new ErrorMessage().message( "UserManagerException: " + e.getMessage() ) );
throw new RedbackServiceException( errorMessages );
}
catch ( PasswordRuleViolationException e )
{
PasswordRuleViolations violations = e.getViolations();
@ -147,7 +156,7 @@ public class DefaultPasswordService
}
public org.apache.archiva.redback.rest.api.model.User changePassword( String userName, String previousPassword,
String password, String passwordConfirmation )
String password, String passwordConfirmation )
throws RedbackServiceException
{
if ( StringUtils.isEmpty( userName ) )
@ -203,6 +212,13 @@ public class DefaultPasswordService
throw new RedbackServiceException( new ErrorMessage( "user.not.found" ),
Response.Status.BAD_REQUEST.getStatusCode() );
}
catch ( UserManagerException e )
{
log.info( "UserManagerException: {}", e.getMessage() );
List<ErrorMessage> errorMessages =
Arrays.asList( new ErrorMessage().message( "UserManagerException: " + e.getMessage() ) );
throw new RedbackServiceException( errorMessages );
}
}
}

View File

@ -30,6 +30,7 @@ import org.apache.archiva.redback.role.model.ModelRole;
import org.apache.archiva.redback.role.model.ModelTemplate;
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.UserNotFoundException;
import org.apache.commons.lang.StringUtils;
import org.apache.archiva.redback.integration.model.AdminEditUserCredentials;
@ -62,7 +63,7 @@ import java.util.Set;
* @author Olivier Lamy
* @since 1.3
*/
@Service( "roleManagementService#rest" )
@Service("roleManagementService#rest")
public class DefaultRoleManagementService
implements RoleManagementService
{
@ -77,8 +78,8 @@ public class DefaultRoleManagementService
@Inject
public DefaultRoleManagementService( RoleManager roleManager,
@Named( value = "rBACManager#cached" ) RBACManager rbacManager,
@Named( value = "userManager#cached" ) UserManager userManager )
@Named(value = "rBACManager#cached") RBACManager rbacManager,
@Named(value = "userManager#cached") UserManager userManager )
{
this.roleManager = roleManager;
this.rbacManager = rbacManager;
@ -404,7 +405,8 @@ public class DefaultRoleManagementService
try
{
User user = userManager.findUser( userAssignment.getPrincipal() );
role.getParentsRolesUsers().add( new org.apache.archiva.redback.rest.api.model.User( user ) );
role.getParentsRolesUsers().add(
new org.apache.archiva.redback.rest.api.model.User( user ) );
}
catch ( UserNotFoundException e )
{
@ -418,8 +420,8 @@ public class DefaultRoleManagementService
new ArrayList<org.apache.archiva.redback.rest.api.model.User>();
for ( User u : userManager.getUsers() )
{
org.apache.archiva.redback.rest.api.model.User
user = new org.apache.archiva.redback.rest.api.model.User( u );
org.apache.archiva.redback.rest.api.model.User user =
new org.apache.archiva.redback.rest.api.model.User( u );
if ( role.getParentsRolesUsers().contains( user ) )
{
continue;
@ -439,6 +441,10 @@ public class DefaultRoleManagementService
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}
public Boolean updateRoleDescription( String roleName, String description )
@ -464,14 +470,17 @@ public class DefaultRoleManagementService
for ( org.apache.archiva.redback.rest.api.model.User user : role.getUsers() )
{
String username = user.getUsername();
if ( !userManager.userExists( username ) )
{
log.error( "user {} not exits", username );
throw new RedbackServiceException( new ErrorMessage( "user.not.exists", new String[]{ username } ) );
}
try
{
if ( !userManager.userExists( username ) )
{
log.error( "user {} not exits", username );
throw new RedbackServiceException(
new ErrorMessage( "user.not.exists", new String[]{ username } ) );
}
UserAssignment assignment;
if ( rbacManager.userAssignmentExists( username ) )
@ -493,19 +502,26 @@ public class DefaultRoleManagementService
throw new RedbackServiceException(
new ErrorMessage( "error.assign.role.user", new String[]{ role.getName(), username } ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}
for ( org.apache.archiva.redback.rest.api.model.User user : role.getRemovedUsers() )
{
String username = user.getUsername();
if ( !userManager.userExists( username ) )
{
log.error( "user {} not exits", username );
throw new RedbackServiceException( new ErrorMessage( "user.not.exists", new String[]{ username } ) );
}
try
{
if ( !userManager.userExists( username ) )
{
log.error( "user {} not exits", username );
throw new RedbackServiceException(
new ErrorMessage( "user.not.exists", new String[]{ username } ) );
}
UserAssignment assignment;
if ( rbacManager.userAssignmentExists( username ) )
@ -527,6 +543,10 @@ public class DefaultRoleManagementService
throw new RedbackServiceException(
new ErrorMessage( "error.unassign.role.user", new String[]{ role.getName(), username } ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}
return Boolean.TRUE;
@ -541,13 +561,14 @@ public class DefaultRoleManagementService
throw new RedbackServiceException( new ErrorMessage( "rbac.edit.user.empty.principal" ) );
}
if ( !userManager.userExists( username ) )
{
throw new RedbackServiceException( new ErrorMessage( "user.does.not.exist", new String[]{ username } ) );
}
try
{
if ( !userManager.userExists( username ) )
{
throw new RedbackServiceException(
new ErrorMessage( "user.does.not.exist", new String[]{ username } ) );
}
User u = userManager.findUser( username );
if ( u == null )
@ -562,6 +583,10 @@ public class DefaultRoleManagementService
throw new RedbackServiceException(
new ErrorMessage( "user.does.not.exist", new String[]{ username, e.getMessage() } ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
try
{
// check first if role assignments for user exist
@ -597,18 +622,19 @@ public class DefaultRoleManagementService
applicationRoles.setRoleTemplates( toRoleTemplates( modelApplication.getTemplates() ) );
// cleanup app roles remove roles coming from templates
List<String> appRoleNames = new ArrayList<String>( appRoles.size() );
for (String appRoleName : applicationRoles.getGlobalRoles())
for ( String appRoleName : applicationRoles.getGlobalRoles() )
{
if (!roleFromTemplate( appRoleName, modelApplication.getTemplates() )){
if ( !roleFromTemplate( appRoleName, modelApplication.getTemplates() ) )
{
appRoleNames.add( appRoleName );
}
}
applicationRoles.setGlobalRoles( appRoleNames );
applicationRolesList.add( applicationRoles );
}
@ -635,13 +661,15 @@ public class DefaultRoleManagementService
throw new RedbackServiceException( new ErrorMessage( "rbac.edit.user.empty.principal" ) );
}
if ( !userManager.userExists( username ) )
{
throw new RedbackServiceException( new ErrorMessage( "user.does.not.exist", new String[]{ username } ) );
}
try
{
if ( !userManager.userExists( username ) )
{
throw new RedbackServiceException(
new ErrorMessage( "user.does.not.exist", new String[]{ username } ) );
}
User u = userManager.findUser( username );
if ( u == null )
@ -655,6 +683,10 @@ public class DefaultRoleManagementService
throw new RedbackServiceException(
new ErrorMessage( "user.does.not.exist", new String[]{ username, e.getMessage() } ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
try
{
@ -692,7 +724,7 @@ public class DefaultRoleManagementService
//----------------------------------------------------------------
private org.apache.archiva.redback.rbac.Role isInList( String roleName,
Collection<org.apache.archiva.redback.rbac.Role> roles )
Collection<org.apache.archiva.redback.rbac.Role> roles )
{
for ( org.apache.archiva.redback.rbac.Role role : roles )
{
@ -705,8 +737,8 @@ public class DefaultRoleManagementService
}
private Collection<org.apache.archiva.redback.rbac.Role> filterApplicationRoles( ModelApplication application,
List<org.apache.archiva.redback.rbac.Role> allRoles,
List<ModelTemplate> applicationTemplates )
List<org.apache.archiva.redback.rbac.Role> allRoles,
List<ModelTemplate> applicationTemplates )
{
Set<org.apache.archiva.redback.rbac.Role> applicationRoles =
new HashSet<org.apache.archiva.redback.rbac.Role>();

View File

@ -55,6 +55,7 @@ import org.apache.archiva.redback.role.RoleManager;
import org.apache.archiva.redback.role.RoleManagerException;
import org.apache.archiva.redback.system.SecuritySystem;
import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.UserNotFoundException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@ -159,6 +160,10 @@ public class DefaultUserService
//ignore we just want to prevent non human readable error message from backend :-)
log.debug( "user {} not exists", user.getUsername() );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
// data validation
if ( StringUtils.isEmpty( user.getUsername() ) )
@ -176,29 +181,31 @@ public class DefaultUserService
throw new RedbackServiceException( new ErrorMessage( "email cannot be empty" ) );
}
org.apache.archiva.redback.users.User u =
userManager.createUser( user.getUsername(), user.getFullName(), user.getEmail() );
u.setPassword( user.getPassword() );
u.setLocked( user.isLocked() );
u.setPasswordChangeRequired( user.isPasswordChangeRequired() );
u.setPermanent( user.isPermanent() );
u.setValidated( user.isValidated() );
u = userManager.addUser( u );
if ( !user.isPasswordChangeRequired() )
{
u.setPasswordChangeRequired( false );
try
{
u = userManager.updateUser( u );
log.debug( "user {} created", u.getUsername() );
}
catch ( UserNotFoundException e )
{
throw new RedbackServiceException( e.getMessage() );
}
}
try
{
org.apache.archiva.redback.users.User u =
userManager.createUser( user.getUsername(), user.getFullName(), user.getEmail() );
u.setPassword( user.getPassword() );
u.setLocked( user.isLocked() );
u.setPasswordChangeRequired( user.isPasswordChangeRequired() );
u.setPermanent( user.isPermanent() );
u.setValidated( user.isValidated() );
u = userManager.addUser( u );
if ( !user.isPasswordChangeRequired() )
{
u.setPasswordChangeRequired( false );
try
{
u = userManager.updateUser( u );
log.debug( "user {} created", u.getUsername() );
}
catch ( UserNotFoundException e )
{
throw new RedbackServiceException( e.getMessage() );
}
}
roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getUsername() );
}
catch ( RoleManagerException rpe )
@ -206,6 +213,10 @@ public class DefaultUserService
log.error( "RoleProfile Error: " + rpe.getMessage(), rpe );
throw new RedbackServiceException( new ErrorMessage( "assign.role.failure", null ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
return Boolean.TRUE;
}
@ -238,6 +249,10 @@ public class DefaultUserService
log.error( e.getMessage(), e );
throw new RedbackServiceException( e.getMessage() );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
finally
{
removeFromCache( username );
@ -257,20 +272,31 @@ public class DefaultUserService
{
return null;
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}
public List<User> getUsers()
throws RedbackServiceException
{
List<org.apache.archiva.redback.users.User> users = userManager.getUsers();
List<User> simpleUsers = new ArrayList<User>( users.size() );
for ( org.apache.archiva.redback.users.User user : users )
try
{
simpleUsers.add( getSimpleUser( user ) );
}
List<org.apache.archiva.redback.users.User> users = userManager.getUsers();
List<User> simpleUsers = new ArrayList<User>( users.size() );
return simpleUsers;
for ( org.apache.archiva.redback.users.User user : users )
{
simpleUsers.add( getSimpleUser( user ) );
}
return simpleUsers;
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}
public Boolean updateMe( User user )
@ -322,6 +348,10 @@ public class DefaultUserService
throw new RedbackServiceException( new ErrorMessage( "user not found" ),
Response.Status.BAD_REQUEST.getStatusCode() );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
// only 3 fields to update
realUser.setFullName( user.getFullName() );
realUser.setEmail( user.getEmail() );
@ -359,6 +389,10 @@ public class DefaultUserService
{
throw new RedbackServiceException( e.getMessage() );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}
public int removeFromCache( String userName )
@ -433,6 +467,10 @@ public class DefaultUserService
log.error( e.getMessage(), e );
throw new RedbackServiceException( e.getMessage() );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
finally
{
@ -466,26 +504,29 @@ public class DefaultUserService
return Boolean.FALSE;
}
org.apache.archiva.redback.users.User user =
userManager.createUser( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME, adminUser.getFullName(),
adminUser.getEmail() );
user.setPassword( adminUser.getPassword() );
user.setLocked( false );
user.setPasswordChangeRequired( false );
user.setPermanent( true );
user.setValidated( true );
userManager.addUser( user );
try
{
org.apache.archiva.redback.users.User user =
userManager.createUser( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME, adminUser.getFullName(),
adminUser.getEmail() );
user.setPassword( adminUser.getPassword() );
user.setLocked( false );
user.setPasswordChangeRequired( false );
user.setPermanent( true );
user.setValidated( true );
userManager.addUser( user );
roleManager.assignRole( "system-administrator", user.getUsername() );
}
catch ( RoleManagerException e )
{
throw new RedbackServiceException( e.getMessage() );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
return Boolean.TRUE;
}
@ -501,6 +542,10 @@ public class DefaultUserService
{
// ignore
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
return Boolean.FALSE;
}
@ -543,6 +588,10 @@ public class DefaultUserService
log.info( "Unable to issue password reset.", e );
throw new RedbackServiceException( new ErrorMessage( "password.reset.email.generation.failure" ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
return Boolean.TRUE;
}
@ -570,22 +619,24 @@ public class DefaultUserService
validateCredentialsStrict( user );
}
// NOTE: Do not perform Password Rules Validation Here.
if ( userManager.userExists( user.getUsername() ) )
{
throw new RedbackServiceException(
new ErrorMessage( "user.already.exists", new String[]{ user.getUsername() } ) );
}
org.apache.archiva.redback.users.User u =
userManager.createUser( user.getUsername(), user.getFullName(), user.getEmail() );
u.setPassword( user.getPassword() );
u.setValidated( false );
u.setLocked( false );
org.apache.archiva.redback.users.User u = null;
try
{
// NOTE: Do not perform Password Rules Validation Here.
if ( userManager.userExists( user.getUsername() ) )
{
throw new RedbackServiceException(
new ErrorMessage( "user.already.exists", new String[]{ user.getUsername() } ) );
}
u = userManager.createUser( user.getUsername(), user.getFullName(), user.getEmail() );
u.setPassword( user.getPassword() );
u.setValidated( false );
u.setLocked( false );
roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getUsername() );
}
catch ( RoleManagerException rpe )
@ -593,6 +644,10 @@ public class DefaultUserService
log.error( "RoleProfile Error: " + rpe.getMessage(), rpe );
throw new RedbackServiceException( new ErrorMessage( "assign.role.failure", null ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
if ( emailValidationRequired )
{
@ -624,6 +679,10 @@ public class DefaultUserService
log.error( "Unable to register a new user.", e );
throw new RedbackServiceException( new ErrorMessage( "cannot.register.user", null ) );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
finally
{
securityPolicy.setEnabled( true );
@ -631,8 +690,15 @@ public class DefaultUserService
}
else
{
userManager.addUser( u );
return new RegistrationKey( "-1" );
try
{
userManager.addUser( u );
return new RegistrationKey( "-1" );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}
// FIXME log this event
@ -702,6 +768,10 @@ public class DefaultUserService
{
throw new RedbackServiceException( e.getMessage(), Response.Status.FORBIDDEN.getStatusCode() );
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}
public Collection<Permission> getCurrentUserPermissions()
@ -845,17 +915,23 @@ public class DefaultUserService
throws RedbackServiceException
{
validateCredentialsLoose( user );
org.apache.archiva.redback.users.User tmpuser =
userManager.createUser( user.getUsername(), user.getFullName(), user.getEmail() );
user.setPassword( user.getPassword() );
securitySystem.getPolicy().validatePassword( tmpuser );
if ( ( org.codehaus.plexus.util.StringUtils.isEmpty( user.getPassword() ) ) )
try
{
throw new RedbackServiceException( new ErrorMessage( "password.required", null ) );
org.apache.archiva.redback.users.User tmpuser =
userManager.createUser( user.getUsername(), user.getFullName(), user.getEmail() );
user.setPassword( user.getPassword() );
securitySystem.getPolicy().validatePassword( tmpuser );
if ( ( org.codehaus.plexus.util.StringUtils.isEmpty( user.getPassword() ) ) )
{
throw new RedbackServiceException( new ErrorMessage( "password.required", null ) );
}
}
catch ( UserManagerException e )
{
throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) );
}
}

View File

@ -32,6 +32,7 @@ import org.apache.archiva.redback.rest.services.RedbackRequestInformation;
import org.apache.archiva.redback.system.SecuritySession;
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.UserNotFoundException;
import org.apache.cxf.jaxrs.ext.RequestHandler;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
@ -54,17 +55,17 @@ import javax.ws.rs.core.Response;
* @author Olivier Lamy
* @since 1.3
*/
@Service ("authenticationInterceptor#rest")
@Service("authenticationInterceptor#rest")
public class AuthenticationInterceptor
extends AbstractInterceptor
implements RequestHandler
{
@Inject
@Named (value = "userManager#configurable")
@Named(value = "userManager#configurable")
private UserManager userManager;
@Inject
@Named (value = "httpAuthenticator#basic")
@Named(value = "httpAuthenticator#basic")
private HttpBasicAuthentication httpAuthenticator;
private Logger log = LoggerFactory.getLogger( getClass() );
@ -168,5 +169,10 @@ public class AuthenticationInterceptor
log.debug( "failed to authenticate for path {}", message.get( Message.REQUEST_URI ) );
return Response.status( Response.Status.FORBIDDEN ).build();
}
catch ( UserManagerException e )
{
log.debug( "UserManagerException: {} for path", e.getMessage(), message.get( Message.REQUEST_URI ) );
return Response.status( Response.Status.FORBIDDEN ).build();
}
}
}

View File

@ -20,6 +20,7 @@ package org.apache.archiva.redback.rest.services.utils;
import org.apache.archiva.redback.policy.PasswordRuleViolations;
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.policy.PasswordEncoder;
import org.apache.archiva.redback.policy.PasswordRuleViolationException;
@ -32,13 +33,14 @@ import org.springframework.stereotype.Service;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Olivier Lamy
* @since 1.4
*/
@Service( "passwordValidator#rest" )
@Service("passwordValidator#rest")
public class PasswordValidator
{
@ -48,7 +50,6 @@ public class PasswordValidator
private SecuritySystem securitySystem;
/**
*
* @param password
* @param principal
* @return encoded password
@ -98,6 +99,13 @@ public class PasswordValidator
}
throw new RedbackServiceException( errorMessages );
}
catch ( UserManagerException e )
{
log.info( "UserManagerException: {}", e.getMessage() );
List<ErrorMessage> errorMessages =
Arrays.asList( new ErrorMessage().message( "UserManagerException: " + e.getMessage() ) );
throw new RedbackServiceException( errorMessages );
}
}
}

View File

@ -32,6 +32,7 @@ import org.apache.archiva.redback.policy.AccountLockedException;
import org.apache.archiva.redback.policy.MustChangePasswordException;
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.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -44,16 +45,16 @@ import javax.annotation.Resource;
*
* @author: Jesse McConnell <jesse@codehaus.org>
*/
@Service ("authenticator#keystore")
@Service("authenticator#keystore")
public class KeyStoreAuthenticator
implements Authenticator
{
private Logger log = LoggerFactory.getLogger( getClass() );
@Resource (name = "keyManager#cached")
@Resource(name = "keyManager#cached")
private KeyManager keystore;
@Resource (name = "userManager#configurable")
@Resource(name = "userManager#configurable")
private UserManager userManager;
public String getId()
@ -107,6 +108,11 @@ public class KeyStoreAuthenticator
log.warn( "Login for user {} failed. user not found.", source.getPrincipal() );
return new AuthenticationResult( false, null, e );
}
catch ( UserManagerException e )
{
log.warn( "Login fail for user {} failed. message: {}", source.getPrincipal(), e.getMessage() );
return new AuthenticationResult( false, null, e );
}
}
public boolean supportsDataSource( AuthenticationDataSource source )

View File

@ -32,6 +32,7 @@ import org.apache.archiva.redback.rbac.RbacManagerException;
import org.apache.archiva.redback.rbac.RbacObjectNotFoundException;
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.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -47,18 +48,18 @@ import java.util.Map;
*
* @author Jesse McConnell <jmcconnell@apache.org>
*/
@Service ( "authorizer#rbac" )
@Service("authorizer#rbac")
public class RbacAuthorizer
implements Authorizer
{
private Logger log = LoggerFactory.getLogger( getClass() );
@Inject
@Named ( value = "rBACManager#cached" )
@Named(value = "rBACManager#cached")
private RBACManager manager;
@Inject
@Named ( value = "userManager#configurable" )
@Named(value = "userManager#configurable")
private UserManager userManager;
@Inject
@ -115,8 +116,7 @@ public class RbacAuthorizer
if ( !guest.isLocked() )
{
// Set permissions = manager.getAssignedPermissions( principal.toString(), operation );
Map<String, List<Permission>> permissionMap =
manager.getAssignedPermissionMap( guest.getUsername() );
Map<String, List<Permission>> permissionMap = manager.getAssignedPermissionMap( guest.getUsername() );
if ( permissionMap.keySet().contains( operation.toString() ) )
{
@ -151,6 +151,10 @@ public class RbacAuthorizer
{
return new AuthorizationResult( false, null, rme );
}
catch ( UserManagerException e )
{
return new AuthorizationResult( false, null, e );
}
}
public RBACManager getManager()

View File

@ -21,6 +21,7 @@ package org.apache.archiva.redback.authorization.rbac.evaluator;
import org.apache.archiva.redback.rbac.Resource;
import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.UserNotFoundException;
import org.apache.archiva.redback.rbac.Permission;
import org.springframework.stereotype.Service;
@ -35,14 +36,13 @@ import javax.inject.Named;
* of the person making the authorization check
*
* @author Jesse McConnell <jesse@codehaus.org>
*
*/
@Service("permissionEvaluator")
public class DefaultPermissionEvaluator
implements PermissionEvaluator
{
@Inject
@Named(value="userManager#configurable")
@Named(value = "userManager#configurable")
private UserManager userManager;
public boolean evaluate( Permission permission, Object operation, Object resource, Object principal )
@ -61,9 +61,13 @@ public class DefaultPermissionEvaluator
{
permissionResource = userManager.findUser( principal.toString() ).getUsername();
}
catch ( UserNotFoundException ne )
catch ( UserNotFoundException e )
{
throw new PermissionEvaluationException( "unable to locate user to retrieve username", ne );
throw new PermissionEvaluationException( "unable to locate user to retrieve username", e );
}
catch ( UserManagerException e )
{
throw new PermissionEvaluationException( "trouble finding user: " + e.getMessage(), e );
}
}
}
@ -82,7 +86,7 @@ public class DefaultPermissionEvaluator
{
return true;
}
// check if the resource identifier of the permission matches the resource we are checking against
// if it does then return true
if ( permissionResource.equals( resource.toString() ) )

View File

@ -24,6 +24,7 @@ import org.apache.archiva.redback.policy.AccountLockedException;
import org.apache.archiva.redback.policy.UserSecurityPolicy;
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.UserNotFoundException;
import org.apache.archiva.redback.authentication.AuthenticationDataSource;
import org.apache.archiva.redback.authentication.AuthenticationException;
@ -45,9 +46,8 @@ import javax.inject.Named;
* DefaultSecuritySystem:
*
* @author: Jesse McConnell <jesse@codehaus.org>
*
*/
@Service( "securitySystem" )
@Service("securitySystem")
public class DefaultSecuritySystem
implements SecuritySystem
{
@ -57,15 +57,15 @@ public class DefaultSecuritySystem
private AuthenticationManager authnManager;
@Inject
@Named( value = "authorizer#rbac" )
@Named(value = "authorizer#rbac")
private Authorizer authorizer;
@Inject
@Named( value = "userManager#configurable" )
@Named(value = "userManager#configurable")
private UserManager userManager;
@Inject
@Named( value = "keyManager#cached" )
@Named(value = "keyManager#cached")
private KeyManager keyManager;
@Inject
@ -92,10 +92,12 @@ public class DefaultSecuritySystem
* @throws UserNotFoundException
* @throws MustChangePasswordException
* @throws org.apache.archiva.redback.policy.AccountLockedException
*
* @throws MustChangePasswordException
*/
public SecuritySession authenticate( AuthenticationDataSource source )
throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException
throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException,
UserManagerException
{
// Perform Authentication.
AuthenticationResult result = authnManager.authenticate( source );
@ -105,7 +107,7 @@ public class DefaultSecuritySystem
// Process Results.
if ( result.isAuthenticated() )
{
log.debug( "User '{}' authenticated.", result.getPrincipal());
log.debug( "User '{}' authenticated.", result.getPrincipal() );
User user = userManager.findUser( result.getPrincipal() );
if ( user != null )
{
@ -127,7 +129,8 @@ public class DefaultSecuritySystem
}
public boolean isAuthenticated( AuthenticationDataSource source )
throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException
throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException,
UserManagerException
{
return authenticate( source ).getAuthenticationResult().isAuthenticated();
}

View File

@ -22,6 +22,7 @@ package org.apache.archiva.redback.system;
import org.apache.archiva.redback.policy.AccountLockedException;
import org.apache.archiva.redback.policy.MustChangePasswordException;
import org.apache.archiva.redback.policy.UserSecurityPolicy;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.UserNotFoundException;
import org.apache.archiva.redback.authentication.AuthenticationDataSource;
import org.apache.archiva.redback.authentication.AuthenticationException;
@ -34,7 +35,6 @@ import org.apache.archiva.redback.users.UserManager;
* SecuritySystem:
*
* @author: Jesse McConnell <jesse@codehaus.org>
*
*/
public interface SecuritySystem
{
@ -44,10 +44,12 @@ public interface SecuritySystem
// ----------------------------------------------------------------------------
SecuritySession authenticate( AuthenticationDataSource source )
throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException;
throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException,
UserManagerException;
boolean isAuthenticated( AuthenticationDataSource source )
throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException;
throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException,
UserManagerException;
// ----------------------------------------------------------------------------
// Authorization
@ -61,6 +63,7 @@ public interface SecuritySystem
/**
* return AuthorizationResult without changing authorization
*
* @param session
* @param permission
* @param resource
@ -78,22 +81,22 @@ public interface SecuritySystem
// ----------------------------------------------------------------------------
UserManager getUserManager();
// ----------------------------------------------------------------------------
// Key Management
// ----------------------------------------------------------------------------
KeyManager getKeyManager();
// ----------------------------------------------------------------------------
// Policy Management
// ----------------------------------------------------------------------------
UserSecurityPolicy getPolicy();
/**
* @since 2.1
* @return is it possible to modify user datas (some userManager cannot i.e ldap)
* @since 2.1
*/
boolean userManagerReadOnly();
}

View File

@ -31,13 +31,12 @@ import javax.annotation.PostConstruct;
* AbstractUserManager
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
public abstract class AbstractUserManager
implements UserManager
{
protected Logger log = LoggerFactory.getLogger( getClass() );
private List<UserManagerListener> listeners = new ArrayList<UserManagerListener>();
public void addUserManagerListener( UserManagerListener listener )
@ -114,12 +113,13 @@ public abstract class AbstractUserManager
}
public User getGuestUser()
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
return findUser( GUEST_USERNAME );
}
public User createGuestUser()
throws UserManagerException
{
try
{

View File

@ -29,7 +29,7 @@ import java.util.List;
*/
public interface UserManager
{
static final String GUEST_USERNAME = "guest";
/**
@ -72,15 +72,19 @@ public interface UserManager
* @param fullName the full name for this user.
* @param emailAddress the email address for this user.
* @return the new user object ready to use.
* @throws UserManagerException
*/
User createUser( String username, String fullName, String emailAddress );
User createUser( String username, String fullName, String emailAddress )
throws UserManagerException;
/**
* Factory method to create the guest user.
*
* @return The guest user
* @throws UserManagerException
*/
User createGuestUser();
User createGuestUser()
throws UserManagerException;
/**
* Factory method to create {@link UserQuery}s based on provider specific
@ -94,18 +98,23 @@ public interface UserManager
* Get the List of {@link User} objects.
*
* @return the List of {@link User} Objects.
* @throws UserManagerException
*/
List<User> getUsers();
List<User> getUsers()
throws UserManagerException;
List<User> getUsers( boolean orderAscending );
List<User> getUsers( boolean orderAscending )
throws UserManagerException;
/**
* Add a User.
*
* @param user the user to add.
* @return the user that was just added.
* @throws UserManagerException
*/
User addUser( User user );
User addUser( User user )
throws UserManagerException;
/**
* Update a User.
@ -115,7 +124,7 @@ public interface UserManager
* @throws UserNotFoundException if the user was not found to update.
*/
User updateUser( User user )
throws UserNotFoundException;
throws UserNotFoundException, UserManagerException;
/**
* Find a User using a User name.
@ -125,7 +134,7 @@ public interface UserManager
* @throws UserNotFoundException if the user was not found.
*/
User findUser( String username )
throws UserNotFoundException;
throws UserNotFoundException, UserManagerException;
/**
* Get the guest user.
@ -133,13 +142,16 @@ public interface UserManager
* @return the guest user.
*/
User getGuestUser()
throws UserNotFoundException;
throws UserNotFoundException, UserManagerException;
List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending );
List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
throws UserManagerException;
List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending );
List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
throws UserManagerException;
List<User> findUsersByEmailKey( String emailKey, boolean orderAscending );
List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
throws UserManagerException;
/**
* Find users matching properties, ordering and range as specified by the
@ -148,7 +160,8 @@ public interface UserManager
* @param query the query.
* @return a List of {@link User} objects.
*/
List<User> findUsersByQuery( UserQuery query );
List<User> findUsersByQuery( UserQuery query )
throws UserManagerException;
/**
* true if the user exists, false if it doesn't
@ -156,7 +169,8 @@ public interface UserManager
* @param principal
* @return true, if user exists
*/
boolean userExists( String principal );
boolean userExists( String principal )
throws UserManagerException;
/**
* Delete a user using the username.
@ -165,7 +179,7 @@ public interface UserManager
* @throws UserNotFoundException the user was not found.
*/
void deleteUser( String username )
throws UserNotFoundException;
throws UserNotFoundException, UserManagerException;
/**
* Add a user to the database without checking for consistency or adjusting the password. Should only be used for
@ -173,30 +187,32 @@ public interface UserManager
*
* @param user the user to add
*/
void addUserUnchecked( User user );
void addUserUnchecked( User user )
throws UserManagerException;
void eraseDatabase();
User updateUser( User user, boolean passwordChangeRequired )
throws UserNotFoundException;
throws UserNotFoundException, UserManagerException;
/**
* consumer of user manager can use it to reload various configuration
* with the configurable implementation is possible to change dynamically the real implementation used.
*
* @since 2.1
*/
void initialize();
/**
* @since 2.1
* @return true if this implementation is a final one and not a wrapper (configurable, cached)
* @since 2.1
*/
boolean isFinalImplementation();
/**
* @since 2.1
* @return a key to be able to customize label in UI
* @since 2.1
*/
String getDescriptionKey();
}

View File

@ -26,7 +26,7 @@ package org.apache.archiva.redback.users;
*
*/
public class UserManagerException
extends RuntimeException
extends Exception
{
public UserManagerException()

View File

@ -23,7 +23,7 @@ package org.apache.archiva.redback.users;
* @author Jason van Zyl
*/
public class UserNotFoundException
extends Exception
extends UserManagerException
{
public UserNotFoundException( String string )
{

View File

@ -21,6 +21,7 @@ package org.apache.archiva.redback.users.cached;
import org.apache.archiva.redback.components.cache.Cache;
import org.apache.archiva.redback.users.User;
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;
@ -37,7 +38,6 @@ import java.util.List;
* CachedUserManager
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
@Service( "userManager#cached" )
public class CachedUserManager
@ -60,11 +60,13 @@ public class CachedUserManager
}
public User createGuestUser()
throws UserManagerException
{
return userImpl.createGuestUser();
}
public User addUser( User user )
throws UserManagerException
{
if ( user != null )
{
@ -79,6 +81,7 @@ public class CachedUserManager
}
public void addUserUnchecked( User user )
throws UserManagerException
{
if ( user != null )
{
@ -88,13 +91,14 @@ public class CachedUserManager
}
public User createUser( String username, String fullName, String emailAddress )
throws UserManagerException
{
usersCache.remove( username );
return this.userImpl.createUser( username, fullName, emailAddress );
}
public void deleteUser( String username )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
usersCache.remove( username );
this.userImpl.deleteUser( username );
@ -113,7 +117,7 @@ public class CachedUserManager
}
public User findUser( String username )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
if ( GUEST_USERNAME.equals( username ) )
{
@ -134,7 +138,7 @@ public class CachedUserManager
}
public User getGuestUser()
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
Object el = usersCache.get( GUEST_USERNAME );
if ( el != null )
@ -156,24 +160,28 @@ public class CachedUserManager
public List<User> findUsersByQuery( UserQuery query )
throws UserManagerException
{
log.debug( "NOT CACHED - .findUsersByQuery(UserQuery)" );
return this.userImpl.findUsersByQuery( query );
}
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
throws UserManagerException
{
log.debug( "NOT CACHED - .findUsersByEmailKey(String, boolean)" );
return this.userImpl.findUsersByEmailKey( emailKey, orderAscending );
}
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
throws UserManagerException
{
log.debug( "NOT CACHED - .findUsersByFullNameKey(String, boolean)" );
return this.userImpl.findUsersByFullNameKey( fullNameKey, orderAscending );
}
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
throws UserManagerException
{
log.debug( "NOT CACHED - .findUsersByUsernameKey(String, boolean)" );
return this.userImpl.findUsersByUsernameKey( usernameKey, orderAscending );
@ -185,12 +193,14 @@ public class CachedUserManager
}
public List<User> getUsers()
throws UserManagerException
{
log.debug( "NOT CACHED - .getUsers()" );
return this.userImpl.getUsers();
}
public List<User> getUsers( boolean orderAscending )
throws UserManagerException
{
log.debug( "NOT CACHED - .getUsers(boolean)" );
return this.userImpl.getUsers( orderAscending );
@ -202,13 +212,13 @@ public class CachedUserManager
}
public User updateUser( User user )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
return updateUser( user, false );
}
public User updateUser( User user, boolean passwordChangeRequired )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
if ( user != null )
{
@ -218,6 +228,7 @@ public class CachedUserManager
}
public boolean userExists( String userName )
throws UserManagerException
{
if ( usersCache.hasKey( userName ) )
{

View File

@ -21,6 +21,7 @@ import org.apache.archiva.redback.configuration.UserConfigurationKeys;
import org.apache.archiva.redback.users.AbstractUserManager;
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.UserNotFoundException;
import org.apache.archiva.redback.users.UserQuery;
import org.springframework.context.ApplicationContext;
@ -66,16 +67,19 @@ public class ConfigurableUserManager
}
public User addUser( User user )
throws UserManagerException
{
return userManagerImpl.addUser( user );
}
public void addUserUnchecked( User user )
throws UserManagerException
{
userManagerImpl.addUserUnchecked( user );
}
public User createUser( String username, String fullName, String emailAddress )
throws UserManagerException
{
return userManagerImpl.createUser( username, fullName, emailAddress );
}
@ -86,7 +90,7 @@ public class ConfigurableUserManager
}
public void deleteUser( String username )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
userManagerImpl.deleteUser( username );
}
@ -97,34 +101,38 @@ public class ConfigurableUserManager
}
public User findUser( String username )
throws UserNotFoundException
throws UserManagerException, UserNotFoundException
{
return userManagerImpl.findUser( username );
}
@Override
public User getGuestUser()
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
return userManagerImpl.getGuestUser();
}
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
throws UserManagerException
{
return userManagerImpl.findUsersByEmailKey( emailKey, orderAscending );
}
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
throws UserManagerException
{
return userManagerImpl.findUsersByFullNameKey( fullNameKey, orderAscending );
}
public List<User> findUsersByQuery( UserQuery query )
throws UserManagerException
{
return userManagerImpl.findUsersByQuery( query );
}
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
throws UserManagerException
{
return userManagerImpl.findUsersByUsernameKey( usernameKey, orderAscending );
}
@ -135,11 +143,13 @@ public class ConfigurableUserManager
}
public List<User> getUsers()
throws UserManagerException
{
return userManagerImpl.getUsers();
}
public List<User> getUsers( boolean orderAscending )
throws UserManagerException
{
return userManagerImpl.getUsers( orderAscending );
}
@ -150,18 +160,19 @@ public class ConfigurableUserManager
}
public User updateUser( User user )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
return updateUser( user, false );
}
public User updateUser( User user, boolean passwordChangeRequired )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
return userManagerImpl.updateUser( user, passwordChangeRequired );
}
public boolean userExists( String userName )
throws UserManagerException
{
return userManagerImpl.userExists( userName );
}

View File

@ -50,12 +50,12 @@ import java.util.List;
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*/
@Service ("userManager#jdo")
@Service("userManager#jdo")
public class JdoUserManager
extends AbstractUserManager
{
@Inject
@Named (value = "jdoFactory#users")
@Named(value = "jdoFactory#users")
private JdoFactory jdoFactory;
@Inject
@ -104,7 +104,7 @@ public class JdoUserManager
return getAllObjectsDetached( ordering );
}
@SuppressWarnings ("unchecked")
@SuppressWarnings("unchecked")
private List<User> getAllObjectsDetached( String ordering )
{
return RedbackJdoUtils.getAllObjectsDetached( getPersistenceManager(), JdoUser.class, ordering, (String) null );
@ -125,7 +125,7 @@ public class JdoUserManager
return findUsers( "email", emailKey, orderAscending );
}
@SuppressWarnings ("unchecked")
@SuppressWarnings("unchecked")
public List<User> findUsersByQuery( UserQuery userQuery )
{
JdoUserQuery uq = (JdoUserQuery) userQuery;
@ -169,7 +169,7 @@ public class JdoUserManager
}
}
@SuppressWarnings ("unchecked")
@SuppressWarnings("unchecked")
private List<User> findUsers( String searchField, String searchKey, boolean ascendingUsername )
{
PersistenceManager pm = getPersistenceManager();
@ -209,6 +209,7 @@ public class JdoUserManager
}
public User addUser( User user )
throws UserManagerException
{
if ( !( user instanceof JdoUser ) )
{
@ -243,6 +244,7 @@ public class JdoUserManager
}
public void deleteUser( String username )
throws UserManagerException
{
try
{
@ -264,6 +266,7 @@ public class JdoUserManager
}
public void addUserUnchecked( User user )
throws UserManagerException
{
if ( !( user instanceof JdoUser ) )
{
@ -287,7 +290,7 @@ public class JdoUserManager
}
public User findUser( String username )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
if ( StringUtils.isEmpty( username ) )
{
@ -298,6 +301,7 @@ public class JdoUserManager
}
public boolean userExists( String principal )
throws UserManagerException
{
try
{
@ -311,13 +315,13 @@ public class JdoUserManager
}
public User updateUser( User user )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
return updateUser( user, false );
}
public User updateUser( User user, boolean passwordChangeRequired )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
if ( !( user instanceof JdoUser ) )
{
@ -385,6 +389,7 @@ public class JdoUserManager
}
private Object removeObject( Object o )
throws UserManagerException
{
if ( o == null )
{

View File

@ -21,6 +21,7 @@ package org.apache.archiva.redback.users.jdo;
import org.apache.archiva.redback.components.jdo.DefaultConfigurableJdoFactory;
import org.apache.archiva.redback.common.jdo.test.StoreManagerDebug;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.provider.test.AbstractUserManagerTestCase;
import org.jpox.AbstractPersistenceManagerFactory;
import org.jpox.SchemaTool;
@ -38,17 +39,16 @@ import java.util.Properties;
* JdoUserManagerTest
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
public class JdoUserManagerTest
extends AbstractUserManagerTestCase
{
@Inject
@Named( value = "jdoFactory#users" )
@Named(value = "jdoFactory#users")
DefaultConfigurableJdoFactory jdoFactory;
@Inject
@Named( value = "userManager#jdo" )
@Named(value = "userManager#jdo")
JdoUserManager jdoUserManager;
private StoreManagerDebug storeManager;
@ -106,12 +106,10 @@ public class JdoUserManagerTest
}
protected void assertCleanUserManager()
throws UserManagerException
{
// database cleanup
( (JdoUserManager) getUserManager()).eraseDatabase();
( (JdoUserManager) getUserManager() ).eraseDatabase();
super.assertCleanUserManager();
}

View File

@ -74,6 +74,7 @@ public class LdapUserManager
}
public User addUser( User user )
throws UserManagerException
{
try
{
@ -86,6 +87,7 @@ public class LdapUserManager
}
public void addUserUnchecked( User user )
throws UserManagerException
{
try
{
@ -144,7 +146,7 @@ public class LdapUserManager
public void deleteUser( String username )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
if ( username != null )
{
@ -177,7 +179,7 @@ public class LdapUserManager
}
public User findUser( String username )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
if ( username == null )
{
@ -248,6 +250,7 @@ public class LdapUserManager
}
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
throws UserManagerException
{
LdapUserQuery query = new LdapUserQuery();
query.setEmail( emailKey );
@ -257,6 +260,7 @@ public class LdapUserManager
}
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
throws UserManagerException
{
LdapUserQuery query = new LdapUserQuery();
query.setFullName( fullNameKey );
@ -266,6 +270,7 @@ public class LdapUserManager
}
public List<User> findUsersByQuery( UserQuery query )
throws UserManagerException
{
if ( query == null )
{
@ -304,6 +309,7 @@ public class LdapUserManager
* @see org.apache.archiva.redback.users.UserManager#findUsersByUsernameKey(java.lang.String, boolean)
*/
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
throws UserManagerException
{
LdapUserQuery query = new LdapUserQuery();
query.setUsername( usernameKey );
@ -365,13 +371,13 @@ public class LdapUserManager
}
public User updateUser( User user )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
return updateUser( user, false );
}
public User updateUser( User user, boolean passwordChangeRequired )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
if ( user != null )
{
@ -406,6 +412,7 @@ public class LdapUserManager
}
public boolean userExists( String principal )
throws UserManagerException
{
if ( principal == null )
{

View File

@ -24,6 +24,7 @@ import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.policy.UserSecurityPolicy;
import org.apache.archiva.redback.users.AbstractUserManager;
import org.apache.archiva.redback.users.PermanentUserException;
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.UserQuery;
import org.apache.archiva.redback.users.UserNotFoundException;
import org.apache.archiva.redback.users.memory.util.UserSorter;
@ -163,7 +164,7 @@ public class MemoryUserManager
}
public void deleteUser( String username )
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
User user = findUser( username );

View File

@ -24,6 +24,7 @@ import org.apache.archiva.redback.policy.UserSecurityPolicy;
import org.apache.archiva.redback.users.PermanentUserException;
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.UserNotFoundException;
import org.apache.archiva.redback.users.UserQuery;
import org.junit.Test;
@ -40,9 +41,9 @@ import java.util.List;
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*/
@RunWith ( SpringJUnit4ClassRunner.class )
@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
@DirtiesContext ( classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD )
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" })
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class AbstractUserManagerTestCase
extends TestCase
{
@ -93,6 +94,7 @@ public class AbstractUserManagerTestCase
}
protected void assertCleanUserManager()
throws UserManagerException
{
getUserManager().eraseDatabase();
@ -105,6 +107,7 @@ public class AbstractUserManagerTestCase
@Test
public void testFindUserByNullPrincipal()
throws UserManagerException
{
try
{
@ -120,6 +123,7 @@ public class AbstractUserManagerTestCase
@Test
public void testFindUserByEmptyUsername()
throws UserManagerException
{
try
{
@ -157,7 +161,7 @@ public class AbstractUserManagerTestCase
@Test
public void testAddFindUserByPrincipal()
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
assertCleanUserManager();
securityPolicy.setEnabled( false );
@ -187,7 +191,7 @@ public class AbstractUserManagerTestCase
@Test
public void testAddFindUserLockedStatus()
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
assertCleanUserManager();
securityPolicy.setEnabled( false );
@ -197,7 +201,7 @@ public class AbstractUserManagerTestCase
smcqueen.setLocked( true );
/*
* Keep a reference to the object that was added. Since it has the
* Keep a reference to the object that was added. Since it has the
* actual principal that was managed by jpox/jdo.
*/
User added = userManager.addUser( smcqueen );
@ -224,7 +228,7 @@ public class AbstractUserManagerTestCase
@Test
public void testAddFindUserByUsername()
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
assertCleanUserManager();
securityPolicy.setEnabled( false );
@ -396,6 +400,7 @@ public class AbstractUserManagerTestCase
@Test
public void testFindUsersByQuery()
throws UserManagerException
{
assertCleanUserManager();
securityPolicy.setEnabled( false );
@ -572,7 +577,7 @@ public class AbstractUserManagerTestCase
@Test
public void testDeletePermanentUser()
throws UserNotFoundException
throws UserNotFoundException, UserManagerException
{
assertCleanUserManager();
securityPolicy.setEnabled( false );