/** * Returns the roles of all active and authenticated tokens. * If no authenticated roles could be found the "Everybody" role is returned * * @return array Array of TYPO3\FLOW3\Security\Policy\Role objects */ public function getRoles() { if ($this->initialized === FALSE) { $this->initialize(); } $roles = array(new Role('Everybody')); if ($this->authenticationManager->isAuthenticated() === FALSE) { $roles[] = new Role('Anonymous'); } else { foreach ($this->getAuthenticationTokens() as $token) { if ($token->isAuthenticated()) { $tokenRoles = $token->getRoles(); foreach ($tokenRoles as $currentRole) { if (!in_array($currentRole, $roles)) { $roles[] = $currentRole; } foreach ($this->policyService->getAllParentRoles($currentRole) as $currentParentRole) { if (!in_array($currentParentRole, $roles)) { $roles[] = $currentParentRole; } } } } } $roles = array_intersect($roles, $this->policyService->getRoles()); } return $roles; }