Clarify implementation base APIs.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / CmsUserManager.java
index c51d21caa30505129f01476db05647ffb02d0586..f87d28b1c3a8729c1b84ca2dbbe75be07cc40ea7 100644 (file)
@@ -6,8 +6,12 @@ import java.util.Map;
 import java.util.Set;
 
 import javax.security.auth.Subject;
+import javax.xml.namespace.QName;
 
-import org.argeo.osgi.useradmin.UserDirectory;
+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.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.useradmin.Role;
 import org.osgi.service.useradmin.User;
@@ -17,52 +21,84 @@ import org.osgi.service.useradmin.User;
  * the userAdmin.
  */
 public interface CmsUserManager {
-       public Map<String, String> getKnownBaseDns(boolean onlyWritable);
-       public Set<UserDirectory> getUserDirectories();
-       
+       Map<String, String> getKnownBaseDns(boolean onlyWritable);
+
+       Set<UserDirectory> getUserDirectories();
+
        // CurrentUser
        /** Returns the e-mail of the current logged in user */
-       public String getMyMail();
+       String getMyMail();
 
        // Other users
        /** Returns a {@link User} given a username */
-       public User getUser(String username);
+       CmsUser getUser(String username);
 
        /** Can be a group or a user */
-       public String getUserDisplayName(String dn);
+       String getUserDisplayName(String dn);
 
        /** Can be a group or a user */
-       public String getUserMail(String dn);
+       String getUserMail(String dn);
 
        /** Lists all roles of the given user */
-       public String[] getUserRoles(String dn);
+       String[] getUserRoles(String dn);
 
        /** Checks if the passed user belongs to the passed role */
-       public boolean isUserInRole(String userDn, String roleDn);
+       boolean isUserInRole(String userDn, String roleDn);
 
        // Search
        /** Returns a filtered list of roles */
-       public Role[] getRoles(String filter) throws InvalidSyntaxException;
+       Role[] getRoles(String filter) throws InvalidSyntaxException;
 
        /** Recursively lists users in a given group. */
-       public Set<User> listUsersInGroup(String groupDn, String filter);
+       Set<CmsUser> listUsersInGroup(String groupDn, String filter);
 
        /** Search among groups including system roles and users if needed */
-       public 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. */
+       CmsUser createUser(String username, Map<String, Object> properties, Map<String, Object> credentials);
+
+       /** Creates a group. */
+       CmsGroup getOrCreateGroup(HierarchyUnit groups, String commonName);
+
+       /** Creates a new system role. */
+       CmsGroup getOrCreateSystemRole(HierarchyUnit roles, QName 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(CmsGroup group, Role role);
+
+       void edit(Runnable action);
 
        /* MISCELLANEOUS */
        /** Returns the dn of a role given its local ID */
-       public String buildDefaultDN(String localId, int type);
+       String buildDefaultDN(String localId, int type);
 
        /** Exposes the main default domain name for this instance */
-       public String getDefaultDomainName();
+       String getDefaultDomainName();
 
        /**
         * Search for a {@link User} (might also be a group) whose uid or cn is equals
         * to localId within the various user repositories defined in the current
         * context.
         */
-       public User getUserFromLocalId(String localId);
+       CmsUser getUserFromLocalId(String localId);
 
        void changeOwnPassword(char[] oldPassword, char[] newPassword);
 
@@ -81,11 +117,8 @@ public interface CmsUserManager {
 
        void expireAuthTokens(Subject subject);
 
-//     User createUserFromPerson(Node person);
+       UserDirectory getDirectory(Role role);
 
-//     @Deprecated
-//     public UserAdmin getUserAdmin();
-//
-//     @Deprecated
-//     public UserTransaction getUserTransaction();
+       /** Create a new hierarchy unit. Does nothing if it already exists. */
+       HierarchyUnit getOrCreateHierarchyUnit(UserDirectory directory, String path);
 }
\ No newline at end of file