53 foreach ($inArray as $elm) {
54 if ($elm->getName() == $name) {
58 throw new AclException(
"$name does not exist in $type ACL");
62 foreach ($inArray as $elm) {
63 if ($elm->getName() == $name) {
71 $this->providers = [];
77 '@ALL' =>
new Role(
'@ALL')
82 $this->permissions = [
85 $this->elementsCache = [];
87 foreach ($this->providers as $prov) {
93 return $this->elementsCache[$name] ??= $this->getElementByName($name, $this->roles,
'roles');
97 return $this->elementsCache[$name] ??= $this->getElementByName($name, $this->resources,
'resources');
101 return $this->elementsCache[$name] ??= $this->getElementByName($name, $this->permissions,
'permissions');
105 foreach ($this->providers as $provider) {
106 $this->acls += $provider->loadAllAcls();
112 foreach ($this->providers as $provider) {
113 $this->roles += $provider->loadAllRoles();
119 foreach ($this->providers as $provider) {
120 $this->resources += $provider->loadAllResources();
122 return $this->resources;
126 foreach ($this->providers as $provider) {
127 $this->permissions+=$provider->loadAllPermissions();
129 return $this->permissions;
133 $this->providers[] = $provider;
157 return $this->resources;
165 return $this->permissions;
173 return $this->providers;
181 $this->providers = $providers;
185 $role = $this->getRoleByName($roleName);
186 $parents = $role->getParentsArray();
188 foreach ($this->acls as $aclElement) {
189 $aclRoleName = $aclElement->getRole()->getName();
190 if ($aclRoleName ===
'@ALL' || $aclRoleName === $roleName) {
191 $aclResourceName = $aclElement->getResource()->getName();
192 if ($aclResourceName ===
'*' || $aclResourceName === $resourceName || \strpos($resourceName, $aclResourceName.
'.')!==
false) {
193 $result[] = $aclElement;
197 foreach ($parents as $parentElm) {
198 $result += $this->getRolePermissionsOn($parentElm, $resourceName);
203 public function isAllowed(
string $roleName,
string $resourceName,
string $permissionName) {
204 $acls = $this->getRolePermissionsOn($roleName, $resourceName);
205 if (\count($acls) > 0) {
206 $permissionLevel = $this->getPermissionByName($permissionName)->getLevel();
207 foreach ($acls as $aclElm) {
208 $level = $aclElm->getPermission()->getLevel();
209 if ($level >= $permissionLevel) {
223 foreach ($this->providers as $prov) {
224 if ($prov instanceof $providerClass) {
237 foreach ($this->acls as $acl) {
238 if ($acl->getId_() === $id_) {
247 foreach ($this->providers as $prov) {
248 $result[] = \get_class($prov);
254 foreach ($this->providers as $prov) {
264 foreach ($this->$part as $elm) {
265 $result[] = $elm->__toString();
Ubiquity\exceptions$AclException This class is part of Ubiquity.
Ubiquity\security\acl\models$AclElement This class is part of Ubiquity.
Ubiquity\security\acl\models$AclList This class is part of Ubiquity.
addProvider(AclProviderInterface $provider)
isAllowed(string $roleName, string $resourceName, string $permissionName)
getPermissionByName(string $name)
elementExistByName(string $name, array $inArray)
getRolePermissionsOn(string $roleName, $resourceName=' *')
getElementByName(string $name, array $inArray, string $type)
getProvider(string $providerClass)
getRoleByName(string $name)
getResourceByName(string $name)
Ubiquity\security\acl\models$Permission This class is part of Ubiquity.
Ubiquity\security\acl\models$Resource This class is part of Ubiquity.
Ubiquity\security\acl\models$Role This class is part of Ubiquity.
Ubiquity\security\acl\persistence$AclCacheProvider This class is part of Ubiquity.
Ubiquity\security\acl\persistence$AclProviderInterface This class is part of Ubiquity.