Get JWT verification keys from Azure Active Directory.

@return array
772655
public function getJwtVerificationKeys()
    {
        $factory = $this->getRequestFactory();
        $request = $factory->getRequestWithOptions('get', 'https://login.windows.net/common/discovery/keys', []);

        $response = $this->getParsedResponse($request);

        $keys = [];
        foreach ($response['keys'] as $i => $keyinfo) {
            if (isset($keyinfo['x5c']) && is_array($keyinfo['x5c'])) {
                foreach ($keyinfo['x5c'] as $encodedkey) {
                    $cert =
                        '-----BEGIN CERTIFICATE-----' . PHP_EOL
                        . chunk_split($encodedkey, 64,  PHP_EOL)
                        . '-----END CERTIFICATE-----' . PHP_EOL;

                    $cert_object = openssl_x509_read($cert);

                    if ($cert_object === false) {
                        throw new \RuntimeException('An attempt to read ' . $encodedkey . ' as a certificate failed.');
                    }

                    $pkey_object = openssl_pkey_get_public($cert_object);

                    if ($pkey_object === false) {
                        throw new \RuntimeException('An attempt to read a public key from a ' . $encodedkey . ' certificate failed.');
                    }

                    $pkey_array = openssl_pkey_get_details($pkey_object);

                    if ($pkey_array === false) {
                        throw new \RuntimeException('An attempt to get a public key as an array from a ' . $encodedkey . ' certificate failed.');
                    }

                    $publicKey = $pkey_array ['key'];

                    $keys[$keyinfo['kid']] = $publicKey;
                }
            }
        }

        return $keys;
    }
1175836
protected function getAclRoles()
    {
        $aclRoles = [];
        $roleHierarchy = $this->container->getParameter('security.role_hierarchy.roles');
        $pool = $this->container->get('sonata.admin.pool');

        foreach ($pool->getAdminServiceIds() as $id) {
            try {
                $admin = $pool->getInstance($id);
            } catch (\Exception $e) {
                continue;
            }

            $baseRole = $admin->getSecurityHandler()->getBaseRole($admin);
            foreach ($admin->getSecurityInformation() as $role => $permissions) {
                $role = sprintf($baseRole, $role);
                $aclRoles[] = $role;
            }
        }

        foreach ($roleHierarchy as $name => $roles) {
            $aclRoles[] = $name;
            $aclRoles = array_merge($aclRoles, $roles);
        }

        $aclRoles = array_unique($aclRoles);

        return \is_array($aclRoles) ? new \ArrayIterator($aclRoles) : $aclRoles;
    }
895452
public function getUnavailableRegistrationIds()
    {
        if ($this->getFailureCount() == 0) {
            return array();
        }
        $filteredResults = array_filter(
            $this->results,
            function ($result) {
                return (
                    isset($result['error'])
                    &&
                    ($result['error'] == "Unavailable")
                );
            }
        );

        return array_keys($filteredResults);
    }
798993
protected function _getKeys() {
        $keys = $this->Permissions->schema()->columns();
        $newKeys = array();
        foreach ($keys as $key) {
            if (!in_array($key, array('id', 'aro_id', 'aco_id'))) {
                $newKeys[] = $key;
            }
        }
        return $newKeys;
    }
525406
protected function GetOrderOrPayIdAuthenticationArray()
    {
        $aAuthArray = array();
        if (isset($this->aXMLResponseData['PAYID']) && !empty($this->aXMLResponseData['PAYID'])) {
            $aAuthArray = array('PAYID' => $this->aXMLResponseData['PAYID']);
        } elseif (isset($this->aPaymentUserData['ORDERID']) && !empty($this->aPaymentUserData['ORDERID'])) {
            $aAuthArray = array('ORDERID' => $this->aPaymentUserData['ORDERID']);
        }

        return $aAuthArray;
    }
905400
public function getSandBoxKeys()
    {
        if ($this->getType() !== self::TYPE_REQUEST) {
            return array();
        }

        return array(
            \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY  => \SwaggerValidator\Common\Sandbox::getInstance()->hasBody(),
            \SwaggerValidator\Common\FactorySwagger::LOCATION_FORM  => \SwaggerValidator\Common\Sandbox::getInstance()->keysForm(),
            \SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY => \SwaggerValidator\Common\Sandbox::getInstance()->keysQueryString(),
        );
    }
