Пример #1
1
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     if (method_exists($e->getRequest(), 'getHeaders')) {
         $headers = $e->getRequest()->getHeaders();
         if ($headers->has('Origin') && $headers->has('X-Requested-With') && $headers->addHeaderLine('Access-Control-Allow-Methods: PUT, GET, POST, PATCH, DELETE, OPTIONS') && $headers->get('X-Requested-With')->getFieldValue() === 'com.ionicframework.notifycar') {
             //convert to array because get method throw an exception
             $headersArray = $headers->toArray();
             $origin = $headersArray['Origin'];
             if ($origin === 'file://') {
                 unset($headersArray['Origin']);
                 $headers->clearHeaders();
                 $headers->addHeaders($headersArray);
                 //$headers->addHeaderLine('Access-Control-Allow-Methods: PUT, GET, POST, PATCH, DELETE, OPTIONS');
                 //this is a valid uri
                 $headers->addHeaderLine('Origin', 'file://mobile');
             } else {
                 if ($origin === 'chrome-extension') {
                     unset($headersArray['Origin']);
                     $headers->clearHeaders();
                     $headers->addHeaders($headersArray);
                     //$headers->addHeaderLine('Access-Control-Allow-Methods: PUT, GET, POST, PATCH, DELETE, OPTIONS');
                     //this is a valid uri
                     $headers->addHeaderLine('Origin', 'chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop');
                     //$headers->addHeaderLine('Origin', 'chrome-extension://aicmkgpgakddgnaphhhpliifpcfhicfo');
                 }
             }
         }
     }
 }
Пример #2
0
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
 }
Пример #3
0
 /**
  * Test registering a new Scheme
  *
  * @param        string $scheme
  * @param        string $class
  * @dataProvider registeringNewSchemeProvider
  */
 public function testRegisteringNewScheme($scheme, $class)
 {
     $this->assertAttributeNotContains($class, 'schemeClasses', '\\Zend\\Uri\\UriFactory');
     UriFactory::registerScheme($scheme, $class);
     $this->assertAttributeContains($class, 'schemeClasses', '\\Zend\\Uri\\UriFactory');
     UriFactory::unregisterScheme($scheme);
     $this->assertAttributeNotContains($class, 'schemeClasses', '\\Zend\\Uri\\UriFactory');
 }
 public function onBootstrap(MvcEvent $mvcEvent)
 {
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     // add chrome-extension for API Client
     $serviceManager = $mvcEvent->getApplication()->getServiceManager();
     $eventManager = $mvcEvent->getApplication()->getEventManager();
     $sharedEventManager = $eventManager->getSharedManager();
 }
Пример #5
0
 public function onBootstrap(MvcEvent $e)
 {
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // get the cache listener service
     $cacheListener = $e->getApplication()->getServiceManager()->get('Columnis\\Model\\CacheListener');
     // attach the listeners to the event manager
     $e->getApplication()->getEventManager()->attach($cacheListener);
 }
Пример #6
0
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $this->services = $e->getApplication()->getServiceManager();
     $eventManager->attach(MvcAuthEvent::EVENT_AUTHENTICATION, $this->services->get('DotUser\\Authentication\\AuthenticationListener'), 100);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, $this->services->get('DotUser\\Authentication\\OauthRouteGuard'));
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     $this->fixBrokenOriginHeader($e->getRequest());
 }
 public function __construct($url, $apiKey, $sharedSecret, ApiVersion $version, $timeout = 30)
 {
     $this->lastRequest = null;
     $this->apiKey = trim($apiKey);
     $this->signature = hash("sha256", $apiKey . trim($sharedSecret) . time());
     $this->httpClient = new Client();
     $this->httpClient->setOptions(["timeout" => $timeout]);
     UriFactory::registerScheme("https", "hotelbeds\\hotel_api_sdk\\types\\ApiUri");
     $this->apiUri = UriFactory::factory($url);
     $this->apiUri->prepare($version);
 }
