Get ContentKeyAuthorizationPolicy linked Options.

@param ContentKeyAuthorizationPolicy|string $policy ContentKeyAuthorizationPolicy data or
ContentKeyAuthorizationPolicy Id

@return ContentKeyAuthorizationPolicyOption[]
192286
public function getContentKeyAuthorizationPolicyLinkedOptions($policy)
    {
        $policyId = Utilities::getEntityId(
            $policy,
            'WindowsAzure\MediaServices\Models\ContentKeyAuthorizationPolicy'
        );

        $propertyList = $this->_getEntityList("ContentKeyAuthorizationPolicies('{$policyId}')/Options");
        $result = [];

        foreach ($propertyList as $properties) {
            $result[] = ContentKeyAuthorizationPolicyOption::createFromOptions($properties);
        }

        return $result;
    }
80142
public function loadPoliciesByUserId($userId)
    {
        $data = $this->roleGateway->loadPoliciesByUserId($userId);

        $policies = $this->mapper->mapPolicies($data);

        foreach ($policies as $policy) {
            $this->limitationConverter->toSPI($policy);
        }

        return $policies;
    }
1014646
protected function getAclPermissions($object)
    {
        $roles = [];

        try {
            $objectIdentity = ObjectIdentity::fromDomainObject($object);

            /* @var AclInterface $acl */
            $acl = $this->aclProvider->findAcl($objectIdentity);
            $objectAces = $acl->getObjectAces();

            /* @var AuditableEntryInterface $ace */
            foreach ($objectAces as $ace) {
                $securityIdentity = $ace->getSecurityIdentity();
                if (
                    $securityIdentity instanceof RoleSecurityIdentity &&
                    ($ace->getMask() & MaskBuilder::MASK_VIEW != 0)
                ) {
                    $roles[] = $securityIdentity->getRole();
                }
            }
        } catch (AclNotFoundException $e) {
            // No ACL found... assume default
            $roles = array('IS_AUTHENTICATED_ANONYMOUSLY');
        }

        return $roles;
    }
1025960
public function getRoles($domain = false, $expanded = true)
    {
        $pool = $this->pool;
        $tokenStorage = $this->tokenStorage;
        $authorizationChecker = $this->authorizationChecker;
        $rolesHierarchyList = $this->rolesHierarchy;

        $roles = [];
        $rolesReadOnly = [];

        if (!$tokenStorage->getToken()) {
            return [$roles, $rolesReadOnly];
        }

        $isMaster = $authorizationChecker->isGranted('ROLE_SUPER_ADMIN');

        // get roles from the service container
        foreach ($rolesHierarchyList as $name => $rolesHierarchy) {
            if ($isMaster || $authorizationChecker->isGranted($name)) {
                $roles[$name] = $name;

                /** @var array $rolesHierarchy */
                foreach ($rolesHierarchy as $role) {
                    if (!isset($roles[$role]) && !\in_array($role, [
                            'ROLE_SONATA_ADMIN',
                            'ROLE_USER',
                            'ROLE_SONATA_MEDIA_ADMIN_MEDIA_LIST',
                            'ROLE_SONATA_MEDIA_ADMIN_MEDIA_CREATE',
                            'ROLE_SONATA_MEDIA_ADMIN_MEDIA_VIEW',
                            'ROLE_SONATA_MEDIA_ADMIN_MEDIA_EDIT',
                        ], true)) {
                        $roles[$role] = $role;
                    }
                }
            }
        }

        // get roles from the Admin classes
        foreach ($pool->getAdminServiceIds() as $id) {
            try {
                $admin = $pool->getInstance($id);
            } catch (\Exception $e) {
                continue;
            }

            $isMaster = $admin->isGranted('MASTER');
            $securityHandler = $admin->getSecurityHandler();

            $baseRole = $securityHandler->getBaseRole($admin);

            if ('' === $baseRole) { // the security handler related to the admin does not provide a valid string
                continue;
            }

            $items = [
                'LIST',
                'VIEW',
                'EDIT',
                'CREATE',
                'DELETE',
                'UNDELETE',
                'EXPORT',
                'IMPORT',
                'SETTINGS',
            ];

            if (\in_array($id, [
                'sonata.media.admin.media',
                'sonata.media.admin.gallery',
                'sonata.media.admin.gallery_has_media',
                'sonata.page.admin.snapshot',
                'sonata.page.admin.shared_block',
            ], true)) {
                continue;
            }

            foreach ($items as $role_item) {
                $role = sprintf($baseRole, $role_item);

                //$role_label = $translator->trans($admin->getLabel(), [], $admin->getTranslationDomain())
                //    . ' - '
                //    . $translator->trans('ROLE_' . $role_item, [], $admin->getTranslationDomain());

                $role_label = $role;

                if ($isMaster) {
                    // if the user has the MASTER permission, allow to grant access the admin roles to other users
                    $roles[$role] = $role_label;
                } elseif ($authorizationChecker->isGranted($role)) {
                    // although the user has no MASTER permission, allow the currently logged in user to view the role
                    $rolesReadOnly[$role] = $role_label;
                }
            }
        }

        return $roles;
    }
