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.controller;
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.controller.Controller;
022    
023    
024    /**
025     * Controller definition for {@link User}.
026     * 
027     * @author Thiago H. de Paula Figueiredo
028     */
029    public interface UserController extends Controller<User, Integer> {
030    
031            /**
032             * Returns the user with a given login and password or <code>null</code> if no such user
033             * exists.
034             * 
035             * @param login a <code>String</code>.
036             * @return
037             */
038            User findByLoginAndPassword(String login, String password);
039    
040            /**
041             * Returns the user with a given login or <code>null</code> if no such user exists.
042             * 
043             * @param login a <code>String</code>.
044             * @return an {@link User}.
045             */
046            User findByLogin(String login);
047    
048            /**
049             * Returns all users with a given {@link Role} subclass.
050             *  
051             * @param role a {@link Class}. It must be a {@link Role} subclass and cannot be null.
052             * @return a {@link List} of {@link User}s.
053             */
054            <T extends Role> List<User> findByRole(Class<T> roleClass);
055            
056            /**
057             * Tells if some user with a given login exists. 
058             * @param login a {@link String}. It cannot be null.
059             * 
060             * @return a <code>boolean</code>.
061             */
062            boolean hasUserWithLogin(String login);
063            
064    }