]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/CmsUserManager.java
d970855ff5066316857c38b101c52f4d43767e2d
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / CmsUserManager.java
1 package org.argeo.cms;
2
3 import java.time.ZonedDateTime;
4 import java.util.List;
5 import java.util.Set;
6
7 import javax.security.auth.Subject;
8 import javax.transaction.UserTransaction;
9
10 import org.osgi.framework.InvalidSyntaxException;
11 import org.osgi.service.useradmin.Role;
12 import org.osgi.service.useradmin.User;
13 import org.osgi.service.useradmin.UserAdmin;
14
15 /**
16 * Provide method interfaces to manage user concepts without accessing directly
17 * the userAdmin.
18 */
19 public interface CmsUserManager {
20
21 // CurrentUser
22 /** Returns the e-mail of the current logged in user */
23 public String getMyMail();
24
25 // Other users
26 /** Returns a {@link User} given a username */
27 public User getUser(String username);
28
29 /** Can be a group or a user */
30 public String getUserDisplayName(String dn);
31
32 /** Can be a group or a user */
33 public String getUserMail(String dn);
34
35 /** Lists all roles of the given user */
36 public String[] getUserRoles(String dn);
37
38 /** Checks if the passed user belongs to the passed role */
39 public boolean isUserInRole(String userDn, String roleDn);
40
41 // Search
42 /** Returns a filtered list of roles */
43 public Role[] getRoles(String filter) throws InvalidSyntaxException;
44
45 /** Recursively lists users in a given group. */
46 public Set<User> listUsersInGroup(String groupDn, String filter);
47
48 /** Search among groups including system roles and users if needed */
49 public List<User> listGroups(String filter, boolean includeUsers, boolean includeSystemRoles);
50
51 /* MISCELLANEOUS */
52 /** Returns the dn of a role given its local ID */
53 public String buildDefaultDN(String localId, int type);
54
55 /** Exposes the main default domain name for this instance */
56 public String getDefaultDomainName();
57
58 /**
59 * Search for a {@link User} (might also be a group) whose uid or cn is equals
60 * to localId within the various user repositories defined in the current
61 * context.
62 */
63 public User getUserFromLocalId(String localId);
64
65 void changeOwnPassword(char[] oldPassword, char[] newPassword);
66
67 void resetPassword(String username, char[] newPassword);
68
69 @Deprecated
70 String addSharedSecret(String username, int hours);
71
72 // String addSharedSecret(String username, String authInfo, String authToken);
73
74 void addAuthToken(String userDn, String token, Integer hours, String... roles);
75
76 void addAuthToken(String userDn, String token, ZonedDateTime expiryDate, String... roles);
77
78 void expireAuthToken(String token);
79
80 void expireAuthTokens(Subject subject);
81
82 // User createUserFromPerson(Node person);
83
84 @Deprecated
85 public UserAdmin getUserAdmin();
86
87 @Deprecated
88 public UserTransaction getUserTransaction();
89 }