You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/04/07 17:05:30 UTC

svn commit: r1310783 - in /archiva/redback/redback-core/trunk: redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/ redback-users/redback-users-providers/redback-users-memory/s...

Author: olamy
Date: Sat Apr  7 15:05:29 2012
New Revision: 1310783

URL: http://svn.apache.org/viewvc?rev=1310783&view=rev
Log:
package move to o.a.a.r

Added:
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java   (with props)
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUser.java   (with props)
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUserQuery.java   (with props)
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/util/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/util/UserSorter.java   (with props)
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/users/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/users/MemoryUserManagerTest.java   (with props)
Removed:
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/codehaus/
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/codehaus/
Modified:
    archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/AbstractUserCredentialsActionTest.java
    archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/UserEditActionTest.java
    archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/resources/META-INF/spring-context.xml

Modified: archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/AbstractUserCredentialsActionTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/AbstractUserCredentialsActionTest.java?rev=1310783&r1=1310782&r2=1310783&view=diff
==============================================================================
--- archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/AbstractUserCredentialsActionTest.java (original)
+++ archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/AbstractUserCredentialsActionTest.java Sat Apr  7 15:05:29 2012
@@ -37,7 +37,7 @@ import org.codehaus.plexus.redback.syste
 import org.codehaus.plexus.redback.system.SecuritySystemConstants;
 import org.apache.archiva.redback.users.User;
 import org.apache.archiva.redback.users.UserNotFoundException;
-import org.codehaus.plexus.redback.users.memory.SimpleUser;
+import org.apache.archiva.redback.users.memory.SimpleUser;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.runner.RunWith;

Modified: archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/UserEditActionTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/UserEditActionTest.java?rev=1310783&r1=1310782&r2=1310783&view=diff
==============================================================================
--- archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/UserEditActionTest.java (original)
+++ archiva/redback/redback-core/trunk/redback-integrations/redback-struts2/redback-struts2-integration/src/test/java/org/codehaus/plexus/redback/struts2/action/admin/UserEditActionTest.java Sat Apr  7 15:05:29 2012
@@ -33,7 +33,7 @@ import org.codehaus.plexus.redback.rbac.
 import org.codehaus.plexus.redback.system.DefaultSecuritySession;
 import org.codehaus.plexus.redback.system.SecuritySession;
 import org.codehaus.plexus.redback.system.SecuritySystemConstants;
-import org.codehaus.plexus.redback.users.memory.SimpleUser;
+import org.apache.archiva.redback.users.memory.SimpleUser;
 import org.codehaus.redback.integration.model.AdminEditUserCredentials;
 import org.junit.After;
 import org.junit.Before;