Пример #8
0
 public function onBootstrap(MvcEvent $mvcEvent)
 {
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     // add chrome-extension for API Client
     $serviceManager = $mvcEvent->getApplication()->getServiceManager();
     $eventManager = $mvcEvent->getApplication()->getEventManager();
     $sharedEventManager = $eventManager->getSharedManager();
     // attach image shared event listener
     $sharedEventManager->attachAggregate($serviceManager->get('AqilixAPI\\Image\\SharedEventListener'));
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // set role based on oAuth client id
     $eventManager->attach(MvcAuthEvent::EVENT_AUTHENTICATION_POST, function ($mvcAuthEvent) {
         $identity = $mvcAuthEvent->getIdentity();
         $authIdentity = $identity->getAuthenticationIdentity();
         if (!$identity instanceof \ZF\MvcAuth\Identity\GuestIdentity) {
             $identity->setName($authIdentity['client_id']);
         }
     }, 100);
     // attach ACL for checking Scope
     $eventManager->attach(MvcAuthEvent::EVENT_AUTHORIZATION_POST, $serviceManager->get('AqilixAPI\\Image\\Authorization\\AclScopeListener'), 101);
     // attach ACL for checking Image Owner
     $eventManager->attach(MvcAuthEvent::EVENT_AUTHORIZATION_POST, $serviceManager->get('AqilixAPI\\Image\\Authorization\\AclImageListener'), 100);
 }
Пример #9
0
 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     $headers = $e->getRequest()->getHeaders();
     if ($headers->has('Origin')) {
         //        if ($headers->has('Origin') &&
         //        $headers->has('X-Requested-With') &&
         //        $headers->has('X-Requested-With')->getFieldValue() === 'com.ionicframework.codeorder918719')
         //        {
         //convert to array because get method throw an exception
         $headersArray = $headers->toArray();
         $origin = $headersArray['Origin'];
         if ($origin === 'file://') {
             unset($headersArray['Origin']);
             $headers->clearHeaders();
             $headers->addHeaders($headersArray);
             //this is a valid uri
             $headers->addHeaderLine('Origin', 'file://mobile');
         }
     }
 }
Пример #10
0
<?php

use Zend\Uri\UriFactory;
require __DIR__ . '/src/ExpressApi/Module.php';
UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
Пример #11
0
 /**
  * Makes \Zend\Uri recognize the ftp:// scheme.
  */
 protected function registerFtpUriScheme()
 {
     UriFactory::registerScheme('ftp', Uri::class);
 }
Пример #12
0
use Rhumsaa\Uuid\Uuid;
use Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException;
use Symfony\Component\Filesystem\Filesystem;
use Zend\Uri\UriFactory;
use TheFox\Logger\Logger;
use TheFox\Logger\StreamHandler;
use TheFox\PhpChat\Settings;
use TheFox\Dht\Kademlia\Node;
$filesystem = new Filesystem();
$filesystem->mkdir('log', 0700);
$filesystem->mkdir('pid', 0700);
$log = new Logger('main');
$log->pushHandler(new StreamHandler('php://stdout', Logger::INFO));
$log->pushHandler(new StreamHandler('log/bootstrap.log', Logger::DEBUG));
UriFactory::registerScheme('tcp', 'TheFox\\PhpChat\\TcpUri');
UriFactory::registerScheme('http', 'TheFox\\PhpChat\\HttpUri');
$settings = new Settings(__DIR__ . '/settings.yml');
if (isset($settings->data['datadir']) && !file_exists($settings->data['datadir'])) {
    $log->info('create datadir: ' . $settings->data['datadir']);
    $filesystem->mkdir($settings->data['datadir'], 0700);
}
if (!$settings->data['node']['sslKeyPrvPass']) {
    $sslKeyPrvPass = '';
    try {
        $log->info('ssl: generate private key password');
        $sslKeyPrvPass = (string) Uuid::uuid4();
    } catch (UnsatisfiedDependencyException $e) {
        $log->critical('uuid4: ' . $e->getMessage());
        exit(1);
    }
    $settings->data['node']['sslKeyPrvPass'] = hash('sha512', mt_rand(0, 999999) . '_' . time() . '_' . $sslKeyPrvPass);
 /**
  * HotelApiClient Constructor they initialize SDK Client.
  * @param string $url Base URL of hotel-api service.
  * @param string $apiKey Client APIKey
  * @param string $sharedSecret Shared secret
  * @param ApiVersion $version Version of HotelAPI Interface
  * @param int $timeout HTTP Client timeout
  * @param string $adapter Customize adapter for http request
  */
 public function __construct($url, $apiKey, $sharedSecret, ApiVersion $version, $timeout = 30, $adapter = null)
 {
     $this->lastRequest = null;
     $this->apiKey = trim($apiKey);
     $this->sharedSecret = trim($sharedSecret);
     $this->httpClient = new Client();
     if ($adapter != null) {
         $this->httpClient->setOptions(["adapter" => $adapter, "timeout" => $timeout]);
     } else {
         $this->httpClient->setOptions(["timeout" => $timeout]);
     }
     UriFactory::registerScheme("https", "hotelbeds\\hotel_api_sdk\\types\\ApiUri");
     $this->apiUri = UriFactory::factory($url);
     $this->apiUri->prepare($version);
 }