001    // Copyright 2008 Thiago H. de Paula Figueiredo
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package br.com.arsmachina.authentication.dao;
016    
017    import java.util.List;
018    
019    import br.com.arsmachina.authentication.entity.Role;
020    import br.com.arsmachina.authentication.entity.User;
021    import br.com.arsmachina.dao.DAO;
022    
023    
024    /**
025     * Data access object (DAO) for {@link User}.
026     * 
027     * @author Thiago H. de Paula Figueiredo
028     */
029    public interface UserDAO extends DAO<User, Integer> {
030    
031            /**
032             * Returns the user with a given login and password or <code>null</code> if no such
033             * user exists.
034             * 
035             * @param login a <code>String</code>.
036             * @param password a <code>String</code>.
037             * @return an {@link User}.
038             */
039            User findByLoginAndPassword(String login, String password);
040    
041            /**
042             * Returns the user with a given login or <code>null</code> if no such
043             * user exists.
044             * 
045             * @param login a <code>String</code>.
046             * @return an {@link User}.
047             */
048            User findByLogin(String login);
049            
050            /**
051             * Returns all users with a given {@link Role} subclass.
052             *  
053             * @param role a {@link Class}. It must be a {@link Role} subclass and cannot be null.
054             * @return a {@link List} of {@link User}s.
055             */
056            <T extends Role> List<User> findByRole(Class<T> roleClass);
057            
058            /**
059             * Tells if some user with a given login exists. 
060             * @param login a {@link String}. It cannot be null.
061             * 
062             * @return a <code>boolean</code>.
063             */
064            boolean hasUserWithLogin(String login);
065    
066    }