Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

The IUserIdentityStore interface is the mechanism for retrieving the unique identifier for the current user in the portal. There is one implementation of this interfact: RDBMUserIdentityStore. Two properties as well as the value of person attributes for the user affect how this class makes the choice of template.

  • The property autoCreateUsers turns template behavior on or off. As distributed the property is set:
    Code Block
    org.jasig.portal.services.Authentication.autoCreateUsers=true
    When set to true, RDBMUserIdentityStore will automatically create all necessary data for a new portal user based on a template user. If set to false users data will not be automatically created. So far there is no other mechanism for creating user data so this property is always set to true.
  • The template user value is determined either by the property defaultTemplateUserName or by mapping a directory attribute to uPortalTemplateUserName. When a user logs in for the first time, RDBMUserIdentityStore first looks for a person attribute named uPortalTemplateUserName. The value of that attribute is expected to be the username of an existing user. The existing user is then the template for the new user. If no attribute is of that name is mapped the template user name comes from the property org.jasig.portal.services.Authentication.defaultTemplateUserName. In the distribution this is set to the user demo:
    Code Block
    org.jasig.portal.services.Authentication.defaultTemplateUserName=demo
    This means that if you make no changes and map no attribute to uPortalTemplateUserName then all new users will be cloned from the user demo.

Templates and layout managers

...

Source code snippets implementing the described behavior

Code Block
javajava
titleOnly users without their own layouts are updated
java
 boolean hasSavedLayout = userHasSavedLayout(portalUser.getUserId());
 if (!hasSavedLayout) {
                       
     TemplateUser templateUser = getTemplateUser(templateName);                       
     if (portalUser.getDefaultUserId() != templateUser.getUserId()) {
            //Update user data with new template user's data
            updateUser(portalUser.getUserId(), person, templateUser);
         }
     }
java
Code Block
java
titleChanging template affiliation changes group memberships
java
 protected void updateUser(int userId, IPerson person, TemplateUser templateUser) throws Exception {
      // Remove my existing group memberships
      IGroupMember me = GroupService.getGroupMember(person.getEntityIdentifier()); 
      Iterator myExistingGroups = me.getContainingGroups();
      while (myExistingGroups.hasNext()) {
          IEntityGroup eg = (IEntityGroup)myExistingGroups.next();
          ILockableEntityGroup leg = GroupService.findLockableGroup(eg.getKey(), me.getKey());
          removePersonFromGroup(person, me, leg);
      }
      
      // Copy template user's groups memberships
      IGroupMember template = GroupService.getEntity(templateUser.getUserName(), Class.forName("org.jasig.portal.security.IPerson"));
      Iterator templateGroups = template.getContainingGroups();
      while (templateGroups.hasNext()) {
          IEntityGroup eg = (IEntityGroup)templateGroups.next();
          ILockableEntityGroup leg = GroupService.findLockableGroup(eg.getKey(), me.getKey());
          addPersonToGroup(person, me, leg);     
      }