Gathers and organizes the response based on the specified rootCategory and the permissions of
the specified user.
17348
private Map<String, SortedSet<?>> getRegistryOriginal(WebRequest request, IPerson user) {

        /*
         * This collection of all the portlets in the portal is for the sake of
         * tracking which ones are uncategorized.
         */
        Set<IPortletDefinition> portletsNotYetCategorized =
                new HashSet<>(portletDefinitionRegistry.getAllPortletDefinitions());

        // construct a new channel registry
        Map<String, SortedSet<?>> rslt = new TreeMap<>();
        SortedSet<ChannelCategoryBean> categories = new TreeSet<>();

        // add the root category and all its children to the registry
        final PortletCategory rootCategory = portletCategoryRegistry.getTopLevelPortletCategory();
        final Locale locale = getUserLocale(user);
        categories.add(
                prepareCategoryBean(
                        request, rootCategory, portletsNotYetCategorized, user, locale));

        /*
         * uPortal historically has provided for a convention that portlets not in any category
         * may potentially be viewed by users but may not be subscribed to.
         *
         * As of uPortal 4.2, the logic below now takes any portlets the user has BROWSE access to
         * that have not already been identified as belonging to a category and adds them to a category
         * called Uncategorized.
         */

        EntityIdentifier ei = user.getEntityIdentifier();
        IAuthorizationPrincipal ap =
                AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());

        // construct a new channel category bean for this category
        String uncategorizedString =
                messageSource.getMessage(UNCATEGORIZED, new Object[] {}, locale);
        ChannelCategoryBean uncategorizedPortletsBean =
                new ChannelCategoryBean(new PortletCategory(uncategorizedString));
        uncategorizedPortletsBean.setName(UNCATEGORIZED);
        uncategorizedPortletsBean.setDescription(
                messageSource.getMessage(UNCATEGORIZED_DESC, new Object[] {}, locale));

        for (IPortletDefinition portlet : portletsNotYetCategorized) {
            if (authorizationService.canPrincipalBrowse(ap, portlet)) {
                // construct a new channel bean from this channel
                ChannelBean channel = getChannel(portlet, request, locale);
                uncategorizedPortletsBean.addChannel(channel);
            }
        }
        // Add even if no portlets in category
        categories.add(uncategorizedPortletsBean);

        rslt.put(CATEGORIES_MAP_KEY, categories);
        return rslt;
    }
359317
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_update_topics_to_normal_topics(obj, user)
1075703
public function listAction()
    {
        $roleHierarchy = $this->container->getParameter('security.role_hierarchy.roles');

        $roles = [];
        foreach (array_keys($roleHierarchy) as $role) {
            $roles[] = ['id' => $role, 'name' => $role];
        }

        return new JsonResponse($roles);
    }
858722
@POST
  @Path("/db/{authorizerName}/roles/{roleName}/permissions")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  @ResourceFilters(BasicSecurityResourceFilter.class)
  public Response setRolePermissions(
      @Context HttpServletRequest req,
      @PathParam("authorizerName") final String authorizerName,
      @PathParam("roleName") String roleName,
      List<ResourceAction> permissions
  )
  {
    return resourceHandler.setRolePermissions(authorizerName, roleName, permissions);
  }
1081291
private void checkSuperUser() throws AccessControlException {
    // collects user and groups
    String user = AuthenticatedClientUser.getClientUser(ServerConfiguration.global());
    List<String> groups = getGroups(user);
    if (!isPrivilegedUser(user, groups)) {
      throw new AccessControlException(ExceptionMessage.PERMISSION_DENIED
          .getMessage(user + " is not a super user or in super group"));
    }
  }
380689
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_move_topics(obj, user)
968361
def set(self, permissions):
        
        parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})
        target_url = parent_url + self.client.get_url_path(self._URL_KEY, 'PUT', 'multi')
        r = self.client.request('PUT', target_url, json=permissions)
        if r.status_code != 201:
            raise exceptions.ServerError("Expected 201 response, got %s: %s" % (r.status_code, target_url))
        return self.list()
376072
public function listAction()
    {
        $siterootManager = $this->get('phlexible_siteroot.siteroot_manager');

        $siteroots = [];
        foreach ($siterootManager->findAll() as $siteroot) {
            $siteroots[] = [
                'id' => $siteroot->getId(),
                'title' => $siteroot->getTitle(),
            ];
        }

        return new JsonResponse([
            'siteroots' => $siteroots,
            'count' => count($siteroots),
        ]);
    }