498175
public function findExpiredIdentifiers(): array
    {
        $queryBuilder = $this->createQuery();
        $rows = $queryBuilder->select('identifier')
            ->from($this->getTableName())
            ->where($queryBuilder->expr()->lt(
                'expires',
                $queryBuilder->createNamedParameter((new DateTimeService())->getCurrentTime(), \PDO::PARAM_INT)
            ))
            ->groupBy('identifier')
            ->execute()
            ->fetchAll();

        $cacheIdentifiers = [];
        foreach ($rows as $row) {
            $cacheIdentifiers[] = $row['identifier'];
        }

        return $cacheIdentifiers;
    }
1080705
public function validated(): array
    {
        $config = $this->container->make('katsana.manager')->config('webhook');

        $signature = new Signature($config['signature']);
        $header = $this->header('X_SIGNATURE') ?? '';

        if (! $signature->verify($header, $this->getContent(), ($config['threshold'] ?? 3600))) {
            throw new HttpException(419, 'Unable to verify X-Signature.');
        }

        return $this->post();
    }
1232590
private function getCredentials()
    {
        $options = ['--config ui.interactive' => 'no', '--config auth.x.prefix' => 'http://'];

        $repository = $this->credentials->getCurrentRepository();
        if ($user = $repository->username) {
            $options['--config auth.x.username'] = $user;
        }
        if ($pass = $repository->password) {
            $options['--config auth.x.password'] = $pass;
        }

        return $options;
    }
980761
public function getRepositoryCredentials()
    {
        $endpoint = $this->vcs->runLocally('currentEndpoint');
        $user = $this->bash->runLocally('whoami');

        return $this->askQuestions('vcs', [
            'repository' => ['Where is your code located?', $endpoint],
            'username' => ['What is the username for it?', $user],
            'password' => 'And the password?',
        ]);
    }
1248734
protected function loadCredentials()
    {
        $instance = $this->getInstance();
        if ($instance && $instance->exists()) {

            $props = $instance->getPropertiesValues([
                $this->getProperty(self::PROPERTY_LOGIN),
                $this->getProperty(self::PROPERTY_PASSWORD)
            ]);

            $data = [
                self::PROPERTY_LOGIN => (string)current($props[self::PROPERTY_LOGIN]),
                self::PROPERTY_PASSWORD => (string)current($props[self::PROPERTY_PASSWORD]),
            ];
        } else {
            $data = [
                self::PROPERTY_LOGIN => '',
                self::PROPERTY_PASSWORD => '',
            ];
        }

        return $data;
    }
533168
public static function getSupportedAuthMethods()
    {
        return array(
            ezcMailSmtpTransport::AUTH_DIGEST_MD5,
            ezcMailSmtpTransport::AUTH_CRAM_MD5,
            ezcMailSmtpTransport::AUTH_NTLM,
            ezcMailSmtpTransport::AUTH_LOGIN,
            ezcMailSmtpTransport::AUTH_PLAIN,
            );
    }
1062625
protected function computeJwt()
    {
        $payload = [
            'iss' => $this->config->get('client_id'),
            'aud' => sprintf('%s/%s', rtrim($this->client->getBaseUrl(), '/'), ltrim($this->config->get('token_url'), '/')),
            'exp' => time() + 60 * 60,
            'iat' => time()
        ];

        return JWT::encode($payload, $this->readPrivateKey($this->config->get('private_key')), 'RS256');
    }
1076215
protected function getKeys()
    {
        $identifier = $this->getIdentifier();

        $query = new Query();
        $selectNode = new Node\SelectNode([$identifier]);
        $query->setSelect($selectNode);
        $queryResult = $this->query($query);
        $keysArray = [];

        foreach ($queryResult as $row) {
            $keysArray[] = $row[$identifier];
        }

        return $keysArray;
    }
428539
public function getActiveEntities() {
      $response = $this->client->request('get', 'getActiveEntities');
      return [
         'statusCode' => $response->getStatusCode(),
         'body' => $response->getBody()->getContents(),
      ];
   }
254658
public function getIds()
    {
        $ids      = array();
        $iterator = new APCUIterator('user', null, APCU_ITER_KEY);
        foreach ($iterator as $item) {
            $ids[] = $item['key'];
        }

        return $ids;
    }
1245920
protected function getPublicParams()
    {
        return [
            'AccessKeyId'      => $this->config['accessKeyId'],
            'Timestamp'        => $this->getTimestamp(),
            'Format'           => $this->format,
            'SignatureMethod'  => $this->signatureMethod,
            'SignatureVersion' => '1.0',
            'SignatureNonce'   => uniqid(),
            'Version'          => '2017-05-25',
            'RegionId'         => 'cn-hangzhou',
        ];
    }