Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-3046

Disabling profile fields if value is delivered by Shibboleth

    XMLWordPrintable

    Details

      Description

      For a user it's not comprehensible that he can edit profile fields and after the next login his changes has been gone because they are overwritten by Shibboleth. the following patch avoids that by disabling the fields whose values are delivered by Shibboleth:

      diff --git a/src/main/java/org/olat/user/ProfileFormController.java b/src/main/java/org/olat/user/ProfileFormController.java
      --- a/src/main/java/org/olat/user/ProfileFormController.java
      +++ b/src/main/java/org/olat/user/ProfileFormController.java
      @@ -66,6 +66,7 @@
       import org.olat.core.util.xml.XStreamHelper;
       import org.olat.registration.RegistrationManager;
       import org.olat.registration.TemporaryKey;
      +import org.olat.shibboleth.ShibbolethModule;
       import org.olat.user.propertyhandlers.UserPropertyHandler;
       import org.springframework.beans.factory.annotation.Autowired;
       
      @@ -115,6 +116,8 @@
           private HomePageConfigManager hpcm;
           @Autowired
           private DisplayPortraitManager dps;
      +    @Autowired
      +    private ShibbolethModule shibbolethModule;
           
           /**
            * Create this controller with the request's identity as none administrative
      @@ -196,10 +199,14 @@
                   String propertyName = userPropertyHandler.getName();
                   formItems.put(propertyName, formItem);
                   
      +            String attributeName = shibbolethModule.getShibbolethAttributeName(propertyName);
      +            boolean isNotDeliveredByShib = user.getPropertyOrIdentityEnvAttribute(attributeName, getLocale()) == null;
      +
                   if (formItem instanceof TextElement) {
                       // it's a text field, so get the value of this property into the text field
                       TextElement textElement = (TextElement)formItem;
                       textElement.setValue(user.getProperty(propertyName, getLocale()));
      +                textElement.setEnabled(isNotDeliveredByShib);
                   } else if (formItem instanceof MultipleSelectionElement) {
                       // it's a checkbox, so set the box to checked if the corresponding property is set to "true"
                       MultipleSelectionElement checkbox = (MultipleSelectionElement)formItem;
      @@ -210,6 +217,7 @@
                           // assume "false" if the property is not present
                           checkbox.select(propertyName, false);
                       }
      +                checkbox.setEnabled(isNotDeliveredByShib);
                   }
                   
                   // special case for email field
      

        Attachments

          Activity

            People

            • Assignee:
              srosse Stéphane Rossé
              Reporter:
              stephan Stephan Clemenz
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: