001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.security;
018:
019: import java.sql.Date;
020: import java.util.Collection;
021: import java.util.Iterator;
022:
023: /**
024: * <p>
025: * Describes the interface for managing users and provides access to the
026: * {@link User}.
027: * </p>
028: *
029: * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
030: */
031: public interface UserManager {
032: /**
033: * @return the name of the anonymous user
034: */
035: String getAnonymousUser();
036:
037: /**
038: * <p>
039: * Authenticate a user.
040: * </p>
041: *
042: * @param username The user name.
043: * @param password The user password.
044: * @return Whether or not a user is authenticated.
045: */
046: boolean authenticate(String username, String password);
047:
048: /**
049: * <p>
050: * Add a new user provided a username and password.
051: * </p>
052: *
053: * @param username The user name.
054: * @param password The password.
055: * @throws Throws a security exception.
056: */
057: void addUser(String username, String password)
058: throws SecurityException;
059:
060: /**
061: * <p>
062: * Add a new user provided a username and password in the specified authentication
063: * provider store.
064: * </p>
065: *
066: * @param username The user name.
067: * @param password The password.
068: * @param atnProviderName The authentication provider name.
069: * @throws Throws a security exception.
070: */
071: void addUser(String username, String password,
072: String atnProviderName) throws SecurityException;
073:
074: /**
075: * <p>
076: * Import a new user with username and password and allow to bypass the enconding algorithm
077: * </p>
078: *
079: * @param username The user name.
080: * @param password The password.
081: * @param passThrough If true the provided password will not be validated/encoded
082: * @throws Throws a security exception.
083: */
084: void importUser(String username, String password,
085: boolean passThrough) throws SecurityException;
086:
087: /**
088: * <p>
089: * Import a new user with username and password in the specified authentication
090: * provider store and allow to bypass the enconding algorithm
091: * </p>
092: *
093: * @param username The user name.
094: * @param password The password.
095: * @param atnProviderName The authentication provider name.
096: * @param passThrough If true the provided password will not be validated/encoded
097: * @throws Throws a security exception.
098: */
099: void importUser(String username, String password,
100: String atnProviderName, boolean passThrough)
101: throws SecurityException;
102:
103: /**
104: * <p>
105: * Remove a user. If there is a {@link java.util.prefs.Preferences}node for
106: * profile properties associated to this user, it will be removed as well.
107: * </p>
108: * <p>
109: * {@link java.security.Permission}for this user will be removed as well.
110: * </p>
111: *
112: * @param username The user name.
113: * @throws Throws a security exception.
114: */
115: void removeUser(String username) throws SecurityException;
116:
117: /**
118: * <p>
119: * Whether or not a user exists.
120: * </p>
121: *
122: * @param username The user name.
123: * @return Whether or not a user exists.
124: */
125: boolean userExists(String username);
126:
127: /**
128: * <p>
129: * Get a {@link User}for a given username.
130: * </p>
131: *
132: * @param username The username.
133: * @return The {@link User}.
134: * @throws Throws a security exception if the user cannot be found.
135: */
136: User getUser(String username) throws SecurityException;
137:
138: /**
139: * <p>
140: * An iterator of {@link User}finding users matching the corresponding
141: * filter criteria.
142: * </p>
143: * TODO Complete filter implementation.
144: *
145: * @param filter The filter used to retrieve matching users.
146: * @return The Iterator of {@link User}.
147: */
148: Iterator getUsers(String filter) throws SecurityException;
149:
150: /**
151: * <p>
152: * An iterator of user names, finding users matching the corresponding
153: * filter criteria.
154: * </p>
155: * TODO Complete filter implementation.
156: *
157: * @param filter The filter used to retrieve matching users.
158: * @return The Iterator of {@link User}.
159: */
160: Iterator getUserNames(String filter) throws SecurityException;
161:
162: /**
163: * <p>
164: * A collection of {@link User}for all the users in a specific role.
165: * </p>
166: *
167: * @param roleFullPathName The role name full path (e.g.
168: * theRoleName.theRoleNameChild).
169: * @return A Collection of {@link User}.
170: * @throws Throws a security exception if the role does not exist.
171: */
172: Collection getUsersInRole(String roleFullPathName)
173: throws SecurityException;
174:
175: /**
176: * <p>A collection of {@link User} for a specific group.</p>
177: * @param groupFullPathName The group name full path
178: * (e.g. theGroupName.theGroupChildName).
179: * @return A collection of {@link User}.
180: * @throws Throws security exception if the group does not exist.
181: */
182: Collection getUsersInGroup(String groupFullPathName)
183: throws SecurityException;
184:
185: /**
186: * <p>
187: * Set the user password.
188: * </p>
189: *
190: * @param username The user name.
191: * @param oldPassword The old password.
192: * @param newPassword The new password.
193: * @throws Throws a security exception.
194: */
195: void setPassword(String username, String oldPassword,
196: String newPassword) throws SecurityException;
197:
198: /**
199: * <p>
200: * Set the update required state of the user password credential.
201: * </p>
202: *
203: * @param userName The user name.
204: * @param updateRequired The update required state.
205: * @throws Throws a security exception.
206: */
207: void setPasswordUpdateRequired(String userName,
208: boolean updateRequired) throws SecurityException;
209:
210: /**
211: * <p>
212: * Set the enabled state of the user password credential.
213: * </p>
214: *
215: * @param userName The user name.
216: * @param enabled The enabled state.
217: * @throws Throws a security exception.
218: */
219: void setPasswordEnabled(String userName, boolean enabled)
220: throws SecurityException;
221:
222: /**
223: * Enable or disable a user.
224: * @param userName The user name
225: * @param enabled enabled flag for the user
226: */
227: void setUserEnabled(String userName, boolean enabled)
228: throws SecurityException;
229:
230: /**
231: * <p>
232: * Set the expiration date and the expired flag of the password credential.</p>
233: * <p>
234: * If a date equal or before the current date is provided, the expired flag will be set to true,
235: * otherwise to false.</p>
236: *
237: * @param userName The user name.
238: * @param expirationDate The expiration date to set.
239: * @throws Throws a security exception.
240: */
241: void setPasswordExpiration(String userName, Date expirationDate)
242: throws SecurityException;
243: }
|