• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • Last Change
  • Annotate
  • Revision Log

root/trunk/components/common/src/ome/api/IAdmin.java

Revision 2856, 16.7 kB (checked in by ola, 3 months ago)

#1104

  • Property svn:keywords set to
    Date
    Revision
    Id
    URL
Line 
1/*
2 * ome.api.IAdmin
3 *
4 *   Copyright 2006 University of Dundee. All rights reserved.
5 *   Use is subject to license terms supplied in LICENSE.txt
6 */
7
8package ome.api;
9
10// Java imports
11
12// Third-party libraries
13
14// Application-internal dependencies
15import java.util.List;
16import java.util.Map;
17
18import ome.annotations.Hidden;
19import ome.annotations.NotNull;
20import ome.conditions.AuthenticationException;
21import ome.model.IObject;
22import ome.model.internal.Permissions;
23import ome.model.internal.Permissions.Flag;
24import ome.model.meta.Experimenter;
25import ome.model.meta.ExperimenterGroup;
26import ome.system.EventContext;
27import ome.system.Roles;
28
29/**
30 * Administration interface providing access to admin-only functionality as well
31 * as JMX-based server access and selected user functions. Most methods require
32 * membership in privileged {@link ExperimenterGroup groups}.
33 *
34 * Methods which return {@link ome.model.meta.Experimenter} or
35 * {@link ome.model.meta.ExperimenterGroup} instances fetch and load all related
36 * instances of {@link ome.model.meta.ExperimenterGroup} or
37 * {@link ome.model.meta.Experimenter}, respectively.
38 *
39 * @author <br>
40 *         Josh Moore &nbsp;&nbsp;&nbsp;&nbsp; <a
41 *         href="mailto:josh.moore@gmx.de"> josh.moore@gmx.de</a>
42 * @version 3.0 <small> (<b>Internal version:</b> $Revision$ $Date$) </small>
43 * @since OME3.0
44 */
45public interface IAdmin extends ServiceInterface {
46
47    // ~ Getting users and groups
48    // =========================================================================
49
50    /**
51     * fetch an {@link Experimenter} and all related
52     * {@link ExperimenterGroup groups}.
53     *
54     * @param id
55     *            id of the Experimenter
56     * @return an Experimenter. Never null.
57     * @throws ome.conditions.ApiUsageException
58     *             if id does not exist.
59     */
60    Experimenter getExperimenter(long id);
61
62    /**
63     * look up an {@link Experimenter} and all related
64     * {@link ExperimenterGroup groups} by name.
65     *
66     * @param omeName
67     *            Name of the Experimenter
68     * @return an Experimenter. Never null.
69     * @throws ome.conditions.ApiUsageException
70     *             if omeName does not exist.
71     */
72    Experimenter lookupExperimenter(@NotNull
73    String omeName);
74
75    /**
76     * Looks up all {@link Experimenter experimenters} present and all related
77     * {@link ExperimenterGroup groups}.
78     *
79     * @return all Experimenters. Never null.
80     */
81    List<Experimenter> lookupExperimenters();
82
83    /**
84     * Looks up all id of {@link Experimenter experimenters} who uses LDAP
85     * authentication (has set dn on password table).
86     *
87     * @return list of Experimenters. Never null.
88     */
89    List<Map<String, Object>> lookupLdapAuthExperimenters();
90
91    /**
92     * Looks up {@link Experimenter experimenters} who uses LDAP authentication
93     * (has set dn on password table).
94     *
95     * @return Experimenter. Never null.
96     */
97    String lookupLdapAuthExperimenter(long id);
98
99    /**
100     * fetch an {@link ExperimenterGroup} and all contained
101     * {@link Experimenter users}.
102     *
103     * @param id
104     *            id of the ExperimenterGroup
105     * @return an ExperimenterGroup. Never null.
106     * @throws ome.conditions.ApiUsageException
107     *             if id does not exist.
108     */
109    ExperimenterGroup getGroup(long id);
110
111    /**
112     * look up an {@link ExperimenterGroup} and all contained
113     * {@link Experimenter users} by name.
114     *
115     * @param groupName
116     *            Name of the ExperimenterGroup
117     * @return an ExperimenterGroup. Never null.
118     * @throws ome.conditions.ApiUsageException
119     *             if groupName does not exist.
120     */
121    ExperimenterGroup lookupGroup(@NotNull
122    String groupName);
123
124    /**
125     * Looks up all {@link ExperimenterGroups groups} present and all related
126     * {@link Experimenter experimenters}. The experimenters' groups are also
127     * loaded.
128     *
129     * @return all Groups. Never null.
130     */
131    List<ExperimenterGroup> lookupGroups();
132
133    /**
134     * fetch all {@link Experimenter users} contained in this group. The
135     * returned users will have all fields filled in and all collections
136     * unloaded.
137     *
138     * @param groupId
139     *            id of the ExperimenterGroup
140     * @return non-null array of all {@link Experimenter users} in this group.
141     */
142    Experimenter[] containedExperimenters(long groupId);
143
144    /**
145     * fetch all {@link ExperimenterGroup groups} of which the given user is a
146     * member. The returned groups will have all fields filled in and all
147     * collections unloaded.
148     *
149     * @param experimenterId
150     *            id of the Experimenter. Not null.
151     * @return non-null array of all {@link ExperimenterGroup groups} for this
152     *         user.
153     */
154    ExperimenterGroup[] containedGroups(long experimenterId);
155
156    /**
157     * retrieve the default {@link ExperimenterGroup group} for the given user
158     * id.
159     *
160     * @param experimenterId
161     *            of the Experimenter. Not null.
162     * @return non-null {@link ExperimenterGroup}. If no default group is
163     *         found, an exception will be thrown.
164     */
165    ExperimenterGroup getDefaultGroup(long experimenterId);
166
167    // ~ Updating users and groups
168    // =========================================================================
169
170    /**
171     * Allows a user to update his/her own information. This is limited to the
172     * fields on Experimenter, all other fields (groups, etc.) are ignored. The
173     * experimenter argument need not have the proper id nor the proper omeName
174     * (which is immutable). To change the users default group (which is the
175     * only other customizable option), use
176     * {@link #setDefaultGroup(Experimenter, ExperimenterGroup)}
177     *
178     * @see #setDefaultGroup(Experimenter, ExperimenterGroup)
179     * @param experimenter
180     *            A data transfer object. Only the fields: firstName,
181     *            middleName, lastName, email, and institution are checked. Not
182     *            null.
183     */
184    void updateSelf(@NotNull
185    Experimenter experimenter);
186
187    /**
188     * Updates an experimenter as admin. All aspects of the passed object are
189     * taken into account including omeName, groups, and default group.
190     *
191     * @param experimenter
192     *            the Experimenter to update.
193     */
194    void updateExperimenter(@NotNull
195    Experimenter experimenter);
196
197    /**
198     * Updates an experimenter as admin. All aspects of the passed object are
199     * taken into account including omeName, groups, and default group.
200     *
201     * @param experimenter
202     *            the Experimenter to update.
203     * @param password
204     *            Not-null. Must pass validation in the security sub-system.           
205     */
206    void updateExperimenterWithPassword(@NotNull
207    Experimenter experimenter, @Hidden
208    String password);
209   
210    /**
211     * Updates a group. All aspects of the passed object are taken into account
212     * including group name and the included users.
213     *
214     * @param group
215     *            the ExperimenterGroup to update.
216     */
217    void updateGroup(@NotNull
218    ExperimenterGroup group);
219
220    // ~ Creating users in groups
221    // =========================================================================
222
223    /**
224     * create and return a new user. This user will be created with the default
225     * group specified.
226     *
227     * @param newUser
228     *            a new {@link Experimenter} instance
229     * @parm group group name of the default group for this user
230     * @return id of the newly created {@link Experimenter}
231     */
232    long createUser(@NotNull
233    Experimenter newUser, @NotNull
234    String group);
235
236    /**
237     * create and return a new system user. This user will be created with the
238     * "System" (administration) group as default and will also be in the "user"
239     * group.
240     *
241     * @param newUser
242     *            a new {@link Experimenter} instance
243     * @return id of the newly created {@link Experimenter}
244     */
245    long createSystemUser(@NotNull
246    Experimenter newSystemUser);
247
248    /**
249     * create and return a new user in the given groups.
250     *
251     * @param experimenter
252     *            A new {@link Experimenter} instance. Not null.
253     * @param defaultGroup
254     *            Instance of {@link ExperimenterGroup}. Not null.
255     * @param otherGroups
256     *            Array of {@link ExperimenterGroup} instances. Can be null.
257     * @return id of the newly created {@link Experimenter} Not null.
258     */
259    long createExperimenter(@NotNull
260    Experimenter experimenter, @NotNull
261    ExperimenterGroup defaultGroup, ExperimenterGroup... otherGroups);
262
263    /**
264     * create and return a new user in the given groups with password.
265     *
266     * @param experimenter
267     *            A new {@link Experimenter} instance. Not null.
268     * @param password
269     *            Not-null. Must pass validation in the security sub-system.
270     * @param defaultGroup
271     *            Instance of {@link ExperimenterGroup}. Not null.
272     * @param otherGroups
273     *            Array of {@link ExperimenterGroup} instances. Can be null.
274     * @return id of the newly created {@link Experimenter} Not null.
275     * @throws ome.conditions.SecurityViolation
276     *             if the new password is too weak.
277     */
278    long createExperimenterWithPassword(@NotNull
279    Experimenter experimenter, @Hidden
280    String password, @NotNull
281    ExperimenterGroup defaultGroup, ExperimenterGroup... otherGroups);   
282   
283    /**
284     * create and return a new group.
285     *
286     * @param newGroup
287     *            a new {@link ExperimenterGroup} instance. Not null.
288     * @return id of the newly created {@link ExperimenterGroup}
289     */
290    long createGroup(ExperimenterGroup group);
291
292    /**
293     * adds a user to the given groups.
294     *
295     * @param user
296     *            A currently managed entity. Not null.
297     * @param groups
298     *            Groups to which the user will be added. Not null.
299     */
300    void addGroups(@NotNull
301    Experimenter user, @NotNull
302    ExperimenterGroup... groups);
303
304    /**
305     * removes a user from the given groups.
306     *
307     * @param user
308     *            A currently managed entity. Not null.
309     * @param groups
310     *            Groups from which the user will be removed. Not null.
311     */
312    void removeGroups(@NotNull
313    Experimenter user, @NotNull
314    ExperimenterGroup... groups);
315
316    /**
317     * sets the default group for a given user.
318     *
319     * @param user
320     *            A currently managed {@link Experimenter}. Not null.
321     * @param group
322     *            The group which should be set as default group for this user.
323     *            Not null.
324     */
325    void setDefaultGroup(@NotNull
326    Experimenter user, @NotNull
327    ExperimenterGroup group);
328
329    /**
330     * sets the owner of a group to be a given user.
331     *
332     * @param group
333     *            A currently managed {@link ExperimenterGroup}. Not null.
334     * @param owner
335     *            A currently managed {@link Experimenter}. Not null.
336     */
337    void setGroupOwner(@NotNull
338    ExperimenterGroup group, @NotNull
339    Experimenter owner);
340
341    /**
342     * removes a user by removing the password information for that user as well
343     * as all {@link GroupExperimenterMap} instances.
344     *
345     * @param user
346     *            Experimenter to be deleted. Not null.
347     */
348    void deleteExperimenter(@NotNull
349    Experimenter user);
350
351    /**
352     * removes a group by first removing all users in the group, and then
353     * deleting the actual {@link ExperimenterGroup} instance.
354     *
355     * @param group
356     *            {@link ExperimenterGroup} to be deleted. Not null.
357     */
358    void deleteGroup(@NotNull
359    ExperimenterGroup group);
360
361    // ~ Permissions and Ownership
362    // =========================================================================
363
364    /**
365     * call
366     * {@link ome.model.internal.Details#setOwner(Experimenter) details.setOwner()}
367     * on this instance. It is valid for the instance to be
368     * {@link IObject#unload() unloaded} (or constructed with an
369     * unloading-constructor.)
370     *
371     * @param iObject
372     *            An entity or an unloaded reference to an entity. Not null.
373     * @param omeName
374     *            The user name who should gain ownership of this entity. Not
375     *            null.
376     */
377    void changeOwner(@NotNull
378    IObject iObject, @NotNull
379    String omeName);
380
381    /**
382     * call
383     * {@link ome.model.internal.Details#setGroup(ExperimenterGroup) details.setGroup()}
384     * on this instance. It is valid for the instance to be
385     * {@link IObject#unload() unloaded} (or constructed with an
386     * unloading-constructor.)
387     *
388     * @param iObject
389     *            An entity or an unloaded reference to an entity. Not null.
390     * @param groupName
391     *            The group name who should gain ownership of this entity. Not
392     *            null.
393     */
394    void changeGroup(@NotNull
395    IObject iObject, @NotNull
396    String groupName);
397
398    /**
399     * call
400     * {@link ome.model.internal.Details#setPermissions(Permissions) defaults.setPermissions()}
401     * on this instance. It is valid for the instance to be
402     * {@link IObject#unload() unloaded} (or constructed with an
403     * unloading-constructor.)
404     *
405     * @param iObject
406     *            An entity or an unloaded reference to an entity. Not null.
407     * @param perms
408     *            The permissions value for this entity. Not null.
409     */
410    void changePermissions(@NotNull
411    IObject iObject, @NotNull
412    Permissions perms);
413
414    /**
415     * checks an entity for any in-bound references and if none are present,
416     * will remove the {@link Flag#LOCKED} status. This method is backend-
417     * intensive and should not be used in a tight loop. Returns an array with
418     * length equal to the number of instances passed in. A true value means
419     * that the object is now unlocked.
420     *
421     * @param iObjects
422     *            a variable array argument of objects to be unlocked
423     * @return an array of equal length to iObjects where a true value asserts
424     *         that the instance is now unlocked in the database.
425     */
426    boolean[] unlock(IObject... iObjects);
427
428    // ~ Authentication and Authorization
429    // =========================================================================
430
431    /**
432     * Can be used after repeated {@link AuthenticationException} instances are
433     * thrown, to request that an email with a temporary password be sent. The
434     * given email must match the email for the user listed under the name
435     * argument.
436     *
437     * Does not require a session to be active.
438     *
439     * @param name
440     * @param email
441     * @throws AuthenticationException
442     *             when name and email do not match
443     */
444    void reportForgottenPassword(String name, String email)
445            throws AuthenticationException;
446
447    /**
448     * Used after an {@link ExpiredCredentialsException} instance is thrown.
449     *
450     * Does not require
451     */
452    void changeExpiredCredentials(String name, String oldCred, String newCred)
453            throws AuthenticationException;
454
455    /**
456     * change the password for the current user
457     *
458     * @param newPassword
459     *            Not-null. Must pass validation in the security sub-system.
460     * @throws ome.conditions.SecurityViolation
461     *             if the new password is too weak.
462     */
463    void changePassword(@Hidden
464    String newPassword);
465
466    /**
467     * change the password for the a given user.
468     *
469     * @param newPassword
470     *            Not-null. Might must pass validation in the security
471     *            sub-system.
472     * @throws ome.conditions.SecurityViolation
473     *             if the new password is too weak.
474     */
475    void changeUserPassword(@NotNull
476    String omeName, @Hidden
477    String newPassword);
478
479    /**
480     * uses JMX to refresh the login cache <em>if supported</em>. Some
481     * backends may not provide refreshing. This may be called internally during
482     * some other administrative tasks. The exact implementation of this depends
483     * on the application server and the authentication/authorization backend.
484     */
485    void synchronizeLoginCache();
486
487    // ~ Security context
488    // =========================================================================
489
490    /**
491     * returns the active {@link Roles} in use by the server.
492     *
493     * @return Non-null, immutable {@link Roles} instance.
494     */
495    Roles getSecurityRoles();
496
497    /**
498     * returns an implementation of {@link EventContext} loaded with the
499     * security for the current user and thread. If called remotely, not all
500     * values of {@link EventContext} will be sensible.
501     *
502     * @return Non-null, immutable {@link EventContext} instance
503     */
504    EventContext getEventContext();
505}
Note: See TracBrowser for help on using the browser.

Download in other formats:

  • Plain Text
  • Original Format

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/