77811
def _load_permissions(self):
        """"""
        result = _P(needs=set(), excludes=set())
        if not self.allow_by_default:
            result.needs.update(self.explicit_needs)

        for explicit_need in self.explicit_needs:
            if explicit_need.method == 'action':
                action = current_access.get_action_cache(
                    self._cache_key(explicit_need)
                )
                if action is None:
                    action = _P(needs=set(), excludes=set())

                    actionsusers = ActionUsers.query_by_action(
                        explicit_need
                    ).all()

                    actionsroles = ActionRoles.query_by_action(
                        explicit_need
                    ).join(
                        ActionRoles.role
                    ).all()

                    actionssystem = ActionSystemRoles.query_by_action(
                        explicit_need
                    ).all()

                    for db_action in chain(
                            actionsusers, actionsroles, actionssystem):
                        if db_action.exclude:
                            action.excludes.add(db_action.need)
                        else:
                            action.needs.add(db_action.need)

                    current_access.set_action_cache(
                        self._cache_key(explicit_need),
                        action
                    )
                # in-place update of results
                result.update(action)
            elif self.allow_by_default:
                result.needs.add(explicit_need)
        self._permissions = result
1351080
def process_response(self, request, response, resource):
        
        origin = request.get_header('Origin')
        if not settings.DEBUG:
            if origin in settings.ALLOWED_ORIGINS or not origin:
                response.set_header('Access-Control-Allow-Origin', origin)
            else:
                log.debug("CORS ERROR: %s not allowed, allowed hosts: %s" % (origin,
                                                                             settings.ALLOWED_ORIGINS))
                raise falcon.HTTPForbidden("Denied", "Origin not in ALLOWED_ORIGINS: %s" % origin)
                # response.status = falcon.HTTP_403
        else:
            response.set_header('Access-Control-Allow-Origin', origin or '*')

        response.set_header('Access-Control-Allow-Credentials', "true")
        response.set_header('Access-Control-Allow-Headers', 'Content-Type')
        # This could be overridden in the resource level
        response.set_header('Access-Control-Allow-Methods', 'OPTIONS')
739286
public static void getPermission(@NonNull Activity context, @NonNull String[] permissions, @NonNull Response response) {
        if (Build.VERSION.SDK_INT < 23) {
            response.permissionGranted();
        } else {

            HashSet<String> permissionSet = new HashSet<>();

            for (String permission : permissions)
                if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
                    permissionSet.add(permission);
                }

            if (permissionSet.size() > 0) {
                int id = 42167;
                while (map.containsKey(id))
                    id = random.nextInt(Short.MAX_VALUE * 2);

                map.put(id, new ResponseWrapper(response, permissions));

                context.requestPermissions(permissionSet.toArray(new String[permissionSet.size()]), id);
            } else {
                response.permissionGranted();
            }
        }
    }
30437
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_delete_topics(obj, user)
416766
public function getListAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        Auth::checkComponentAccess($this, 'list', $tree, $user);
      
        $listController = new ListController(app(IndividualListService::class), app(LocalizationService::class));
        return $listController->individualList($request, $tree, $user, $this);
    }
727984
private void setHeaders(final HttpServletResponse response,
            final Root root) {
        response.setHeader("content-type", "application/octet-stream");
        response.setHeader("content-disposition",
                "attachment; filename=" + getSaveFilename(root));
    }
507086
public function getListAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        Auth::checkComponentAccess($this, 'list', $tree, $user);
      
        $listController = new BranchesController(app(ModuleService::class));
        return $listController->list($request, $tree, $user);
    }
537381
def list_users(root=None):
    '''
    
    '''
    if root is not None:
        getspall = functools.partial(_getspall, root=root)
    else:
        getspall = functools.partial(spwd.getspall)

    return sorted([user.sp_namp if hasattr(user, 'sp_namp') else user.sp_nam
                   for user in getspall()])
1133909
public function index(): JsonResponse
    {
        $config = [
            'title' => trans('HCCore::roles.title.list'),
            'roles' => json_encode($this->service->getRolesWithPermissions()),
            'permissions' => json_encode($this->service->getAllPermissions()),
            'updateUrl' => route('v1.api.users.roles.update_permissions'),
        ];

        return $this->response->success('OK', $config);
    }