Added: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java?rev=1310783&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java Sat Apr  7 15:05:29 2012
@@ -0,0 +1,335 @@
+package org.apache.archiva.redback.users.memory;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.redback.users.User;
+import org.apache.archiva.redback.users.UserManager;
+import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
+import org.apache.archiva.redback.users.AbstractUserManager;
+import org.apache.archiva.redback.users.PermanentUserException;
+import org.apache.archiva.redback.users.UserQuery;
+import org.apache.archiva.redback.users.UserNotFoundException;
+import org.apache.archiva.redback.users.memory.util.UserSorter;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.annotation.Resource;
+
+/**
+ * @version $Id$
+ */
+@Service("userManager#memory")
+public class MemoryUserManager
+    extends AbstractUserManager
+    implements UserManager
+{
+    @Resource
+    private UserSecurityPolicy userSecurityPolicy;
+
+    public String getId()
+    {
+        Properties props = new Properties();
+        URL url = this
+            .getClass()
+            .getResource(
+                "META-INF/maven/org/codehaus/plexus/redback/redback-users-memory/pom.properties" );
+
+        if ( url != null )
+        {
+            try
+            {
+                props.load( url.openStream() );
+                return "MemoryUserManager - " + props.getProperty( "version" );
+            }
+            catch ( IOException e )
+            {
+                // Fall thru
+            }
+        }
+        return "MemoryUserManager - (unknown version)";
+    }
+    
+    public boolean isReadOnly()
+    {
+        return false;
+    }
+
+    public UserQuery createUserQuery()
+    {
+        return new SimpleUserQuery();
+    }
+
+    public List<User> findUsersByQuery( UserQuery query )
+    {
+        SimpleUserQuery uq = (SimpleUserQuery) query;
+
+        List<User> list = new ArrayList<User>();
+
+        for ( Iterator<User> i = users.values().iterator(); i.hasNext(); )
+        {
+            SimpleUser user = (SimpleUser) i.next();
+            boolean matches = uq.matches( user );
+            if ( matches )
+            {
+                list.add( user );
+            }
+        }
+
+        Collections.sort( list, uq.getComparator() );
+
+        List<User> cutList = new ArrayList<User>();
+
+        for ( long i = query.getFirstResult();
+              i < list.size() && ( query.getMaxResults() == -1 || i < query.getFirstResult() + uq.getMaxResults() );
+              i++ )
+        {
+            cutList.add( list.get( (int) i ) );
+        }
+        return cutList;
+    }
+
+    private Map<Object, User> users = new HashMap<Object, User>();
+
+    public User addUser( User user )
+    {
+        saveUser( user );
+        fireUserManagerUserAdded( user );
+
+        // If there exists no encoded password, then this is a new user setup 
+        if ( StringUtils.isEmpty( user.getEncodedPassword() ) )
+        {
+            userSecurityPolicy.extensionChangePassword( user );
+        }
+
+        return user;
+    }
+
+    private void saveUser( User user )
+    {
+        triggerInit();
+        users.put( user.getPrincipal(), user );
+    }
+
+    public User updateUser( User user )
+    {
+        return updateUser( user, false );
+    }
+
+    public User updateUser( User user, boolean passwordChangeRequired )
+    {
+        if ( StringUtils.isNotEmpty( user.getPassword() ) )
+        {
+            userSecurityPolicy.extensionChangePassword( user, passwordChangeRequired );
+        }
+
+        saveUser( user );
+
+        fireUserManagerUserUpdated( user );
+
+        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 )
+    {
+        try
+        {
+            findUser( principal );
+            return true;
+        }
+        catch ( UserNotFoundException ne )
+        {
+            return false;
+        }
+    }
+
+    public void deleteUser( Object principal )
+        throws UserNotFoundException
+    {
+        deleteUser( principal.toString() );
+    }
+
+    public User createUser( String username, String fullName, String emailAddress )
+    {
+        User user = new SimpleUser();
+        user.setUsername( username );
+        user.setFullName( fullName );
+        user.setEmail( emailAddress );
+
+        return user;
+    }
+
+    public void deleteUser( String username )
+        throws UserNotFoundException
+    {
+        User user = findUser( username );
+
+        if ( user.isPermanent() )
+        {
+            throw new PermanentUserException( "Cannot delete permanent user." );
+        }
+
+        users.remove( user.getPrincipal() );
+
+        fireUserManagerUserRemoved( user );
+    }
+
+    public void addUserUnchecked( User user )
+    {
+        addUser( user );
+    }
+
+    public void eraseDatabase()
+    {
+        users.clear();
+    }
+
+    public User findUser( String username )
+        throws UserNotFoundException
+    {
+        triggerInit();
+        User user = null;
+
+        Iterator<User> it = users.values().iterator();
+        while ( it.hasNext() )
+        {
+            User u = it.next();
+            if ( u.getUsername().equals( username ) )
+            {
+                user = u;
+            }
+        }
+
+        if ( user == null )
+        {
+            throw new UserNotFoundException( "Unable to find user '" + username + "'" );
+        }
+
+        return user;
+    }
+
+    public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
+    {
+        triggerInit();
+
+        List<User> userList = new ArrayList<User>();
+
+        Iterator<User> it = users.values().iterator();
+        while ( it.hasNext() )
+        {
+            User u = it.next();
+            if ( u.getUsername().indexOf( usernameKey ) > -1 )
+            {
+                userList.add( u );
+            }
+        }
+
+        Collections.sort( userList, new UserSorter( orderAscending ) );
+
+        return userList;
+    }
+
+    public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
+    {
+        triggerInit();
+
+        List<User> userList = new ArrayList<User>();
+
+        Iterator<User> it = users.values().iterator();
+        while ( it.hasNext() )
+        {
+            User u = it.next();
+            if ( u.getFullName().indexOf( fullNameKey ) > -1 )
+            {
+                userList.add( u );
+            }
+        }
+
+        Collections.sort( userList, new UserSorter( orderAscending ) );
+
+        return userList;
+    }
+
+    public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
+    {
+        triggerInit();
+
+        List<User> userList = new ArrayList<User>();
+
+        Iterator<User> it = users.values().iterator();
+        while ( it.hasNext() )
+        {
+            User u = it.next();
+            if ( u.getEmail().indexOf( emailKey ) > -1 )
+            {
+                userList.add( u );
+            }
+        }
+
+        Collections.sort( userList, new UserSorter( orderAscending ) );
+
+        return userList;
+    }
+
+    public List<User> getUsers()
+    {
+        triggerInit();
+        return new ArrayList<User>( users.values() );
+    }
+
+    public List<User> getUsers( boolean ascendingUsername )
+    {
+        return getUsers();
+    }
+
+    private boolean hasTriggeredInit = false;
+
+    public void triggerInit()
+    {
+        if ( !hasTriggeredInit )
+        {
+            fireUserManagerInit( users.isEmpty() );
+            hasTriggeredInit = true;
+        }
+    }
+}

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUser.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUser.java?rev=1310783&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUser.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUser.java Sat Apr  7 15:05:29 2012
@@ -0,0 +1,223 @@
+package org.apache.archiva.redback.users.memory;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.redback.users.User;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A Simple User record.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class SimpleUser
+    implements User, Serializable
+{
+    private String username;
+
+    private String password;
+
+    private String email;
+
+    private String fullName;
+
+    private String encodedPassword;
+
+    private Date lastPasswordChange;
+
+    private Date lastLoginDate;
+
+    private int countFailedLoginAttempts = 0;
+
+    private boolean locked = false;
+
+    private boolean permanent = false;
+
+    private boolean validated = false;
+
+    private List<String> previousEncodedPasswords;
+
+    private Date accountCreationDate;
+
+    private boolean passwordChangeRequired;
+
+    public SimpleUser()
+    {
+        // no op
+    }
+
+    public void addPreviousEncodedPassword( String encodedPassword )
+    {
+        getPreviousEncodedPasswords().add( encodedPassword );
+    }
+
+    public Date getAccountCreationDate()
+    {
+        return accountCreationDate;
+    }
+
+    public int getCountFailedLoginAttempts()
+    {
+        return countFailedLoginAttempts;
+    }
+
+    public String getEmail()
+    {
+        return email;
+    }
+
+    public String getEncodedPassword()
+    {
+        return encodedPassword;
+    }
+
+    public String getFullName()
+    {
+        return fullName;
+    }
+
+    public Date getLastLoginDate()
+    {
+        return lastLoginDate;
+    }
+
+    public Date getLastPasswordChange()
+    {
+        return lastPasswordChange;
+    }
+
+    public String getPassword()
+    {
+        return password;
+    }
+
+    public List<String> getPreviousEncodedPasswords()
+    {
+        if ( previousEncodedPasswords == null )
+        {
+            previousEncodedPasswords = new ArrayList<String>();
+        }
+        return previousEncodedPasswords;
+    }
+
+    public Object getPrincipal()
+    {
+        return username;
+    }
+
+    public String getUsername()
+    {
+        return username;
+    }
+
+    public boolean isLocked()
+    {
+        return locked;
+    }
+
+    public void setAccountCreationDate( Date accountCreationDate )
+    {
+        this.accountCreationDate = accountCreationDate;
+    }
+
+    public void setCountFailedLoginAttempts( int countFailedLoginAttempts )
+    {
+        this.countFailedLoginAttempts = countFailedLoginAttempts;
+    }
+
+    public void setEmail( String email )
+    {
+        this.email = email;
+    }
+
+    public void setEncodedPassword( String encodedPassword )
+    {
+        this.encodedPassword = encodedPassword;
+    }
+
+    public void setFullName( String fullName )
+    {
+        this.fullName = fullName;
+    }
+
+    public void setLastLoginDate( Date lastLoginDate )
+    {
+        this.lastLoginDate = lastLoginDate;
+    }
+
+    public void setLastPasswordChange( Date lastPasswordChange )
+    {
+        this.lastPasswordChange = lastPasswordChange;
+    }
+
+    public void setLocked( boolean locked )
+    {
+        this.locked = locked;
+    }
+
+    public void setPassword( String password )
+    {
+        this.password = password;
+    }
+
+    public void setPreviousEncodedPasswords( List<String> previousEncodedPasswords )
+    {
+        this.previousEncodedPasswords = previousEncodedPasswords;
+    }
+
+    public void setUsername( String username )
+    {
+        this.username = username;
+    }
+
+    public boolean isPasswordChangeRequired()
+    {
+        return passwordChangeRequired;
+    }
+
+    public void setPasswordChangeRequired( boolean passwordChangeRequired )
+    {
+        this.passwordChangeRequired = passwordChangeRequired;
+    }
+
+    public boolean isPermanent()
+    {
+        return permanent;
+    }
+
+    public void setPermanent( boolean permanent )
+    {
+        this.permanent = permanent;
+    }
+
+    public boolean isValidated()
+    {
+        return validated;
+    }
+
+    public void setValidated( boolean validated )
+    {
+        this.validated = validated;
+    }
+}

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUser.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUserQuery.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUserQuery.java?rev=1310783&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUserQuery.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUserQuery.java Sat Apr  7 15:05:29 2012
@@ -0,0 +1,94 @@
+package org.apache.archiva.redback.users.memory;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.redback.users.AbstractUserQuery;
+import org.apache.archiva.redback.users.User;
+
+import java.util.Comparator;
+
+public class SimpleUserQuery
+    extends AbstractUserQuery
+{
+
+    /**
+     * Returns true if this user should be considered a match of the current query
+     *
+     * @param user
+     * @return
+     */
+    public boolean matches( User user )
+    {
+        if ( getUsername() != null && user.getUsername() != null &&
+            user.getUsername().toLowerCase().indexOf( getUsername().toLowerCase() ) == -1 )
+        {
+            return false;
+        }
+        else if ( getFullName() != null && user.getFullName() != null &&
+            user.getFullName().toLowerCase().indexOf( getFullName().toLowerCase() ) == -1 )
+        {
+            return false;
+        }
+        else if ( getEmail() != null && user.getEmail() != null &&
+            user.getEmail().toLowerCase().indexOf( getEmail().toLowerCase() ) == -1 )
+        {
+            return false;
+        }
+        else
+        {
+            return true;
+        }
+
+    }
+
+    /**
+     * Returns a comparator used for sorting a collection of User objects based on the ordering set
+     * on this UserQuery's {@link #setOrderBy(String)} and {@link #setAscending(boolean)}. 
+     * @return
+     */
+    public Comparator<User> getComparator()
+    {
+        return new Comparator<User>()
+        {
+            public int compare( User user1, User user2 )
+            {
+                return ( isAscending() ? 1 : -1 ) * compareUsers( user1, user2 );
+            }
+        };
+    }
+
+    private int compareUsers( User user, User user1 )
+    {
+        if ( ORDER_BY_EMAIL.equals( getOrderBy() ) )
+        {
+            return user.getEmail() == null ? -1
+                : user1.getEmail() == null ? 1 : user.getEmail().compareTo( user1.getEmail() );
+        }
+        else if ( ORDER_BY_FULLNAME.equals( getOrderBy() ) )
+        {
+            return user.getFullName() == null ? -1
+                : user1.getFullName() == null ? 1 : user.getFullName().compareTo( user1.getFullName() );
+        }
+        else
+        {
+            return user.getUsername().compareTo( user1.getUsername() );
+        }
+    }
+}

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUserQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUserQuery.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/util/UserSorter.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/util/UserSorter.java?rev=1310783&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/util/UserSorter.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/util/UserSorter.java Sat Apr  7 15:05:29 2012
@@ -0,0 +1,88 @@
+package org.apache.archiva.redback.users.memory.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.redback.users.User;
+
+import java.util.Comparator;
+
+/**
+ * UserSorter
+ */
+public class UserSorter
+    implements Comparator<User>
+{
+    private boolean ascending;
+
+    public UserSorter()
+    {
+        this.ascending = true;
+    }
+
+    public UserSorter( boolean ascending )
+    {
+        this.ascending = ascending;
+    }
+
+    public int compare( User o1, User o2 )
+    {
+        if ( ( o1 == null ) && ( o2 == null ) )
+        {
+            return 0;
+        }
+
+        if ( ( o1 == null ) && ( o2 != null ) )
+        {
+            return -1;
+        }
+
+        if ( ( o1 != null ) && ( o2 != null ) )
+        {
+            return 1;
+        }
+
+        User u1 = null;
+        User u2 = null;
+
+        if ( isAscending() )
+        {
+            u1 = o1;
+            u2 = o2;
+        }
+        else
+        {
+            u1 = o2;
+            u2 = o1;
+        }
+
+        return u1.getUsername().compareTo( u2.getUsername() );
+    }
+
+    public boolean isAscending()
+    {
+        return ascending;
+    }
+
+    public void setAscending( boolean ascending )
+    {
+        this.ascending = ascending;
+    }
+
+}

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/util/UserSorter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/util/UserSorter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/resources/META-INF/spring-context.xml?rev=1310783&r1=1310782&r2=1310783&view=diff
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/resources/META-INF/spring-context.xml (original)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/main/resources/META-INF/spring-context.xml Sat Apr  7 15:05:29 2012
@@ -28,6 +28,6 @@
        default-lazy-init="true">
 
   <context:annotation-config />
-  <context:component-scan base-package="org.codehaus.plexus.redback.users.memory"/>
+  <context:component-scan base-package="org.apache.archiva.redback.users.memory"/>
  
 </beans>
\ No newline at end of file

Added: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/users/MemoryUserManagerTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/users/MemoryUserManagerTest.java?rev=1310783&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/users/MemoryUserManagerTest.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/users/MemoryUserManagerTest.java Sat Apr  7 15:05:29 2012
@@ -0,0 +1,49 @@
+package org.apache.archiva.redback.users;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.redback.users.UserManager;
+import org.apache.archiva.redback.users.memory.MemoryUserManager;
+import org.codehaus.plexus.redback.users.provider.test.AbstractUserManagerTestCase;
+import org.junit.Before;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * {@link MemoryUserManager} test:
+ * 
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ */
+public class MemoryUserManagerTest
+    extends AbstractUserManagerTestCase
+{
+
+    @Inject @Named(value = "userManager#memory")
+    UserManager userManager;
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setUserManager( userManager );
+    }
+}

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/users/MemoryUserManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-providers/redback-users-memory/src/test/java/org/apache/archiva/redback/users/MemoryUserManagerTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision