();
+
+ public void addUserManagerListener( UserManagerListener listener )
+ {
+ if ( !listeners.contains( listener ) )
+ {
+ listeners.add( listener );
+ }
+ }
+
+ public void removeUserManagerListener( UserManagerListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ protected void fireUserManagerInit( boolean freshDatabase )
+ {
+ for ( UserManagerListener listener : listeners )
+ {
+ try
+ {
+ listener.userManagerInit( freshDatabase );
+ }
+ catch ( Exception e )
+ {
+ // Ignore
+ }
+ }
+ }
+
+ protected void fireUserManagerUserAdded( User addedUser )
+ {
+ for ( UserManagerListener listener : listeners )
+ {
+ try
+ {
+ listener.userManagerUserAdded( addedUser );
+ }
+ catch ( Exception e )
+ {
+ // Ignore
+ }
+ }
+ }
+
+ protected void fireUserManagerUserRemoved( User removedUser )
+ {
+ for ( UserManagerListener listener : listeners )
+ {
+ try
+ {
+ listener.userManagerUserRemoved( removedUser );
+ }
+ catch ( Exception e )
+ {
+ // Ignore
+ }
+ }
+ }
+
+ protected void fireUserManagerUserUpdated( User updatedUser )
+ {
+ for ( UserManagerListener listener : listeners )
+ {
+ try
+ {
+ listener.userManagerUserUpdated( updatedUser );
+ }
+ catch ( Exception e )
+ {
+ // Ignore
+ }
+ }
+ }
+
+ public User getGuestUser()
+ throws UserNotFoundException
+ {
+ return findUser( GUEST_USERNAME );
+ }
+
+ public User createGuestUser()
+ {
+ try
+ {
+ User u = getGuestUser();
+ if ( u != null )
+ {
+ return u;
+ }
+ }
+ catch ( UserNotFoundException e )
+ {
+ //Nothing to do
+ }
+
+ User user = createUser( GUEST_USERNAME, "Guest", "" );
+ user.setPermanent( true );
+ user.setPasswordChangeRequired( false );
+
+ user = addUser( user );
+ return user;
+ }
+}
diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/AbstractUserQuery.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/AbstractUserQuery.java
new file mode 100644
index 00000000..3d8cc4f5
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/AbstractUserQuery.java
@@ -0,0 +1,122 @@
+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.
+ */
+
+/**
+ * Abstract Implementation of UserQuery.
+ * Intended to be subclassed by UserManager providers.
+ */
+public abstract class AbstractUserQuery
+ implements UserQuery
+{
+
+ private String username;
+
+ private String fullName;
+
+ private String email;
+
+ private long maxResults = -1;
+
+ private long firstResult;
+
+ private String orderBy = ORDER_BY_USERNAME;
+
+ private boolean ascending = true;
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername( String userName )
+ {
+ this.username = userName;
+ }
+
+ public String getFullName()
+ {
+ return fullName;
+ }
+
+ public void setFullName( String fullName )
+ {
+ this.fullName = fullName;
+ }
+
+ public String getEmail()
+ {
+ return email;
+ }
+
+ public void setEmail( String email )
+ {
+ this.email = email;
+ }
+
+ public long getFirstResult()
+ {
+ return firstResult;
+ }
+
+ public void setFirstResult( int firstResult )
+ {
+ this.firstResult = firstResult;
+ }
+
+ public long getMaxResults()
+ {
+ return maxResults;
+ }
+
+ public void setMaxResults( int maxResults )
+ {
+ this.maxResults = maxResults;
+ }
+
+ public String getOrderBy()
+ {
+ return orderBy;
+ }
+
+ public void setOrderBy( String orderBy )
+ {
+ if ( orderBy == null )
+ {
+ throw new IllegalArgumentException( "orderBy cannot be set to null" );
+ }
+ else if ( !ALLOWED_ORDER_FIELDS.contains( orderBy ) )
+ {
+ throw new IllegalArgumentException( orderBy + " is not an allowed orderBy field: " + orderBy );
+ }
+ this.orderBy = orderBy;
+ }
+
+ public boolean isAscending()
+ {
+ return ascending;
+ }
+
+ public void setAscending( boolean ascending )
+ {
+ this.ascending = ascending;
+ }
+
+}
\ No newline at end of file
diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/Messages.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/Messages.java
new file mode 100644
index 00000000..8177d86a
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/Messages.java
@@ -0,0 +1,94 @@
+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 java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Localized Message Handling.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class Messages
+{
+ private static final String BUNDLE_NAME = "org.codehaus.plexus.redback.users.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+ /**
+ * Get a Message as-is from the Resource Bundle.
+ *
+ * @param key the key for the message to get.
+ * @return the value of the key, or "!key!" if the key is not found.
+ */
+ public static String getString( String key )
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString( key );
+ }
+ catch ( MissingResourceException e )
+ {
+ return '!' + key + '!';
+ }
+ }
+
+ /**
+ * Gets a Message from the Resource Bundle, with {1} and {2} style arguments.
+ *
+ * @param key the key for the message to get.
+ * @param arg the argument to pass in.
+ * @return the value of the key, or "!key!" if the key is not found.
+ */
+ public static String getString( String key, Object arg )
+ {
+ return getString( key, new Object[] { arg } );
+ }
+
+ /**
+ * Gets a Message from the Resource Bundle, with {1} and {2} style arguments.
+ *
+ * @param key the key for the message to get.
+ * @param args the arguments to pass in.
+ * @return the value of the key, or "!key!" if the key is not found.
+ */
+ public static String getString( String key, Object args[] )
+ {
+ try
+ {
+ String pattern = RESOURCE_BUNDLE.getString( key );
+ return MessageFormat.format( pattern, args );
+ }
+ catch ( MissingResourceException e )
+ {
+ return '!' + key + '!';
+ }
+ }
+
+ /**
+ * Prevent Instantiation.
+ */
+ private Messages()
+ {
+ }
+}
diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/PermanentUserException.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/PermanentUserException.java
new file mode 100644
index 00000000..4bf4b2ce
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/PermanentUserException.java
@@ -0,0 +1,52 @@
+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.
+ */
+
+/**
+ * PermanentUserException - tossed when a forbidden action against a permanent user
+ * occurs.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class PermanentUserException
+ extends UserManagerException
+{
+
+ public PermanentUserException()
+ {
+ super();
+ }
+
+ public PermanentUserException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public PermanentUserException( String message )
+ {
+ super( message );
+ }
+
+ public PermanentUserException( Throwable cause )
+ {
+ super( cause );
+ }
+}
diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/User.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/User.java
new file mode 100644
index 00000000..d8c9d3f9
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/User.java
@@ -0,0 +1,301 @@
+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 java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * The User Object.
+ *
+ * @author Jason van Zyl
+ * @author Joakim Erdfelt
+ */
+public interface User
+ extends Serializable
+{
+
+ /**
+ * This is the object used to track the user within the provider.
+ *
+ * @return the principal for this user.
+ */
+ Object getPrincipal();
+
+ // --------------------------------------------------------------------
+ // Standard User Requirements.
+ // --------------------------------------------------------------------
+
+ /**
+ * Gets the User Name for this user.
+ *
+ * This field is required, and should never be empty.
+ *
+ * @return the user name.
+ */
+ String getUsername();
+
+ /**
+ * Sets the User Name for this user.
+ *
+ * This field is required, and should never be empty.
+ *
+ * @param name the user name.
+ */
+ void setUsername( String name );
+
+ /**
+ * Gets the Full Name for this user.
+ *
+ * This field is required, and should never be empty.
+ *
+ * @return the full name.
+ */
+ String getFullName();
+
+ /**
+ * Sets the Full Name for this user.
+ *
+ * This field is required, and should never be empty.
+ *
+ * @param name the full name.
+ */
+ void setFullName( String name );
+
+ /**
+ * Gets the email address for this user.
+ *
+ * This field is required, and should never be empty.
+ *
+ * @return the email address.
+ */
+ String getEmail();
+
+ /**
+ * Sets the email address for this user.
+ *
+ * This field is required, and should never be empty.
+ *
+ * @param address the email address.
+ */
+ void setEmail( String address );
+
+ // --------------------------------------------------------------------
+ // Password Requirements.
+ // --------------------------------------------------------------------
+
+ /**
+ * Gets the Raw (unencoded) Password.
+ * Used only on password change requests.
+ *
+ *
+ * Notes for User Providers
+ *
+ *
+ * -
+ * Providers need to look for a value in here to indicate if the user is
+ * intending to change their password.
+ *
+ * -
+ * The providers of this interface need to use this field, encode the password, place it's value
+ * into the encodedPassword field, and clear out the raw unencoded password field.
+ *
+ * -
+ * This field should never be stored on disk.
+ *
+ *
+ *
+ * @return the raw encoded password.
+ */
+ String getPassword();
+
+ /**
+ * Sets the raw (unencoded) password for this user.
+ *
+ * @param rawPassword the raw unencoded password for this user.
+ * @see #getPassword()
+ */
+ void setPassword( String rawPassword );
+
+ /**
+ * Gets the Encoded Password.
+ *
+ * @return the encoded password.
+ */
+ String getEncodedPassword();
+
+ /**
+ * Sets the Encoded Password.
+ *
+ * This field is populated by the {@link UserManager} process.
+ *
+ * @param encodedPassword
+ */
+ void setEncodedPassword( String encodedPassword );
+
+ /**
+ * Gets the Date of the Last Password Change.
+ *
+ * Used by password management policies to enforce password expiration rules.
+ *
+ * @return the date of the last password change.
+ */
+ Date getLastPasswordChange();
+
+ /**
+ * Sets the Last Password Change Date.
+ *
+ * This field is populated by the {@link UserManager} process.
+ *
+ * @param passwordChangeDate the date that the last password change occured.
+ */
+ void setLastPasswordChange( Date passwordChangeDate );
+
+ /**
+ * Gets the list of previous password (in encoded format).
+ *
+ * Used by password management policies to enforce password reuse rules.
+ *
+ * @return the list of {@link String} objects. Represents previous passwords (in encoded format).
+ */
+ List getPreviousEncodedPasswords();
+
+ /**
+ * Sets the list of previous passwords (in encoded format)
+ *
+ * @param encodedPasswordList (list of {@link String} objects.) the previously passwords in encoded format.
+ */
+ void setPreviousEncodedPasswords( List encodedPasswordList );
+
+ /**
+ * Add encoded password to previously passwords in encoded format.
+ *
+ * @param encodedPassword the encoded password to add.
+ */
+ void addPreviousEncodedPassword( String encodedPassword );
+
+ // --------------------------------------------------------------------
+ // State
+ // --------------------------------------------------------------------
+
+ /**
+ * Gets the flag indicating if this user is a permanent user or not.
+ *
+ * Usually Root / Admin / Guest users are flagged as such.
+ */
+ boolean isPermanent();
+
+ /**
+ * Sets the permanent flag for this user.
+ *
+ * Users such as Root / Admin / Guest are typically flagged as permanent.
+ *
+ * @param permanent true if permanent.
+ */
+ void setPermanent( boolean permanent );
+
+ /**
+ * Determines if this user account is locked from use or not.
+ *
+ * This state is set from an administrative point of view, or due to
+ * excessive failed login attempts.
+ *
+ * @return true if account is locked.
+ */
+ boolean isLocked();
+
+ /**
+ * Sets the locked state of this account.
+ *
+ * @param locked true if account is to be locked.
+ */
+ void setLocked( boolean locked );
+
+ /**
+ * Determines if this user account must change their password on next login.
+ *
+ * @return true if user must change password on next login.
+ */
+ boolean isPasswordChangeRequired();
+
+ /**
+ * Sets the flag to indicate if this user must change their password on next login.
+ *
+ * @param changeRequired true if user must change password on next login.
+ */
+ void setPasswordChangeRequired( boolean changeRequired );
+
+ /**
+ * Gets the flag indicating if this user has been validated (or not)
+ *
+ * @return true if validated.
+ */
+ boolean isValidated();
+
+ /**
+ * Sets the flag indicating if this user has been validated (or not)
+ *
+ * @param valid true if validated.
+ */
+ void setValidated( boolean valid );
+
+ // --------------------------------------------------------------------
+ // Statistics
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Count of Failed Login Attempts.
+ *
+ * @return the count of failed login attempts.
+ */
+ int getCountFailedLoginAttempts();
+
+ /**
+ * Set the count of failed login attempts.
+ *
+ * @param count the count of failed login attempts.
+ */
+ void setCountFailedLoginAttempts( int count );
+
+ /**
+ * Get the Creation Date for this account.
+ *
+ * @return the date of creation for this account.
+ */
+ Date getAccountCreationDate();
+
+ /**
+ * Set the Creation Date for this account.
+ */
+ void setAccountCreationDate( Date date );
+
+ /**
+ * Get the Last Successful Login Date for this account.
+ *
+ * @return the date of the last successful login
+ */
+ Date getLastLoginDate();
+
+ /**
+ * Sets the Last Successful Login Date for this account.
+ */
+ void setLastLoginDate( Date date );
+}
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
new file mode 100644
index 00000000..4c198c78
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManager.java
@@ -0,0 +1,201 @@
+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 java.util.List;
+
+/**
+ * User Manager Interface
+ *
+ * @author Jason van Zyl
+ * @author Joakim Erdfelt
+ */
+public interface UserManager
+{
+
+ static final String GUEST_USERNAME = "guest";
+
+ /**
+ * Is the UserManager read only? if so then create and modify actions are to be disabled
+ *
+ * @return boolean true if user manager is disabled
+ */
+ boolean isReadOnly();
+
+ /**
+ * An Identifier for the UserManager.
+ *
+ * @return the user manager identifier.
+ */
+ String getId();
+
+ /**
+ * Add a {@link UserManagerListener} to track major events in the
+ * UserManager.
+ *
+ * @param listener the listener to add.
+ */
+ void addUserManagerListener( UserManagerListener listener );
+
+ /**
+ * Remove a {@link UserManagerListener} from the collection of listeners.
+ *
+ * @param listener the listener to remove.
+ */
+ void removeUserManagerListener( UserManagerListener listener );
+
+ /**
+ * Factory method to create new User Objects based on provider specific
+ * implementation.
+ *
+ * User objects created this way do not exist in the provider's underlying
+ * data store until a call to {@link #addUser(User)} is made.
+ *
+ * @param username the username for this user.
+ * @param fullName the full name for this user.
+ * @param emailAddress the email address for this user.
+ * @return the new user object ready to use.
+ */
+ User createUser( String username, String fullName, String emailAddress );
+
+ /**
+ * Factory method to create the guest user.
+ *
+ * @return The guest user
+ */
+ User createGuestUser();
+
+ /**
+ * Factory method to create {@link UserQuery}s based on provider specific
+ * implementations.
+ *
+ * @return the provider implementation of UserQuery
+ */
+ UserQuery createUserQuery();
+
+ /**
+ * Get the List of {@link User} objects.
+ *
+ * @return the List of {@link User} Objects.
+ */
+ List getUsers();
+
+ List getUsers( boolean orderAscending );
+
+ /**
+ * Add a User.
+ *
+ * @param user the user to add.
+ * @return the user that was just added.
+ */
+ User addUser( User user );
+
+ /**
+ * Update a User.
+ *
+ * @param user the user to update.
+ * @return the user that was just updated.
+ * @throws UserNotFoundException if the user was not found to update.
+ */
+ User updateUser( User user )
+ throws UserNotFoundException;
+
+ /**
+ * Find a User using a User name.
+ *
+ * @param username the username to find.
+ * @return the user.
+ * @throws UserNotFoundException if the user was not found.
+ */
+ User findUser( String username )
+ throws UserNotFoundException;
+
+ /**
+ * Get the guest user.
+ *
+ * @return the guest user.
+ */
+ User getGuestUser()
+ throws UserNotFoundException;
+
+ List findUsersByUsernameKey( String usernameKey, boolean orderAscending );
+
+ List findUsersByFullNameKey( String fullNameKey, boolean orderAscending );
+
+ List findUsersByEmailKey( String emailKey, boolean orderAscending );
+
+ /**
+ * Find users matching properties, ordering and range as specified by the
+ * {@link UserQuery}.
+ *
+ * @param query the query.
+ * @return a List of {@link User} objects.
+ */
+ List 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;
+
+ /**
+ * Delete a user using the username.
+ *
+ * @param username the username to look for.
+ * @throws UserNotFoundException the user was not found.
+ */
+ void deleteUser( String username )
+ throws UserNotFoundException;
+
+ /**
+ * Add a user to the database without checking for consistency or adjusting the password. Should only be used for
+ * re-importing known-good data.
+ *
+ * @param user the user to add
+ */
+ void addUserUnchecked( User user );
+
+ void eraseDatabase();
+
+ User updateUser( User user, boolean passwordChangeRequired )
+ throws UserNotFoundException;
+}
diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManagerException.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManagerException.java
new file mode 100644
index 00000000..a7a26bd0
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManagerException.java
@@ -0,0 +1,51 @@
+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.
+ */
+
+/**
+ * UserManagerException
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class UserManagerException
+ extends RuntimeException
+{
+
+ public UserManagerException()
+ {
+ super();
+ }
+
+ public UserManagerException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public UserManagerException( String message )
+ {
+ super( message );
+ }
+
+ public UserManagerException( Throwable cause )
+ {
+ super( cause );
+ }
+}
diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManagerListener.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManagerListener.java
new file mode 100644
index 00000000..763681fd
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserManagerListener.java
@@ -0,0 +1,37 @@
+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.
+ */
+
+/**
+ * UserManagerListener
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface UserManagerListener
+{
+ void userManagerInit( boolean freshDatabase );
+
+ void userManagerUserAdded( User user );
+
+ void userManagerUserRemoved( User user );
+
+ void userManagerUserUpdated( User user );
+}
diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserNotFoundException.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserNotFoundException.java
new file mode 100644
index 00000000..ab8006ad
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserNotFoundException.java
@@ -0,0 +1,42 @@
+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.
+ */
+
+/**
+ * @author Jason van Zyl
+ */
+public class UserNotFoundException
+ extends Exception
+{
+ public UserNotFoundException( String string )
+ {
+ super( string );
+ }
+
+ public UserNotFoundException( String string, Throwable throwable )
+ {
+ super( string, throwable );
+ }
+
+ public UserNotFoundException( Throwable throwable )
+ {
+ super( throwable );
+ }
+}
diff --git a/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserQuery.java b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserQuery.java
new file mode 100644
index 00000000..d242c8a1
--- /dev/null
+++ b/redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/UserQuery.java
@@ -0,0 +1,137 @@
+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 java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+
+public interface UserQuery
+{
+ final static String ORDER_BY_USERNAME = "username";
+
+ final static String ORDER_BY_FULLNAME = "fullname";
+
+ final static String ORDER_BY_EMAIL = "email";
+
+ final static Set ALLOWED_ORDER_FIELDS =
+ new HashSet( Arrays.asList( ORDER_BY_USERNAME, ORDER_BY_FULLNAME, ORDER_BY_EMAIL ) );
+
+ /**
+ * Returns the case insensitive substring user name criteria.
+ *
+ * @return the username criteria.
+ */
+ String getUsername();
+
+ /**
+ * Sets the case insensitive substring user name criteria.
+ *
+ * @param userName the username criteria
+ */
+ void setUsername( String userName );
+
+ /**
+ * Returns the case insensitive substring full name criteria.
+ *
+ * @return the username criteria.
+ */
+ String getFullName();
+
+ /**
+ * Sets the case insensitive substring full name criteria.
+ *
+ * @param fullName the full name criteria
+ */
+ void setFullName( String fullName );
+
+ /**
+ * Returns the case insensitive substring email criteria.
+ *
+ * @return the email criteria.
+ */
+ String getEmail();
+
+ /**
+ * Sets the case insensitive substring email criteria.
+ *
+ * @param email the email criteria
+ */
+ void setEmail( String email );
+
+ /**
+ * Returns the index (zero based) of the first result to include. Useful for paging.
+ *
+ * @return the first index
+ */
+ long getFirstResult();
+
+ /**
+ * Sets the index (zero based) of the first result to include. Useful for paging.
+ *
+ * @param firstResult the first index
+ */
+ void setFirstResult( int firstResult );
+
+ /**
+ * Returns the maximum number of users to return.
+ *
+ * @return the maximum number of users to return.
+ */
+ long getMaxResults();
+
+ /**
+ * Sets the maximum number of users to return.
+ *
+ * @param maxResults the maximum number of users to return.
+ */
+ void setMaxResults( int maxResults );
+
+ /**
+ * Returns the property used to order the results of this query.
+ * This is one of {@link #ORDER_BY_USERNAME}, {@link #ORDER_BY_FULLNAME} or {@link #ORDER_BY_EMAIL}.
+ *
+ * @return the order property.
+ */
+ String getOrderBy();
+
+ /**
+ * Sets the property used to order the results of this query.
+ * This is one of {@link #ORDER_BY_USERNAME}, {@link #ORDER_BY_FULLNAME} or {@link #ORDER_BY_EMAIL}.
+ *
+ * @param orderBy the order property.
+ */
+ void setOrderBy( String orderBy );
+
+ /**
+ * Returns true if the results should be returned in ascending order.
+ *
+ * @return ascending
+ */
+ boolean isAscending();
+
+ /**
+ * Set this to true if the results should be returned in ascending order.
+ *
+ * @param ascending true if the results should be returned in ascending
+ */
+ void setAscending( boolean ascending );
+}
diff --git a/redback-users/redback-users-api/src/main/resources/org/codehaus/plexus/redback/users/messages.properties b/redback-users/redback-users-api/src/main/resources/org/apache/archiva/redback/users/messages.properties
similarity index 100%
rename from redback-users/redback-users-api/src/main/resources/org/codehaus/plexus/redback/users/messages.properties
rename to redback-users/redback-users-api/src/main/resources/org/apache/archiva/redback/users/messages.properties