1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package net.sf.hermesftp.usermanager;
26
27 import java.util.List;
28 import java.util.Map;
29
30 import net.sf.hermesftp.common.FtpSessionContext;
31 import net.sf.hermesftp.exception.FtpConfigException;
32 import net.sf.hermesftp.exception.FtpQuotaException;
33 import net.sf.hermesftp.usermanager.model.GroupDataList;
34 import net.sf.hermesftp.usermanager.model.UserData;
35
36 /***
37 * Generic description of user management classes.
38 *
39 * @author Lars Behnke
40 */
41 public interface UserManager {
42
43 /***
44 * Registers the current user's resource consumption. That is, downloaded or uploaded bytes or
45 * files.
46 *
47 * @param user The user name.
48 * @param limitName The name of the consumption type (resource limit).
49 * @param value The consumed resources.
50 * @throws FtpQuotaException Thrown if resource limit has been reached.
51 */
52 void updateIncrementalStatistics(String user, String limitName, long value) throws FtpQuotaException;
53
54 /***
55 * Registers the current user's transfer rate. A mean value is calculated.
56 *
57 * @param user The user name.
58 * @param avgKeyName The key of the transfer rate (resource limit).
59 * @param value The consumed resources.
60 */
61 void updateAverageStatistics(String user, String avgKeyName, long value);
62
63 /***
64 * Checks the resource consumption of the passed users. Only the passed limits are condidered.
65 *
66 * @param user The user name.
67 * @param limitNames The resource limits to condider.
68 * @throws FtpQuotaException Thrown if at least one limit has been reached.
69 */
70 void checkResourceConsumption(String user, String[] limitNames) throws FtpQuotaException;
71
72 /***
73 * Returns the resource consumption statistics for a given user.
74 *
75 * @param user The user.
76 * @return The statistics.
77 */
78 Map<String, Long> getUserStatistics(String user);
79
80 /***
81 * Returns the logged statistics for all user and all available dates (since the server was
82 * started).
83 *
84 * @return The statistics.
85 */
86 Map<String, Map<String, Long>> getAllStatistics();
87
88 /***
89 * Returns object representations of all registered users.
90 *
91 * @param username The user's name.
92 * @return The user data.
93 * @throws FtpConfigException Error in configuration.
94 */
95 UserData getUserData(String username) throws FtpConfigException;
96
97 /***
98 * Returns object representations of all registered users.
99 *
100 * @return The users.
101 * @throws FtpConfigException Error in configuration.
102 */
103 List<UserData> getUserDataList() throws FtpConfigException;
104
105 /***
106 * Returns object representations of all groups the passed user belongs to.
107 *
108 * @param username The user's name.
109 * @return The group data.
110 * @throws FtpConfigException Error in configuration.
111 */
112 GroupDataList getGroupDataList(String username) throws FtpConfigException;
113
114 /***
115 * Validates the passed user credentials.
116 *
117 * @param user The username.
118 * @param password The password
119 * @param ctx The context of the current session.
120 * @return True, if credentials are valid.
121 * @throws FtpConfigException Error on reading or processing a configuration file.
122 */
123 boolean authenticate(String user, String password, FtpSessionContext ctx) throws FtpConfigException;
124
125 /***
126 * (Re)loads the configuration.
127 *
128 * @throws FtpConfigException Error on reading or processing a configuration file.
129 */
130 void load() throws FtpConfigException;
131
132 /***
133 * Checks if the configuration is loaded.
134 *
135 * @return True, if configuration has already been loaded.
136 * @throws FtpConfigException Error on reading or processing a configuration file.
137 */
138 boolean isLoaded() throws FtpConfigException;
139
140 }