--- /dev/null
+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.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * AbstractUserManager
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractUserManager
+ implements UserManager
+{
+ protected Logger log = LoggerFactory.getLogger( getClass() );
+
+ private List<UserManagerListener> listeners = new ArrayList<UserManagerListener>();
+
+ 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;
+ }
+}
--- /dev/null
+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
--- /dev/null
+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 <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @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()
+ {
+ }
+}
--- /dev/null
+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 <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @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 );
+ }
+}
--- /dev/null
+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 <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+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.
+ * <p/>
+ * This field is required, and should never be empty.
+ *
+ * @return the user name.
+ */
+ String getUsername();
+
+ /**
+ * Sets the User Name for this user.
+ * <p/>
+ * 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.
+ * <p/>
+ * This field is required, and should never be empty.
+ *
+ * @return the full name.
+ */
+ String getFullName();
+
+ /**
+ * Sets the Full Name for this user.
+ * <p/>
+ * 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.
+ * <p/>
+ * This field is required, and should never be empty.
+ *
+ * @return the email address.
+ */
+ String getEmail();
+
+ /**
+ * Sets the email address for this user.
+ * <p/>
+ * 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.
+ * <p/>
+ * <p>
+ * <b>Notes for User Providers</b>
+ * </p>
+ * <ol>
+ * <li>
+ * Providers need to look for a value in here to indicate if the user is
+ * intending to change their password.
+ * </li>
+ * <li>
+ * 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.
+ * </li>
+ * <li>
+ * This field should never be stored on disk.
+ * </li>
+ * </ol>
+ *
+ * @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.
+ * <p/>
+ * This field is populated by the {@link UserManager} process.
+ *
+ * @param encodedPassword
+ */
+ void setEncodedPassword( String encodedPassword );
+
+ /**
+ * Gets the Date of the Last Password Change.
+ * <p/>
+ * 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.
+ * <p/>
+ * 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).
+ * <p/>
+ * Used by password management policies to enforce password reuse rules.
+ *
+ * @return the list of {@link String} objects. Represents previous passwords (in encoded format).
+ */
+ List<String> 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<String> 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.
+ * <p/>
+ * Usually Root / Admin / Guest users are flagged as such.
+ */
+ boolean isPermanent();
+
+ /**
+ * Sets the permanent flag for this user.
+ * <p/>
+ * 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.
+ * <p/>
+ * 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 );
+}
--- /dev/null
+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 <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+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.
+ * <p/>
+ * 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<User> getUsers();
+
+ List<User> 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<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending );
+
+ List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending );
+
+ List<User> 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<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;
+
+ /**
+ * 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;
+}
--- /dev/null
+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 <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @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 );
+ }
+}
--- /dev/null
+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 <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface UserManagerListener
+{
+ void userManagerInit( boolean freshDatabase );
+
+ void userManagerUserAdded( User user );
+
+ void userManagerUserRemoved( User user );
+
+ void userManagerUserUpdated( User user );
+}
--- /dev/null
+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 );
+ }
+}
--- /dev/null
+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<String> ALLOWED_ORDER_FIELDS =
+ new HashSet<String>( 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 );
+}
--- /dev/null
+# 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.
+
+password.encoder.no.such.algoritm=The specified algorithm {0} is not available in the JAAS Implementation of this JVM.
+password.encoder.unsupported.encoding=The UTF-8 Encoding is not available in the JAAS Implementation of this JVM.
+user.password.violation.missing=You must provide a password.
+user.password.violation.length=You must provide a password between {0} and {1} characters in length.
+user.password.violation.length.misconfigured=Password Length Rule is misconfigured. Specified minimum of ({0}) is larger than specified maximum of ({1}). Rule disabled.
+user.password.violation.alpha=You must provide a password containing at least {0} alphabetic character(s).
+user.password.violation.numeric=You must provide a password containing at least {0} numeric character(s).
+user.password.violation.reuse=Your password cannot match any of your previous {0} password(s).
+user.password.violation.alphanum.only=You must provide a password containing all alpha-numeric characters.
+user.password.violation.whitespace.detected=You must provide a password without whitespace characters.
\ No newline at end of file
+++ /dev/null
-# 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.
-
-password.encoder.no.such.algoritm=The specified algorithm {0} is not available in the JAAS Implementation of this JVM.
-password.encoder.unsupported.encoding=The UTF-8 Encoding is not available in the JAAS Implementation of this JVM.
-user.password.violation.missing=You must provide a password.
-user.password.violation.length=You must provide a password between {0} and {1} characters in length.
-user.password.violation.length.misconfigured=Password Length Rule is misconfigured. Specified minimum of ({0}) is larger than specified maximum of ({1}). Rule disabled.
-user.password.violation.alpha=You must provide a password containing at least {0} alphabetic character(s).
-user.password.violation.numeric=You must provide a password containing at least {0} numeric character(s).
-user.password.violation.reuse=Your password cannot match any of your previous {0} password(s).
-user.password.violation.alphanum.only=You must provide a password containing all alpha-numeric characters.
-user.password.violation.whitespace.detected=You must provide a password without whitespace characters.
\ No newline at end of file