/** * {@inheritdoc } */ public function getSchemeAndHost() { return sprintf('%s://%s', $this->baseUrl->getScheme(), $this->baseUrl->getHost()); }
protected function parseConnections($options, $defaultHost, $defaultPort) { if (isset($options['host']) || isset($options['port'])) { $options['connections'][] = $options; } /** @var Url[] $toParse */ $toParse = []; if (isset($options['connections'])) { foreach ((array) $options['connections'] as $alias => $conn) { if (is_string($conn)) { $conn = ['host' => $conn]; } $scheme = isset($conn['scheme']) ? $conn['scheme'] : 'tcp'; $host = isset($conn['host']) ? $conn['host'] : $defaultHost; $url = new Url($scheme, $host); $url->setPort(isset($conn['port']) ? $conn['port'] : $defaultPort); if (isset($conn['path'])) { $url->setPath($conn['path']); } if (isset($conn['password'])) { $url->setPassword($conn['password']); } $url->getQuery()->replace($conn); $toParse[] = $url; } } elseif (isset($options['save_path'])) { foreach (explode(',', $options['save_path']) as $conn) { $toParse[] = Url::fromString($conn); } } $connections = []; foreach ($toParse as $url) { $connections[] = ['scheme' => $url->getScheme(), 'host' => $url->getHost(), 'port' => $url->getPort(), 'path' => $url->getPath(), 'alias' => $url->getQuery()->get('alias'), 'prefix' => $url->getQuery()->get('prefix'), 'password' => $url->getPassword(), 'database' => $url->getQuery()->get('database'), 'persistent' => $url->getQuery()->get('persistent'), 'weight' => $url->getQuery()->get('weight'), 'timeout' => $url->getQuery()->get('timeout')]; } return $connections; }
/** * Ensures that the url of the certificate is one belonging to AWS, and not * just something from the amazonaws domain, which includes S3 buckets. * * @param Url $url * * @throws MessageValidatorException if the cert url is invalid */ private function validateUrl(Url $url) { // The cert URL must be https, a .pem, and match the following pattern. $hostPattern = '/^sns\\.[a-zA-Z0-9\\-]{3,}\\.amazonaws\\.com(\\.cn)?$/'; if ($url->getScheme() !== 'https' || substr($url, -4) !== '.pem' || !preg_match($hostPattern, $url->getHost())) { throw new MessageValidatorException('The certificate is located ' . 'on an invalid domain.'); } }