remove non used method with parameter Object principal
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1418771 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
86a6ec5580
commit
3257c3fac5
|
@ -150,32 +150,13 @@ public interface UserManager
|
||||||
*/
|
*/
|
||||||
List<User> findUsersByQuery( UserQuery query );
|
List<User> findUsersByQuery( UserQuery query );
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a User using the principal.
|
|
||||||
*
|
|
||||||
* @param principal the principal to look for.
|
|
||||||
* @return the user.
|
|
||||||
* @throws UserNotFoundException if the user was not found.
|
|
||||||
*/
|
|
||||||
User findUser( Object principal )
|
|
||||||
throws UserNotFoundException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* true if the user exists, false if it doesn't
|
* true if the user exists, false if it doesn't
|
||||||
*
|
*
|
||||||
* @param principal
|
* @param principal
|
||||||
* @return true, if user exists
|
* @return true, if user exists
|
||||||
*/
|
*/
|
||||||
boolean userExists( Object principal );
|
boolean userExists( String principal );
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a user using the principal.
|
|
||||||
*
|
|
||||||
* @param principal the principal to look for.
|
|
||||||
* @throws UserNotFoundException the user was not found.
|
|
||||||
*/
|
|
||||||
void deleteUser( Object principal )
|
|
||||||
throws UserNotFoundException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a user using the username.
|
* Delete a user using the username.
|
||||||
|
|
|
@ -93,13 +93,6 @@ public class CachedUserManager
|
||||||
return this.userImpl.createUser( username, fullName, emailAddress );
|
return this.userImpl.createUser( username, fullName, emailAddress );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteUser( Object principal )
|
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
usersCache.remove( principal );
|
|
||||||
this.userImpl.deleteUser( principal );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteUser( String username )
|
public void deleteUser( String username )
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException
|
||||||
{
|
{
|
||||||
|
@ -156,22 +149,6 @@ public class CachedUserManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public User findUser( Object principal )
|
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
Object el = usersCache.get( principal );
|
|
||||||
if ( el != null )
|
|
||||||
{
|
|
||||||
return (User) el;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
User user = this.userImpl.findUser( principal );
|
|
||||||
usersCache.put( principal, user );
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserQuery createUserQuery()
|
public UserQuery createUserQuery()
|
||||||
{
|
{
|
||||||
return userImpl.createUserQuery();
|
return userImpl.createUserQuery();
|
||||||
|
@ -240,14 +217,14 @@ public class CachedUserManager
|
||||||
return this.userImpl.updateUser( user, passwordChangeRequired );
|
return this.userImpl.updateUser( user, passwordChangeRequired );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean userExists( Object principal )
|
public boolean userExists( String userName )
|
||||||
{
|
{
|
||||||
if ( usersCache.hasKey( principal ) )
|
if ( usersCache.hasKey( userName ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.userImpl.userExists( principal );
|
return this.userImpl.userExists( userName );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void userManagerInit( boolean freshDatabase )
|
public void userManagerInit( boolean freshDatabase )
|
||||||
|
|
|
@ -85,12 +85,6 @@ public class ConfigurableUserManager
|
||||||
return userManagerImpl.createUserQuery();
|
return userManagerImpl.createUserQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteUser( Object principal )
|
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
userManagerImpl.deleteUser( principal );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteUser( String username )
|
public void deleteUser( String username )
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException
|
||||||
{
|
{
|
||||||
|
@ -108,12 +102,6 @@ public class ConfigurableUserManager
|
||||||
return userManagerImpl.findUser( username );
|
return userManagerImpl.findUser( username );
|
||||||
}
|
}
|
||||||
|
|
||||||
public User findUser( Object principal )
|
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
return userManagerImpl.findUser( principal );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User getGuestUser()
|
public User getGuestUser()
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException
|
||||||
|
@ -173,9 +161,9 @@ public class ConfigurableUserManager
|
||||||
return userManagerImpl.updateUser( user, passwordChangeRequired );
|
return userManagerImpl.updateUser( user, passwordChangeRequired );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean userExists( Object principal )
|
public boolean userExists( String userName )
|
||||||
{
|
{
|
||||||
return userManagerImpl.userExists( principal );
|
return userManagerImpl.userExists( userName );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserManagerImpl( UserManager userManagerImpl )
|
public void setUserManagerImpl( UserManager userManagerImpl )
|
||||||
|
|
|
@ -242,27 +242,6 @@ public class JdoUserManager
|
||||||
return (User) addObject( user );
|
return (User) addObject( user );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteUser( Object principal )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
User user = findUser( principal );
|
|
||||||
|
|
||||||
if ( user.isPermanent() )
|
|
||||||
{
|
|
||||||
throw new PermanentUserException( "Cannot delete permanent user [" + user.getUsername() + "]." );
|
|
||||||
}
|
|
||||||
|
|
||||||
fireUserManagerUserRemoved( user );
|
|
||||||
|
|
||||||
removeObject( user );
|
|
||||||
}
|
|
||||||
catch ( UserNotFoundException e )
|
|
||||||
{
|
|
||||||
log.warn( "Unable to delete user " + principal + ", user not found.", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteUser( String username )
|
public void deleteUser( String username )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -307,29 +286,6 @@ public class JdoUserManager
|
||||||
RedbackJdoUtils.removeAll( getPersistenceManager(), UsersManagementModelloMetadata.class );
|
RedbackJdoUtils.removeAll( getPersistenceManager(), UsersManagementModelloMetadata.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
public User findUser( Object principal )
|
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
if ( principal == null )
|
|
||||||
{
|
|
||||||
throw new UserNotFoundException( "Unable to find user based on null principal." );
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return (User) RedbackJdoUtils.getObjectById( getPersistenceManager(), JdoUser.class, principal.toString(),
|
|
||||||
null );
|
|
||||||
}
|
|
||||||
catch ( RedbackObjectNotFoundException e )
|
|
||||||
{
|
|
||||||
throw new UserNotFoundException( "Unable to find user: " + e.getMessage(), e );
|
|
||||||
}
|
|
||||||
catch ( RedbackStoreException e )
|
|
||||||
{
|
|
||||||
throw new UserNotFoundException( "Unable to find user: " + e.getMessage(), e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public User findUser( String username )
|
public User findUser( String username )
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException
|
||||||
{
|
{
|
||||||
|
@ -341,7 +297,7 @@ public class JdoUserManager
|
||||||
return (User) getObjectById( username, null );
|
return (User) getObjectById( username, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean userExists( Object principal )
|
public boolean userExists( String principal )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,29 +127,6 @@ public class LdapUserManager
|
||||||
return new LdapUserQuery();
|
return new LdapUserQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteUser( Object principal )
|
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
if ( principal != null )
|
|
||||||
{
|
|
||||||
clearFromCache( principal.toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
LdapConnection ldapConnection = getLdapConnection();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DirContext context = ldapConnection.getDirContext();
|
|
||||||
controller.removeUser( principal, context );
|
|
||||||
}
|
|
||||||
catch ( LdapControllerException e )
|
|
||||||
{
|
|
||||||
log.error( "Failed to delete user: {}", principal, e );
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
closeLdapConnection( ldapConnection );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteUser( String username )
|
public void deleteUser( String username )
|
||||||
throws UserNotFoundException
|
throws UserNotFoundException
|
||||||
|
@ -245,58 +222,6 @@ public class LdapUserManager
|
||||||
return guestUser;
|
return guestUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User findUser( Object principal )
|
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
if ( principal == null )
|
|
||||||
{
|
|
||||||
throw new UserNotFoundException( "Unable to find user based on null principal." );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( GUEST_USERNAME.equals( principal.toString() ) )
|
|
||||||
{
|
|
||||||
return getGuestUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
// REDBACK-289/MRM-1488
|
|
||||||
// look for the user in the cache first
|
|
||||||
LdapUser ldapUser = ldapCacheService.getUser( principal.toString() );
|
|
||||||
if ( ldapUser != null )
|
|
||||||
{
|
|
||||||
log.debug( "User {} found in cache.", principal );
|
|
||||||
return ldapUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
LdapConnection ldapConnection = getLdapConnection();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DirContext context = ldapConnection.getDirContext();
|
|
||||||
|
|
||||||
User user = controller.getUser( principal, context );
|
|
||||||
|
|
||||||
// REDBACK-289/MRM-1488
|
|
||||||
log.debug( "Adding user {} to cache..", principal );
|
|
||||||
|
|
||||||
ldapCacheService.addUser( (LdapUser) user );
|
|
||||||
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
catch ( LdapControllerException e )
|
|
||||||
{
|
|
||||||
log.error( "Failed to find user: {}", principal, e );
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch ( MappingException e )
|
|
||||||
{
|
|
||||||
log.error( "Failed to map user: {}", principal, e );
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
closeLdapConnection( ldapConnection );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
||||||
{
|
{
|
||||||
LdapUserQuery query = new LdapUserQuery();
|
LdapUserQuery query = new LdapUserQuery();
|
||||||
|
@ -437,7 +362,7 @@ public class LdapUserManager
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean userExists( Object principal )
|
public boolean userExists( String principal )
|
||||||
{
|
{
|
||||||
if ( principal == null )
|
if ( principal == null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,21 +138,7 @@ public class MemoryUserManager
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User findUser( Object principal )
|
public boolean userExists( String principal )
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
triggerInit();
|
|
||||||
User user = users.get( principal );
|
|
||||||
|
|
||||||
if ( user == null )
|
|
||||||
{
|
|
||||||
throw new UserNotFoundException( "Cannot find the user with the principal '" + principal + "'." );
|
|
||||||
}
|
|
||||||
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean userExists( Object principal )
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -165,11 +151,6 @@ public class MemoryUserManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteUser( Object principal )
|
|
||||||
throws UserNotFoundException
|
|
||||||
{
|
|
||||||
deleteUser( principal.toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public User createUser( String username, String fullName, String emailAddress )
|
public User createUser( String username, String fullName, String emailAddress )
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class AbstractUserManagerTestCase
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
getUserManager().findUser( obj );
|
getUserManager().findUser( null );
|
||||||
fail( "findUser() with null Object Should have thrown a UserNotFoundException." );
|
fail( "findUser() with null Object Should have thrown a UserNotFoundException." );
|
||||||
}
|
}
|
||||||
catch ( UserNotFoundException e )
|
catch ( UserNotFoundException e )
|
||||||
|
|
Loading…
Reference in New Issue