Introduce CMS-specific user APIs, based at this stage on OSGi UserAdmin
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / CmsUserManager.java
index 4017c7ebf3b56a18f8bffca4ec0888cb9ffa9734..2d64d9db02e2a6d4fdc06adc132894d2964098b2 100644 (file)
@@ -7,11 +7,12 @@ import java.util.Set;
 
 import javax.security.auth.Subject;
 
+import org.argeo.api.cms.directory.CmsGroup;
+import org.argeo.api.cms.directory.CmsUser;
+import org.argeo.api.cms.directory.HierarchyUnit;
+import org.argeo.api.cms.directory.UserDirectory;
 import org.argeo.cms.auth.SystemRole;
-import org.argeo.osgi.useradmin.UserDirectory;
-import org.argeo.util.directory.HierarchyUnit;
 import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.service.useradmin.Group;
 import org.osgi.service.useradmin.Role;
 import org.osgi.service.useradmin.User;
 
@@ -30,7 +31,7 @@ public interface CmsUserManager {
 
        // Other users
        /** Returns a {@link User} given a username */
-       User getUser(String username);
+       CmsUser getUser(String username);
 
        /** Can be a group or a user */
        String getUserDisplayName(String dn);
@@ -49,28 +50,41 @@ public interface CmsUserManager {
        Role[] getRoles(String filter) throws InvalidSyntaxException;
 
        /** Recursively lists users in a given group. */
-       Set<User> listUsersInGroup(String groupDn, String filter);
+       Set<CmsUser> listUsersInGroup(String groupDn, String filter);
 
        /** Search among groups including system roles and users if needed */
-       List<User> listGroups(String filter, boolean includeUsers, boolean includeSystemRoles);
+       List<CmsUser> listGroups(String filter, boolean includeUsers, boolean includeSystemRoles);
+
+//     /**
+//      * Lists functional accounts, that is users with regular access to the system
+//      * under this functional hierarchy unit (which probably have technical direct
+//      * sub hierarchy units), excluding groups which are not explicitly users.
+//      */
+//     Set<User> listAccounts(HierarchyUnit hierarchyUnit, boolean deep);
 
        /*
         * EDITION
         */
        /** Creates a new user. */
-       User createUser(String username, Map<String, Object> properties, Map<String, Object> credentials);
+       CmsUser createUser(String username, Map<String, Object> properties, Map<String, Object> credentials);
 
        /** Creates a group. */
-       Group getOrCreateGroup(HierarchyUnit groups, String commonName);
+       CmsGroup getOrCreateGroup(HierarchyUnit groups, String commonName);
 
        /** Creates a new system role. */
-       Group getOrCreateSystemRole(HierarchyUnit roles, SystemRole systemRole);
+       CmsGroup getOrCreateSystemRole(HierarchyUnit roles, SystemRole systemRole);
 
        /** Add additional object classes to this role. */
        void addObjectClasses(Role role, Set<String> objectClasses, Map<String, Object> additionalProperties);
 
+       /** Add additional object classes to this hierarchy unit. */
+       void addObjectClasses(HierarchyUnit hierarchyUnit, Set<String> objectClasses,
+                       Map<String, Object> additionalProperties);
+
        /** Add a member to this group. */
-       void addMember(Group group, Role role);
+       void addMember(CmsGroup group, Role role);
+
+       void edit(Runnable action);
 
        /* MISCELLANEOUS */
        /** Returns the dn of a role given its local ID */
@@ -84,7 +98,7 @@ public interface CmsUserManager {
         * to localId within the various user repositories defined in the current
         * context.
         */
-       User getUserFromLocalId(String localId);
+       CmsUser getUserFromLocalId(String localId);
 
        void changeOwnPassword(char[] oldPassword, char[] newPassword);