diff --git a/redback-common/redback-common-ldap/src/test/java/org/apache/archiva/redback/common/ldap/user/MockUserManager.java b/redback-common/redback-common-ldap/src/test/java/org/apache/archiva/redback/common/ldap/user/MockUserManager.java index b2dd32e9..4d2fbdea 100644 --- a/redback-common/redback-common-ldap/src/test/java/org/apache/archiva/redback/common/ldap/user/MockUserManager.java +++ b/redback-common/redback-common-ldap/src/test/java/org/apache/archiva/redback/common/ldap/user/MockUserManager.java @@ -102,6 +102,13 @@ public class MockUserManager return null; //To change body of implemented methods use File | Settings | File Templates. } + @Override + public User findUser( String username, boolean useCache ) + throws UserNotFoundException, UserManagerException + { + return null; + } + public User getGuestUser() throws UserNotFoundException, UserManagerException { diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultPasswordService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultPasswordService.java index 62b6de4b..cd2c9b5f 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultPasswordService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultPasswordService.java @@ -107,7 +107,7 @@ public class DefaultPasswordService String encodedPassword = passwordValidator.validatePassword( password, principal ); - User user = securitySystem.getUserManager().findUser( principal ); + User user = securitySystem.getUserManager().findUser( principal, false ); user.setPassword( password ); user.setEncodedPassword( encodedPassword ); user = securitySystem.getUserManager().updateUser( user ); diff --git a/redback-system/src/test/java/org/apache/archiva/redback/system/MockUserManager.java b/redback-system/src/test/java/org/apache/archiva/redback/system/MockUserManager.java index b49dd5b0..75c70c41 100644 --- a/redback-system/src/test/java/org/apache/archiva/redback/system/MockUserManager.java +++ b/redback-system/src/test/java/org/apache/archiva/redback/system/MockUserManager.java @@ -100,6 +100,13 @@ public class MockUserManager return null; //To change body of implemented methods use File | Settings | File Templates. } + @Override + public User findUser( String username, boolean useCache ) + throws UserNotFoundException, UserManagerException + { + return null; + } + public User getGuestUser() throws UserNotFoundException, UserManagerException { diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManager.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManager.java index e6c967b8..9c758834 100644 --- a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManager.java +++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManager.java @@ -136,6 +136,9 @@ public interface UserManager User findUser( String username ) throws UserNotFoundException, UserManagerException; + User findUser( String username, boolean useCache ) + throws UserNotFoundException, UserManagerException; + /** * Get the guest user. * diff --git a/redback-users/redback-users-providers/redback-users-cached/src/main/java/org/apache/archiva/redback/users/cached/CachedUserManager.java b/redback-users/redback-users-providers/redback-users-cached/src/main/java/org/apache/archiva/redback/users/cached/CachedUserManager.java index b63092dc..d209e760 100644 --- a/redback-users/redback-users-providers/redback-users-cached/src/main/java/org/apache/archiva/redback/users/cached/CachedUserManager.java +++ b/redback-users/redback-users-providers/redback-users-cached/src/main/java/org/apache/archiva/redback/users/cached/CachedUserManager.java @@ -137,6 +137,14 @@ public class CachedUserManager } } + @Override + public User findUser( String username, boolean useCache ) + throws UserNotFoundException, UserManagerException + { + // force use of cache here :-) + return findUser( username ); + } + public User getGuestUser() throws UserNotFoundException, UserManagerException { diff --git a/redback-users/redback-users-providers/redback-users-configurable/src/main/java/org/apache/archiva/redback/users/configurable/ConfigurableUserManager.java b/redback-users/redback-users-providers/redback-users-configurable/src/main/java/org/apache/archiva/redback/users/configurable/ConfigurableUserManager.java index e6f42429..9bee16c6 100644 --- a/redback-users/redback-users-providers/redback-users-configurable/src/main/java/org/apache/archiva/redback/users/configurable/ConfigurableUserManager.java +++ b/redback-users/redback-users-providers/redback-users-configurable/src/main/java/org/apache/archiva/redback/users/configurable/ConfigurableUserManager.java @@ -106,6 +106,13 @@ public class ConfigurableUserManager return userManagerImpl.findUser( username ); } + @Override + public User findUser( String username, boolean useCache ) + throws UserNotFoundException, UserManagerException + { + return userManagerImpl.findUser( username, useCache ); + } + @Override public User getGuestUser() throws UserNotFoundException, UserManagerException diff --git a/redback-users/redback-users-providers/redback-users-jdo/src/main/java/org/apache/archiva/redback/users/jdo/JdoUserManager.java b/redback-users/redback-users-providers/redback-users-jdo/src/main/java/org/apache/archiva/redback/users/jdo/JdoUserManager.java index 07fb0c3a..2369a168 100644 --- a/redback-users/redback-users-providers/redback-users-jdo/src/main/java/org/apache/archiva/redback/users/jdo/JdoUserManager.java +++ b/redback-users/redback-users-providers/redback-users-jdo/src/main/java/org/apache/archiva/redback/users/jdo/JdoUserManager.java @@ -300,6 +300,13 @@ public class JdoUserManager return (User) getObjectById( username, null ); } + @Override + public User findUser( String username, boolean useCache ) + throws UserNotFoundException, UserManagerException + { + return findUser( username ); + } + public boolean userExists( String principal ) throws UserManagerException { diff --git a/redback-users/redback-users-providers/redback-users-ldap/src/main/java/org/apache/archiva/redback/users/ldap/LdapUserManager.java b/redback-users/redback-users-providers/redback-users-ldap/src/main/java/org/apache/archiva/redback/users/ldap/LdapUserManager.java index d0eab844..229f5d3f 100644 --- a/redback-users/redback-users-providers/redback-users-ldap/src/main/java/org/apache/archiva/redback/users/ldap/LdapUserManager.java +++ b/redback-users/redback-users-providers/redback-users-ldap/src/main/java/org/apache/archiva/redback/users/ldap/LdapUserManager.java @@ -51,24 +51,24 @@ import java.util.List; /** * @author jesse */ -@Service( "userManager#ldap" ) +@Service("userManager#ldap") public class LdapUserManager extends AbstractUserManager implements UserManager { @Inject - @Named( value = "ldapConnectionFactory#configurable" ) + @Named(value = "ldapConnectionFactory#configurable") private LdapConnectionFactory connectionFactory; @Inject private LdapController controller; @Inject - @Named( value = "userMapper#ldap" ) + @Named(value = "userMapper#ldap") private UserMapper mapper; @Inject - @Named( value = "userConfiguration#default" ) + @Named(value = "userConfiguration#default") private UserConfiguration userConf; @Inject @@ -195,7 +195,8 @@ public class LdapUserManager // TODO Implement erase! } - public User findUser( String username ) + @Override + public User findUser( String username, boolean useCache ) throws UserNotFoundException, UserManagerException { if ( username == null ) @@ -203,15 +204,17 @@ public class LdapUserManager throw new UserNotFoundException( "Unable to find user based on null username." ); } - // REDBACK-289/MRM-1488 - // look for the user in the cache first - LdapUser ldapUser = ldapCacheService.getUser( username ); - if ( ldapUser != null ) + if ( useCache ) { - log.debug( "User {} found in cache.", username ); - return ldapUser; + // REDBACK-289/MRM-1488 + // look for the user in the cache first + LdapUser ldapUser = ldapCacheService.getUser( username ); + if ( ldapUser != null ) + { + log.debug( "User {} found in cache.", username ); + return ldapUser; + } } - LdapConnection ldapConnection = null; try @@ -251,6 +254,12 @@ public class LdapUserManager } } + public User findUser( String username ) + throws UserNotFoundException, UserManagerException + { + return findUser( username, true ); + } + public List findUsersByEmailKey( String emailKey, boolean orderAscending ) throws UserManagerException { diff --git a/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java b/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java index 5e7e4c78..d2984ce5 100644 --- a/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java +++ b/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java @@ -212,6 +212,13 @@ public class MemoryUserManager return user; } + @Override + public User findUser( String username, boolean useCache ) + throws UserNotFoundException, UserManagerException + { + return findUser( username ); + } + public List findUsersByUsernameKey( String usernameKey, boolean orderAscending ) { triggerInit();