001    /*
002     * Copyright 2010 the original author or authors.
003     * 
004     *  Licensed under the Apache License, Version 2.0 (the "License");
005     *  you may not use this file except in compliance with the License.
006     *  You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     *  Unless required by applicable law or agreed to in writing, software
011     *  distributed under the License is distributed on an "AS IS" BASIS,
012     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     *  See the License for the specific language governing permissions and
014     *  limitations under the License.
015     */
016    package com.hs.mail.imap.user;
017    
018    import java.io.File;
019    import java.util.List;
020    
021    import javax.mail.Quota;
022    import javax.security.auth.login.LoginException;
023    
024    import com.hs.mail.smtp.message.MailAddress;
025    
026    /**
027     * 
028     * @author Won Chul Doh
029     * @since Jun 24, 2010
030     *
031     */
032    public interface UserManager {
033    
034            /**
035             * Authenticate the given user against the given password. When
036             * authenticated, the ID of the user will be supplied.
037             * 
038             * @param username
039             *            user name
040             * @param password
041             *            password supplied
042             * @return id of the user when authenticated
043             * @throws LoginException
044             *             when the user does not exist or not authenticated
045             */
046            public long login(String username, String password) throws LoginException;
047            
048            public User getUser(long id);
049    
050            public long getUserID(String address);
051            
052            public User getUserByAddress(String address);
053    
054            public int getUserCount(String domain);
055            
056            public List<User> getUserList(String domain, int page, int pageSize);
057            
058            public long addUser(final User user);
059            
060            public int updateUser(final User user);
061            
062            public void deleteUser(final long id);
063            
064            public void emptyUser(final long id);
065            
066            public Alias getAlias(long id);
067            
068            public int getAliasCount(String domain);
069            
070            public List<Alias> getAliasList(String domain, int page, int pageSize);
071            
072            public List<Alias> expandAlias(String alias);
073            
074            public long addAlias(final Alias alias);
075            
076            public int updateAlias(final Alias alias);
077            
078            public void deleteAlias(final long id);
079            
080            public long getQuotaUsage(long ownerID);
081    
082            public Quota getQuota(long ownerID, String quotaRoot);
083    
084            public void setQuota(final long ownerID, final Quota quota);
085            
086            public File getUserHome(MailAddress user);
087    
088    }