code: private void addPrincipalPermissionsToForm(IPortletDefinition def, PortletDefinitionForm form) {
          final String portletTargetId = PermissionHelper.permissionTargetIdForPortletDefinition(def);
  
          final Set<JsonEntityBean> principalBeans = new HashSet<>();
          Map<String, IPermissionManager> permManagers = new HashMap<>();
          for (PortletPermissionsOnForm perm : PortletPermissionsOnForm.values()) {
              if (!permManagers.containsKey(perm.getOwner())) {
                  permManagers.put(
                          perm.getOwner(),
                          authorizationService.newPermissionManager(perm.getOwner()));
              }
              final IPermissionManager pm = permManagers.get(perm.getOwner());
              /* Obtain the principals that have permission for the activity on this portlet */
              final IAuthorizationPrincipal[] principals =
                      pm.getAuthorizedPrincipals(perm.getActivity(), portletTargetId);
  
              for (IAuthorizationPrincipal principal : principals) {
                  JsonEntityBean principalBean;
  
                  // first assume this is a group
                  final IEntityGroup group = GroupService.findGroup(principal.getKey());
                  if (group != null) {
                      // principal is a group
                      principalBean = new JsonEntityBean(group, EntityEnum.GROUP);
                  } else {
                      // not a group, so it must be a person
                      final IGroupMember member = authorizationService.getGroupMember(principal);
                      principalBean = new JsonEntityBean(member, EntityEnum.PERSON);
                      // set the name
                      final String name = groupListHelper.lookupEntityName(principalBean);
                      principalBean.setName(name);
                  }
  
                  principalBeans.add(principalBean);
  
                  form.addPermission(principalBean.getTypeAndIdHash() + "_" + perm.getActivity());
              }
          }
          form.setPrincipals(principalBeans, false);
      }
docs: /*
  Add to the form SUBSCRIBE, BROWSE, and CONFIGURE activity permissions, along with their principals,
  assigned to the portlet.