*/
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
*
* @param principal
* @return true, if user exists
*/
- boolean userExists( Object 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;
+ boolean userExists( String principal );
/**
* Delete a user using the username.
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 )
throws UserNotFoundException
{
}
}
- 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()
{
return userImpl.createUserQuery();
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 this.userImpl.userExists( principal );
+ return this.userImpl.userExists( userName );
}
public void userManagerInit( boolean freshDatabase )
return userManagerImpl.createUserQuery();
}
- public void deleteUser( Object principal )
- throws UserNotFoundException
- {
- userManagerImpl.deleteUser( principal );
- }
-
public void deleteUser( String username )
throws UserNotFoundException
{
return userManagerImpl.findUser( username );
}
- public User findUser( Object principal )
- throws UserNotFoundException
- {
- return userManagerImpl.findUser( principal );
- }
-
@Override
public User getGuestUser()
throws UserNotFoundException
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 )
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 )
{
try
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 )
throws UserNotFoundException
{
return (User) getObjectById( username, null );
}
- public boolean userExists( Object principal )
+ public boolean userExists( String principal )
{
try
{
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 )
throws UserNotFoundException
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 )
{
LdapUserQuery query = new LdapUserQuery();
return user;
}
- public boolean userExists( Object principal )
+ public boolean userExists( String principal )
{
if ( principal == null )
{
return user;
}
- public User findUser( Object 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 )
+ public boolean userExists( String principal )
{
try
{
}
}
- public void deleteUser( Object principal )
- throws UserNotFoundException
- {
- deleteUser( principal.toString() );
- }
public User createUser( String username, String fullName, String emailAddress )
{
try
{
Object obj = null;
- getUserManager().findUser( obj );
+ getUserManager().findUser( null );
fail( "findUser() with null Object Should have thrown a UserNotFoundException." );
}
catch ( UserNotFoundException e )