]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/CmsUserManager.java
Add Java monitoring config
[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.Map;
6 import java.util.Set;
7
8 import javax.security.auth.Subject;
9
10 import org.argeo.cms.auth.SystemRole;
11 import org.argeo.osgi.useradmin.UserDirectory;
12 import org.argeo.util.directory.HierarchyUnit;
13 import org.osgi.framework.InvalidSyntaxException;
14 import org.osgi.service.useradmin.Group;
15 import org.osgi.service.useradmin.Role;
16 import org.osgi.service.useradmin.User;
17
18 /**
19 * Provide method interfaces to manage user concepts without accessing directly
20 * the userAdmin.
21 */
22 public interface CmsUserManager {
23 Map<String, String> getKnownBaseDns(boolean onlyWritable);
24
25 Set<UserDirectory> getUserDirectories();
26
27 // CurrentUser
28 /** Returns the e-mail of the current logged in user */
29 String getMyMail();
30
31 // Other users
32 /** Returns a {@link User} given a username */
33 User getUser(String username);
34
35 /** Can be a group or a user */
36 String getUserDisplayName(String dn);
37
38 /** Can be a group or a user */
39 String getUserMail(String dn);
40
41 /** Lists all roles of the given user */
42 String[] getUserRoles(String dn);
43
44 /** Checks if the passed user belongs to the passed role */
45 boolean isUserInRole(String userDn, String roleDn);
46
47 // Search
48 /** Returns a filtered list of roles */
49 Role[] getRoles(String filter) throws InvalidSyntaxException;
50
51 /** Recursively lists users in a given group. */
52 Set<User> listUsersInGroup(String groupDn, String filter);
53
54 /** Search among groups including system roles and users if needed */
55 List<User> listGroups(String filter, boolean includeUsers, boolean includeSystemRoles);
56
57 // /**
58 // * Lists functional accounts, that is users with regular access to the system
59 // * under this functional hierarchy unit (which probably have technical direct
60 // * sub hierarchy units), excluding groups which are not explicitly users.
61 // */
62 // Set<User> listAccounts(HierarchyUnit hierarchyUnit, boolean deep);
63
64 /*
65 * EDITION
66 */
67 /** Creates a new user. */
68 User createUser(String username, Map<String, Object> properties, Map<String, Object> credentials);
69
70 /** Creates a group. */
71 Group getOrCreateGroup(HierarchyUnit groups, String commonName);
72
73 /** Creates a new system role. */
74 Group getOrCreateSystemRole(HierarchyUnit roles, SystemRole systemRole);
75
76 /** Add additional object classes to this role. */
77 void addObjectClasses(Role role, Set<String> objectClasses, Map<String, Object> additionalProperties);
78
79 /** Add a member to this group. */
80 void addMember(Group group, Role role);
81
82 /* MISCELLANEOUS */
83 /** Returns the dn of a role given its local ID */
84 String buildDefaultDN(String localId, int type);
85
86 /** Exposes the main default domain name for this instance */
87 String getDefaultDomainName();
88
89 /**
90 * Search for a {@link User} (might also be a group) whose uid or cn is equals
91 * to localId within the various user repositories defined in the current
92 * context.
93 */
94 User getUserFromLocalId(String localId);
95
96 void changeOwnPassword(char[] oldPassword, char[] newPassword);
97
98 void resetPassword(String username, char[] newPassword);
99
100 @Deprecated
101 String addSharedSecret(String username, int hours);
102
103 // String addSharedSecret(String username, String authInfo, String authToken);
104
105 void addAuthToken(String userDn, String token, Integer hours, String... roles);
106
107 void addAuthToken(String userDn, String token, ZonedDateTime expiryDate, String... roles);
108
109 void expireAuthToken(String token);
110
111 void expireAuthTokens(Subject subject);
112
113 UserDirectory getDirectory(Role role);
114
115 /** Create a new hierarchy unit. Does nothing if it already exists. */
116 HierarchyUnit getOrCreateHierarchyUnit(UserDirectory directory, String path);
117 }