446233
public function setPolicy(string $policy)
    {
        // allow (all is deny, allow part) | deny (all is allow, deny part) | none (all is allow, ignore part)
        if (!in_array($policy, [self::POLICY_NONE, self::POLICY_ALLOW, self::POLICY_DENY])) {
            throw new Exception('Unsupported policy type: ' . $policy);
        }
        $this->policy = $policy;

        $this->init();   // init data after set policy (in extension)!
    }
1209437
public static cachepolicy_binding[] get(nitro_service service, String policyname[]) throws Exception{
		if (policyname !=null && policyname.length>0) {
			cachepolicy_binding response[] = new cachepolicy_binding[policyname.length];
			cachepolicy_binding obj[] = new cachepolicy_binding[policyname.length];
			for (int i=0;i<policyname.length;i++) {
				obj[i] = new cachepolicy_binding();
				obj[i].set_policyname(policyname[i]);
				response[i] = (cachepolicy_binding) obj[i].get_resource(service);
			}
			return response;
		}
		return null;
	}
39796
public function toLegacy(Policy $policy)
    {
        if ($policy->limitations !== '*' && isset($policy->limitations[Limitation::STATE])) {
            if ($policy->limitations[Limitation::STATE] === '*') {
                $map = array_fill_keys(array_keys($this->getGroupMap()), '*');
            } else {
                $map = $this->getGroupMap($policy->limitations[Limitation::STATE]);
            }
            $policy->limitations += $map;
            unset($policy->limitations[Limitation::STATE]);
        }
    }
657060
public function addPolicy($roleId, Policy $policy)
    {
        $legacyPolicy = clone $policy;
        $this->limitationConverter->toLegacy($legacyPolicy);

        $this->roleGateway->addPolicy($roleId, $legacyPolicy);
        $policy->id = $legacyPolicy->id;
        $policy->roleId = $legacyPolicy->roleId;

        return $policy;
    }
648488
public static policypatset[] get(nitro_service service) throws Exception{
		policypatset obj = new policypatset();
		policypatset[] response = (policypatset[])obj.get_resources(service);
		return response;
	}
1103726
public function addPolicy($roleId, Policy $policy)
    {
        try {
            return $this->innerGateway->addPolicy($roleId, $policy);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
576031
public function withPolicySet(string ...$policies): self
    {
        $obj = clone $this;
        $obj->_policySet = $policies;
        return $obj;
    }
1345328
public GetIdentityPoliciesResult withPolicies(java.util.Map<String, String> policies) {
        setPolicies(policies);
        return this;
    }
922458
public function getContentKeyAuthorizationPolicyList()
    {
        $propertyList = $this->_getEntityList('ContentKeyAuthorizationPolicies');
        $result = [];

        foreach ($propertyList as $properties) {
            $result[] = ContentKeyAuthorizationPolicy::createFromOptions($properties);
        }

        return $result;
    }
25429
private function getPoliciesNumbers(array $policies): array
    {
        $policiesNumbers = array_column($policies, 'id');

        return array_combine($policiesNumbers, array_fill_keys($policiesNumbers, false));
    }
664975
public function getAllPolicyDefinitions()
  {

    // Sort $policies
    // 1. By weight. Lighter policies float to the top.
    // 2. By name, alphabetical sorting.
    uasort($this->policies, function (PolicyDefinition $a, PolicyDefinition $b) {

      // 1. By weight. Lighter policies float to the top.
      if ($a->getWeight() == $b->getWeight()) {
        $alpha = [$a->getName(), $b->getName()];
        sort($alpha);
        // 2. By name, alphabetical sorting.
        return $alpha[0] == $a->getName() ? -1 : 1;
      }
      return $a->getWeight() > $b->getWeight() ? 1 : -1;
    });
    return $this->policies;
  }
648829
protected function getAuthorizationParameters(array $options)
    {
        $params = parent::getAuthorizationParameters($options);
        unset($params['approval_prompt']);
        if (!empty($options['prompt'])) {
            $params['prompt'] = $options['prompt'];
        }

        return $params;
    }
1317846
private function getCacheContent($policy, $cache, &$data) {
        $policyContent = $this->tryReadFile($policy);
        $cacheContent = $this->tryReadFile($cache);
        $data = null;

        if ($policyContent === false || $cacheContent === false) {
            $this->tryDeleteFile($policy);
            $this->tryDeleteFile($cache);
            return false;
        }

        $policyEntry = json_decode($policyContent, true);

        $absoluteExpiration = (int)$policyEntry['absoluteExpiration'];

        if ($absoluteExpiration != 0 && $absoluteExpiration < time()) {
            $this->tryDeleteFile($policy);
            $this->tryDeleteFile($cache);
            return false;
        }

        $data = unserialize($cacheContent);

        return true;
    }